babylon.d.ts 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878
  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. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. R16F: number;
  239. RG16F: number;
  240. RGB16F: number;
  241. RED: number;
  242. RG: number;
  243. R8: number;
  244. RG8: number;
  245. UNSIGNED_INT_24_8: number;
  246. DEPTH24_STENCIL8: number;
  247. drawBuffers(buffers: number[]): void;
  248. readBuffer(src: number): void;
  249. readonly COLOR_ATTACHMENT0: number;
  250. readonly COLOR_ATTACHMENT1: number;
  251. readonly COLOR_ATTACHMENT2: number;
  252. readonly COLOR_ATTACHMENT3: number;
  253. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  254. ANY_SAMPLES_PASSED: number;
  255. QUERY_RESULT_AVAILABLE: number;
  256. QUERY_RESULT: number;
  257. }
  258. interface Document {
  259. mozCancelFullScreen(): void;
  260. msCancelFullScreen(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. fullscreen: boolean;
  264. mozPointerLockElement: HTMLElement;
  265. msPointerLockElement: HTMLElement;
  266. webkitPointerLockElement: HTMLElement;
  267. }
  268. interface HTMLCanvasElement {
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  284. }
  285. interface MouseEvent {
  286. mozMovementX: number;
  287. mozMovementY: number;
  288. webkitMovementX: number;
  289. webkitMovementY: number;
  290. msMovementX: number;
  291. msMovementY: number;
  292. }
  293. interface Navigator {
  294. mozGetVRDevices: (any: any) => any;
  295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. webkitGetGamepads(): Gamepad[];
  299. msGetGamepads(): Gamepad[];
  300. webkitGamepads(): Gamepad[];
  301. }
  302. interface HTMLVideoElement {
  303. mozSrcObject: any;
  304. }
  305. interface Screen {
  306. orientation: string;
  307. mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Node is the basic class for all scene objects (Mesh, Light Camera).
  333. */
  334. class Node implements IBehaviorAware<Node> {
  335. /**
  336. * Gets or sets the name of the node
  337. */
  338. name: string;
  339. /**
  340. * Gets or sets the id of the node
  341. */
  342. id: string;
  343. /**
  344. * Gets or sets the unique id of the node
  345. */
  346. uniqueId: number;
  347. /**
  348. * Gets or sets a string used to store user defined state for the node
  349. */
  350. state: string;
  351. /**
  352. * Gets or sets an object used to store user defined information for the node
  353. */
  354. metadata: any;
  355. /**
  356. * Gets or sets a boolean used to define if the node must be serialized
  357. */
  358. doNotSerialize: boolean;
  359. /** @hidden */
  360. _isDisposed: boolean;
  361. /**
  362. * Gets a list of Animations associated with the node
  363. */
  364. animations: Animation[];
  365. private _ranges;
  366. /**
  367. * Callback raised when the node is ready to be used
  368. */
  369. onReady: (node: Node) => void;
  370. private _isEnabled;
  371. private _isReady;
  372. /** @hidden */
  373. _currentRenderId: number;
  374. private _parentRenderId;
  375. protected _childRenderId: number;
  376. /** @hidden */
  377. _waitingParentId: Nullable<string>;
  378. private _scene;
  379. /** @hidden */
  380. _cache: any;
  381. private _parentNode;
  382. private _children;
  383. /**
  384. * Gets a boolean indicating if the node has been disposed
  385. * @returns true if the node was disposed
  386. */
  387. isDisposed(): boolean;
  388. /**
  389. * Gets or sets the parent of the node
  390. */
  391. parent: Nullable<Node>;
  392. private _animationPropertiesOverride;
  393. /**
  394. * Gets or sets the animation properties override
  395. */
  396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  397. /**
  398. * Gets a string idenfifying the name of the class
  399. * @returns "Node" string
  400. */
  401. getClassName(): string;
  402. /**
  403. * An event triggered when the mesh is disposed
  404. */
  405. onDisposeObservable: Observable<Node>;
  406. private _onDisposeObserver;
  407. /**
  408. * Sets a callback that will be raised when the node will be disposed
  409. */
  410. onDispose: () => void;
  411. /**
  412. * Creates a new Node
  413. * @param {string} name - the name and id to be given to this node
  414. * @param {BABYLON.Scene} the scene this node will be added to
  415. */
  416. constructor(name: string, scene?: Nullable<Scene>);
  417. /**
  418. * Gets the scene of the node
  419. * @returns a {BABYLON.Scene}
  420. */
  421. getScene(): Scene;
  422. /**
  423. * Gets the engine of the node
  424. * @returns a {BABYLON.Engine}
  425. */
  426. getEngine(): Engine;
  427. private _behaviors;
  428. /**
  429. * Attach a behavior to the node
  430. * @see http://doc.babylonjs.com/features/behaviour
  431. * @param behavior defines the behavior to attach
  432. * @returns the current Node
  433. */
  434. addBehavior(behavior: Behavior<Node>): Node;
  435. /**
  436. * Remove an attached behavior
  437. * @see http://doc.babylonjs.com/features/behaviour
  438. * @param behavior defines the behavior to attach
  439. * @returns the current Node
  440. */
  441. removeBehavior(behavior: Behavior<Node>): Node;
  442. /**
  443. * Gets the list of attached behaviors
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. */
  446. readonly behaviors: Behavior<Node>[];
  447. /**
  448. * Gets an attached behavior by name
  449. * @param name defines the name of the behavior to look for
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. * @returns null if behavior was not found else the requested behavior
  452. */
  453. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  454. /**
  455. * Returns the world matrix of the node
  456. * @returns a matrix containing the node's world matrix
  457. */
  458. getWorldMatrix(): Matrix;
  459. /** @hidden */
  460. _getWorldMatrixDeterminant(): number;
  461. /** @hidden */
  462. _initCache(): void;
  463. /** @hidden */
  464. updateCache(force?: boolean): void;
  465. /** @hidden */
  466. _updateCache(ignoreParentClass?: boolean): void;
  467. /** @hidden */
  468. _isSynchronized(): boolean;
  469. /** @hidden */
  470. _markSyncedWithParent(): void;
  471. /** @hidden */
  472. isSynchronizedWithParent(): boolean;
  473. /** @hidden */
  474. isSynchronized(updateCache?: boolean): boolean;
  475. /** @hidden */
  476. hasNewParent(update?: boolean): boolean;
  477. /**
  478. * Is this node ready to be used/rendered
  479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  480. * @return true if the node is ready
  481. */
  482. isReady(completeCheck?: boolean): boolean;
  483. /**
  484. * Is this node enabled?
  485. * 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
  486. * @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
  487. * @return whether this node (and its parent) is enabled
  488. */
  489. isEnabled(checkAncestors?: boolean): boolean;
  490. /**
  491. * Set the enabled state of this node
  492. * @param value defines the new enabled state
  493. */
  494. setEnabled(value: boolean): void;
  495. /**
  496. * Is this node a descendant of the given node?
  497. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  498. * @param ancestor defines the parent node to inspect
  499. * @returns a boolean indicating if this node is a descendant of the given node
  500. */
  501. isDescendantOf(ancestor: Node): boolean;
  502. /** @hidden */
  503. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  504. /**
  505. * Will return all nodes that have this node as ascendant
  506. * @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
  507. * @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
  508. * @return all children nodes of all types
  509. */
  510. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  511. /**
  512. * Get all child-meshes of this node
  513. * @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
  514. * @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
  515. * @returns an array of {BABYLON.AbstractMesh}
  516. */
  517. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  518. /**
  519. * Get all child-transformNodes of this node
  520. * @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
  521. * @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
  522. * @returns an array of {BABYLON.TransformNode}
  523. */
  524. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  525. /**
  526. * Get all direct children of this node
  527. * @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
  528. * @returns an array of {BABYLON.Node}
  529. */
  530. getChildren(predicate?: (node: Node) => boolean): Node[];
  531. /** @hidden */
  532. _setReady(state: boolean): void;
  533. /**
  534. * Get an animation by name
  535. * @param name defines the name of the animation to look for
  536. * @returns null if not found else the requested animation
  537. */
  538. getAnimationByName(name: string): Nullable<Animation>;
  539. /**
  540. * Creates an animation range for this node
  541. * @param name defines the name of the range
  542. * @param from defines the starting key
  543. * @param to defines the end key
  544. */
  545. createAnimationRange(name: string, from: number, to: number): void;
  546. /**
  547. * Delete a specific animation range
  548. * @param name defines the name of the range to delete
  549. * @param deleteFrames defines if animation frames from the range must be deleted as well
  550. */
  551. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  552. /**
  553. * Get an animation range by name
  554. * @param name defines the name of the animation range to look for
  555. * @returns null if not found else the requested animation range
  556. */
  557. getAnimationRange(name: string): Nullable<AnimationRange>;
  558. /**
  559. * Will start the animation sequence
  560. * @param name defines the range frames for animation sequence
  561. * @param loop defines if the animation should loop (false by default)
  562. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  563. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  564. * @returns the object created for this animation. If range does not exist, it will return null
  565. */
  566. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  567. /**
  568. * Serialize animation ranges into a JSON compatible object
  569. * @returns serialization object
  570. */
  571. serializeAnimationRanges(): any;
  572. /**
  573. * Computes the world matrix of the node
  574. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  575. * @returns the world matrix
  576. */
  577. computeWorldMatrix(force?: boolean): Matrix;
  578. /**
  579. * Releases resources associated with this node.
  580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  582. */
  583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  584. /**
  585. * Parse animation range data from a serialization object and store them into a given node
  586. * @param node defines where to store the animation ranges
  587. * @param parsedNode defines the serialization object to read data from
  588. * @param scene defines the hosting scene
  589. */
  590. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  591. }
  592. }
  593. declare module BABYLON {
  594. /**
  595. * Define an interface for all classes that will hold resources
  596. */
  597. interface IDisposable {
  598. /**
  599. * Releases all held resources
  600. */
  601. dispose(): void;
  602. }
  603. /**
  604. * Interface used to let developers provide their own mesh selection mechanism
  605. */
  606. interface IActiveMeshCandidateProvider {
  607. /**
  608. * Return the list of active meshes
  609. * @param scene defines the current scene
  610. * @returns the list of active meshes
  611. */
  612. getMeshes(scene: Scene): AbstractMesh[];
  613. /**
  614. * Indicates if the meshes have been checked to make sure they are isEnabled()
  615. */
  616. readonly checksIsEnabled: boolean;
  617. }
  618. /**
  619. * This class is used by the onRenderingGroupObservable
  620. */
  621. class RenderingGroupInfo {
  622. /**
  623. * The Scene that being rendered
  624. */
  625. scene: Scene;
  626. /**
  627. * The camera currently used for the rendering pass
  628. */
  629. camera: Nullable<Camera>;
  630. /**
  631. * The ID of the renderingGroup being processed
  632. */
  633. renderingGroupId: number;
  634. /**
  635. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  636. */
  637. renderStage: number;
  638. /**
  639. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  640. * This stage will be fired no matter what
  641. */
  642. static STAGE_PRECLEAR: number;
  643. /**
  644. * Called before opaque object are rendered.
  645. * This stage will be fired only if there's 3D Opaque content to render
  646. */
  647. static STAGE_PREOPAQUE: number;
  648. /**
  649. * Called after the opaque objects are rendered and before the transparent ones
  650. * This stage will be fired only if there's 3D transparent content to render
  651. */
  652. static STAGE_PRETRANSPARENT: number;
  653. /**
  654. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  655. * This stage will be fired no matter what
  656. */
  657. static STAGE_POSTTRANSPARENT: number;
  658. }
  659. /**
  660. * Represents a scene to be rendered by the engine.
  661. * @see http://doc.babylonjs.com/features/scene
  662. */
  663. class Scene implements IAnimatable {
  664. private static _FOGMODE_NONE;
  665. private static _FOGMODE_EXP;
  666. private static _FOGMODE_EXP2;
  667. private static _FOGMODE_LINEAR;
  668. private static _uniqueIdCounter;
  669. /**
  670. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MinDeltaTime: number;
  674. /**
  675. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  677. */
  678. static MaxDeltaTime: number;
  679. /** The fog is deactivated */
  680. static readonly FOGMODE_NONE: number;
  681. /** The fog density is following an exponential function */
  682. static readonly FOGMODE_EXP: number;
  683. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  684. static readonly FOGMODE_EXP2: number;
  685. /** The fog density is following a linear function. */
  686. static readonly FOGMODE_LINEAR: number;
  687. /**
  688. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  689. */
  690. autoClear: boolean;
  691. /**
  692. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  693. */
  694. autoClearDepthAndStencil: boolean;
  695. /**
  696. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  697. */
  698. clearColor: Color4;
  699. /**
  700. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  701. */
  702. ambientColor: Color3;
  703. /** @hidden */
  704. _environmentBRDFTexture: BaseTexture;
  705. /** @hidden */
  706. protected _environmentTexture: BaseTexture;
  707. /**
  708. * Texture used in all pbr material as the reflection texture.
  709. * As in the majority of the scene they are the same (exception for multi room and so on),
  710. * this is easier to reference from here than from all the materials.
  711. */
  712. /**
  713. * Texture used in all pbr material as the reflection texture.
  714. * As in the majority of the scene they are the same (exception for multi room and so on),
  715. * this is easier to set here than in all the materials.
  716. */
  717. environmentTexture: BaseTexture;
  718. /** @hidden */
  719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  720. /**
  721. * Default image processing configuration used either in the rendering
  722. * Forward main pass or through the imageProcessingPostProcess if present.
  723. * As in the majority of the scene they are the same (exception for multi camera),
  724. * this is easier to reference from here than from all the materials and post process.
  725. *
  726. * No setter as we it is a shared configuration, you can set the values instead.
  727. */
  728. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  729. private _forceWireframe;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  732. */
  733. forceWireframe: boolean;
  734. private _forcePointsCloud;
  735. /**
  736. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  737. */
  738. forcePointsCloud: boolean;
  739. /**
  740. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  741. */
  742. forceShowBoundingBoxes: boolean;
  743. /**
  744. * Gets or sets the active clipplane
  745. */
  746. clipPlane: Nullable<Plane>;
  747. /**
  748. * Gets or sets a boolean indicating if animations are enabled
  749. */
  750. animationsEnabled: boolean;
  751. private _animationPropertiesOverride;
  752. /**
  753. * Gets or sets the animation properties override
  754. */
  755. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  756. /**
  757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  759. */
  760. useConstantAnimationDeltaTime: boolean;
  761. /**
  762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  763. * Please note that it requires to run a ray cast through the scene on every frame
  764. */
  765. constantlyUpdateMeshUnderPointer: boolean;
  766. /**
  767. * Defines the HTML cursor to use when hovering over interactive elements
  768. */
  769. hoverCursor: string;
  770. /**
  771. * Defines the HTML default cursor to use (empty by default)
  772. */
  773. defaultCursor: string;
  774. /**
  775. * This is used to call preventDefault() on pointer down
  776. * in order to block unwanted artifacts like system double clicks
  777. */
  778. preventDefaultOnPointerDown: boolean;
  779. /**
  780. * Gets or sets user defined metadata
  781. */
  782. metadata: any;
  783. /**
  784. * Gets the name of the plugin used to load this scene (null by default)
  785. */
  786. loadingPluginName: string;
  787. /**
  788. * Use this array to add regular expressions used to disable offline support for specific urls
  789. */
  790. disableOfflineSupportExceptionRules: RegExp[];
  791. private _spritePredicate;
  792. /**
  793. * An event triggered when the scene is disposed.
  794. */
  795. onDisposeObservable: Observable<Scene>;
  796. private _onDisposeObserver;
  797. /** Sets a function to be executed when this scene is disposed. */
  798. onDispose: () => void;
  799. /**
  800. * An event triggered before rendering the scene (right after animations and physics)
  801. */
  802. onBeforeRenderObservable: Observable<Scene>;
  803. private _onBeforeRenderObserver;
  804. /** Sets a function to be executed before rendering this scene */
  805. beforeRender: Nullable<() => void>;
  806. /**
  807. * An event triggered after rendering the scene
  808. */
  809. onAfterRenderObservable: Observable<Scene>;
  810. private _onAfterRenderObserver;
  811. /** Sets a function to be executed after rendering this scene */
  812. afterRender: Nullable<() => void>;
  813. /**
  814. * An event triggered before animating the scene
  815. */
  816. onBeforeAnimationsObservable: Observable<Scene>;
  817. /**
  818. * An event triggered after animations processing
  819. */
  820. onAfterAnimationsObservable: Observable<Scene>;
  821. /**
  822. * An event triggered before draw calls are ready to be sent
  823. */
  824. onBeforeDrawPhaseObservable: Observable<Scene>;
  825. /**
  826. * An event triggered after draw calls have been sent
  827. */
  828. onAfterDrawPhaseObservable: Observable<Scene>;
  829. /**
  830. * An event triggered when physic simulation is about to be run
  831. */
  832. onBeforePhysicsObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when physic simulation has been done
  835. */
  836. onAfterPhysicsObservable: Observable<Scene>;
  837. /**
  838. * An event triggered when the scene is ready
  839. */
  840. onReadyObservable: Observable<Scene>;
  841. /**
  842. * An event triggered before rendering a camera
  843. */
  844. onBeforeCameraRenderObservable: Observable<Camera>;
  845. private _onBeforeCameraRenderObserver;
  846. /** Sets a function to be executed before rendering a camera*/
  847. beforeCameraRender: () => void;
  848. /**
  849. * An event triggered after rendering a camera
  850. */
  851. onAfterCameraRenderObservable: Observable<Camera>;
  852. private _onAfterCameraRenderObserver;
  853. /** Sets a function to be executed after rendering a camera*/
  854. afterCameraRender: () => void;
  855. /**
  856. * An event triggered when active meshes evaluation is about to start
  857. */
  858. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when active meshes evaluation is done
  861. */
  862. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  866. */
  867. onBeforeParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when particles rendering is done
  870. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  871. */
  872. onAfterParticlesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is about to start
  875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  876. */
  877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when sprites rendering is done
  880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  881. */
  882. onAfterSpritesRenderingObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  885. */
  886. onDataLoadedObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when a camera is created
  889. */
  890. onNewCameraAddedObservable: Observable<Camera>;
  891. /**
  892. * An event triggered when a camera is removed
  893. */
  894. onCameraRemovedObservable: Observable<Camera>;
  895. /**
  896. * An event triggered when a light is created
  897. */
  898. onNewLightAddedObservable: Observable<Light>;
  899. /**
  900. * An event triggered when a light is removed
  901. */
  902. onLightRemovedObservable: Observable<Light>;
  903. /**
  904. * An event triggered when a geometry is created
  905. */
  906. onNewGeometryAddedObservable: Observable<Geometry>;
  907. /**
  908. * An event triggered when a geometry is removed
  909. */
  910. onGeometryRemovedObservable: Observable<Geometry>;
  911. /**
  912. * An event triggered when a transform node is created
  913. */
  914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  915. /**
  916. * An event triggered when a transform node is removed
  917. */
  918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  919. /**
  920. * An event triggered when a mesh is created
  921. */
  922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  923. /**
  924. * An event triggered when a mesh is removed
  925. */
  926. onMeshRemovedObservable: Observable<AbstractMesh>;
  927. /**
  928. * An event triggered when render targets are about to be rendered
  929. * Can happen multiple times per frame.
  930. */
  931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered when render targets were rendered.
  934. * Can happen multiple times per frame.
  935. */
  936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  937. /**
  938. * An event triggered before calculating deterministic simulation step
  939. */
  940. onBeforeStepObservable: Observable<Scene>;
  941. /**
  942. * An event triggered after calculating deterministic simulation step
  943. */
  944. onAfterStepObservable: Observable<Scene>;
  945. /**
  946. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  948. * 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)
  949. */
  950. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  951. /**
  952. * Gets a list of Animations associated with the scene
  953. */
  954. animations: Animation[];
  955. private _registeredForLateAnimationBindings;
  956. /**
  957. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  958. */
  959. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  960. /**
  961. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  962. */
  963. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  964. /**
  965. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  966. */
  967. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  968. private _onPointerMove;
  969. private _onPointerDown;
  970. private _onPointerUp;
  971. /** Deprecated. Use onPointerObservable instead */
  972. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  973. /** Deprecated. Use onPointerObservable instead */
  974. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  975. /** Deprecated. Use onPointerObservable instead */
  976. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  977. /** Deprecated. Use onPointerObservable instead */
  978. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  979. private _gamepadManager;
  980. /**
  981. * Gets the gamepad manager associated with the scene
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  983. */
  984. readonly gamepadManager: GamepadManager;
  985. /**
  986. * 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).
  987. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  988. */
  989. onPrePointerObservable: Observable<PointerInfoPre>;
  990. /**
  991. * Observable event triggered each time an input event is received from the rendering canvas
  992. */
  993. onPointerObservable: Observable<PointerInfo>;
  994. /**
  995. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  996. */
  997. readonly unTranslatedPointer: Vector2;
  998. /** The distance in pixel that you have to move to prevent some events */
  999. static DragMovementThreshold: number;
  1000. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1001. static LongPressDelay: number;
  1002. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1003. static DoubleClickDelay: number;
  1004. /** If you need to check double click without raising a single click at first click, enable this flag */
  1005. static ExclusiveDoubleClickMode: boolean;
  1006. private _initClickEvent;
  1007. private _initActionManager;
  1008. private _delayedSimpleClick;
  1009. private _delayedSimpleClickTimeout;
  1010. private _previousDelayedSimpleClickTimeout;
  1011. private _meshPickProceed;
  1012. private _previousButtonPressed;
  1013. private _currentPickResult;
  1014. private _previousPickResult;
  1015. private _totalPointersPressed;
  1016. private _doubleClickOccured;
  1017. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1018. cameraToUseForPointers: Nullable<Camera>;
  1019. private _pointerX;
  1020. private _pointerY;
  1021. private _unTranslatedPointerX;
  1022. private _unTranslatedPointerY;
  1023. private _startingPointerPosition;
  1024. private _previousStartingPointerPosition;
  1025. private _startingPointerTime;
  1026. private _previousStartingPointerTime;
  1027. private _pointerCaptures;
  1028. private _timeAccumulator;
  1029. private _currentStepId;
  1030. private _currentInternalStep;
  1031. /** @hidden */
  1032. _mirroredCameraPosition: Nullable<Vector3>;
  1033. /**
  1034. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1035. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1036. */
  1037. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1038. /**
  1039. * Observable event triggered each time an keyboard event is received from the hosting window
  1040. */
  1041. onKeyboardObservable: Observable<KeyboardInfo>;
  1042. private _onKeyDown;
  1043. private _onKeyUp;
  1044. private _onCanvasFocusObserver;
  1045. private _onCanvasBlurObserver;
  1046. private _useRightHandedSystem;
  1047. /**
  1048. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1049. */
  1050. useRightHandedSystem: boolean;
  1051. /**
  1052. * Sets the step Id used by deterministic lock step
  1053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1054. * @param newStepId defines the step Id
  1055. */
  1056. setStepId(newStepId: number): void;
  1057. /**
  1058. * Gets the step Id used by deterministic lock step
  1059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1060. * @returns the step Id
  1061. */
  1062. getStepId(): number;
  1063. /**
  1064. * Gets the internal step used by deterministic lock step
  1065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1066. * @returns the internal step
  1067. */
  1068. getInternalStep(): number;
  1069. private _fogEnabled;
  1070. /**
  1071. * Gets or sets a boolean indicating if fog is enabled on this scene
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogEnabled: boolean;
  1075. private _fogMode;
  1076. /**
  1077. * Gets or sets the fog mode to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogMode: number;
  1081. /**
  1082. * Gets or sets the fog color to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogColor: Color3;
  1086. /**
  1087. * Gets or sets the fog density to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogDensity: number;
  1091. /**
  1092. * Gets or sets the fog start distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogStart: number;
  1096. /**
  1097. * Gets or sets the fog end distance to use
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. */
  1100. fogEnd: number;
  1101. private _shadowsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1104. */
  1105. shadowsEnabled: boolean;
  1106. private _lightsEnabled;
  1107. /**
  1108. * Gets or sets a boolean indicating if lights are enabled on this scene
  1109. */
  1110. lightsEnabled: boolean;
  1111. /**
  1112. * All of the lights added to this scene
  1113. * @see http://doc.babylonjs.com/babylon101/lights
  1114. */
  1115. lights: Light[];
  1116. /** All of the cameras added to this scene.
  1117. * @see http://doc.babylonjs.com/babylon101/cameras
  1118. */
  1119. cameras: Camera[];
  1120. /** All of the active cameras added to this scene. */
  1121. activeCameras: Camera[];
  1122. /** The current active camera */
  1123. activeCamera: Nullable<Camera>;
  1124. /**
  1125. * All of the tranform nodes added to this scene
  1126. * @see http://doc.babylonjs.com/how_to/transformnode
  1127. */
  1128. transformNodes: TransformNode[];
  1129. /**
  1130. * All of the (abstract) meshes added to this scene
  1131. */
  1132. meshes: AbstractMesh[];
  1133. /**
  1134. * All of the animation groups added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/group
  1136. */
  1137. animationGroups: AnimationGroup[];
  1138. private _geometries;
  1139. /**
  1140. * All of the materials added to this scene
  1141. * @see http://doc.babylonjs.com/babylon101/materials
  1142. */
  1143. materials: Material[];
  1144. /**
  1145. * All of the multi-materials added to this scene
  1146. * @see http://doc.babylonjs.com/how_to/multi_materials
  1147. */
  1148. multiMaterials: MultiMaterial[];
  1149. private _defaultMaterial;
  1150. /** The default material used on meshes when no material is affected */
  1151. /** The default material used on meshes when no material is affected */
  1152. defaultMaterial: Material;
  1153. private _texturesEnabled;
  1154. /**
  1155. * Gets or sets a boolean indicating if textures are enabled on this scene
  1156. */
  1157. texturesEnabled: boolean;
  1158. /**
  1159. * All of the textures added to this scene
  1160. */
  1161. textures: BaseTexture[];
  1162. /**
  1163. * Gets or sets a boolean indicating if particles are enabled on this scene
  1164. */
  1165. particlesEnabled: boolean;
  1166. /**
  1167. * All of the particle systems added to this scene
  1168. * @see http://doc.babylonjs.com/babylon101/particles
  1169. */
  1170. particleSystems: IParticleSystem[];
  1171. /**
  1172. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1173. */
  1174. spritesEnabled: boolean;
  1175. /**
  1176. * All of the sprite managers added to this scene
  1177. * @see http://doc.babylonjs.com/babylon101/sprites
  1178. */
  1179. spriteManagers: SpriteManager[];
  1180. /**
  1181. * The list of layers (background and foreground) of the scene
  1182. */
  1183. layers: Layer[];
  1184. /**
  1185. * The list of effect layers (highlights/glow) added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1187. * @see http://doc.babylonjs.com/how_to/glow_layer
  1188. */
  1189. effectLayers: EffectLayer[];
  1190. private _skeletonsEnabled;
  1191. /**
  1192. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1193. */
  1194. skeletonsEnabled: boolean;
  1195. /**
  1196. * The list of skeletons added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1198. */
  1199. skeletons: Skeleton[];
  1200. /**
  1201. * The list of morph target managers added to the scene
  1202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1203. */
  1204. morphTargetManagers: MorphTargetManager[];
  1205. /**
  1206. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1207. */
  1208. lensFlaresEnabled: boolean;
  1209. /**
  1210. * The list of lens flare system added to the scene
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1212. */
  1213. lensFlareSystems: LensFlareSystem[];
  1214. /**
  1215. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1217. */
  1218. collisionsEnabled: boolean;
  1219. private _workerCollisions;
  1220. /** @hidden */
  1221. collisionCoordinator: ICollisionCoordinator;
  1222. /**
  1223. * Defines the gravity applied to this scene (used only for collisions)
  1224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1225. */
  1226. gravity: Vector3;
  1227. /**
  1228. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1229. */
  1230. postProcessesEnabled: boolean;
  1231. /**
  1232. * The list of postprocesses added to the scene
  1233. */
  1234. postProcesses: PostProcess[];
  1235. /**
  1236. * Gets the current postprocess manager
  1237. */
  1238. postProcessManager: PostProcessManager;
  1239. private _postProcessRenderPipelineManager;
  1240. /**
  1241. * Gets the postprocess render pipeline manager
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1243. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1244. */
  1245. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * The list of reflection probes added to the scene
  1274. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1275. */
  1276. reflectionProbes: ReflectionProbe[];
  1277. /**
  1278. * @hidden
  1279. */
  1280. database: Database;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. /** @hidden */
  1287. _actionManagers: ActionManager[];
  1288. private _meshesForIntersections;
  1289. /**
  1290. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1291. */
  1292. proceduralTexturesEnabled: boolean;
  1293. /**
  1294. * The list of procedural textures added to the scene
  1295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1296. */
  1297. proceduralTextures: ProceduralTexture[];
  1298. private _mainSoundTrack;
  1299. /**
  1300. * The list of sound tracks added to the scene
  1301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1302. */
  1303. soundTracks: SoundTrack[];
  1304. private _audioEnabled;
  1305. private _headphone;
  1306. /**
  1307. * Gets the main soundtrack associated with the scene
  1308. */
  1309. readonly mainSoundTrack: SoundTrack;
  1310. /**
  1311. * Gets or sets the VRExperienceHelper attached to the scene
  1312. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1313. * @ignorenaming
  1314. */
  1315. VRHelper: VRExperienceHelper;
  1316. /**
  1317. * Gets or sets the simplification queue attached to the scene
  1318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1319. */
  1320. simplificationQueue: SimplificationQueue;
  1321. private _engine;
  1322. private _totalVertices;
  1323. /** @hidden */
  1324. _activeIndices: PerfCounter;
  1325. /** @hidden */
  1326. _activeParticles: PerfCounter;
  1327. /** @hidden */
  1328. _activeBones: PerfCounter;
  1329. private _animationRatio;
  1330. private _animationTimeLast;
  1331. private _animationTime;
  1332. /**
  1333. * Gets or sets a general scale for animation speed
  1334. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1335. */
  1336. animationTimeScale: number;
  1337. /** @hidden */
  1338. _cachedMaterial: Nullable<Material>;
  1339. /** @hidden */
  1340. _cachedEffect: Nullable<Effect>;
  1341. /** @hidden */
  1342. _cachedVisibility: Nullable<number>;
  1343. private _renderId;
  1344. private _executeWhenReadyTimeoutId;
  1345. private _intermediateRendering;
  1346. private _viewUpdateFlag;
  1347. private _projectionUpdateFlag;
  1348. private _alternateViewUpdateFlag;
  1349. private _alternateProjectionUpdateFlag;
  1350. /** @hidden */
  1351. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1352. private _activeRequests;
  1353. private _pendingData;
  1354. private _isDisposed;
  1355. /**
  1356. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1357. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1358. */
  1359. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1360. private _activeMeshes;
  1361. private _processedMaterials;
  1362. private _renderTargets;
  1363. /** @hidden */
  1364. _activeParticleSystems: SmartArray<IParticleSystem>;
  1365. private _activeSkeletons;
  1366. private _softwareSkinnedMeshes;
  1367. private _renderingManager;
  1368. private _physicsEngine;
  1369. /** @hidden */
  1370. _activeAnimatables: Animatable[];
  1371. private _transformMatrix;
  1372. private _sceneUbo;
  1373. private _alternateSceneUbo;
  1374. private _pickWithRayInverseMatrix;
  1375. private _boundingBoxRenderer;
  1376. private _outlineRenderer;
  1377. private _viewMatrix;
  1378. private _projectionMatrix;
  1379. private _alternateViewMatrix;
  1380. private _alternateProjectionMatrix;
  1381. private _alternateTransformMatrix;
  1382. private _useAlternateCameraConfiguration;
  1383. private _alternateRendering;
  1384. /** @hidden */
  1385. _forcedViewPosition: Nullable<Vector3>;
  1386. /** @hidden */
  1387. readonly _isAlternateRenderingEnabled: boolean;
  1388. private _frustumPlanes;
  1389. /**
  1390. * Gets the list of frustum planes (built from the active camera)
  1391. */
  1392. readonly frustumPlanes: Plane[];
  1393. /**
  1394. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1395. * This is useful if there are more lights that the maximum simulteanous authorized
  1396. */
  1397. requireLightSorting: boolean;
  1398. private _selectionOctree;
  1399. private _pointerOverMesh;
  1400. private _pointerOverSprite;
  1401. private _debugLayer;
  1402. private _depthRenderer;
  1403. private _geometryBufferRenderer;
  1404. /**
  1405. * Gets the current geometry buffer associated to the scene.
  1406. */
  1407. /**
  1408. * Sets the current geometry buffer for the scene.
  1409. */
  1410. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1411. private _pickedDownMesh;
  1412. private _pickedUpMesh;
  1413. private _pickedDownSprite;
  1414. private _externalData;
  1415. private _uid;
  1416. /**
  1417. * Creates a new Scene
  1418. * @param engine defines the engine to use to render this scene
  1419. */
  1420. constructor(engine: Engine);
  1421. /**
  1422. * Gets the debug layer (aka Inspector) associated with the scene
  1423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1424. */
  1425. readonly debugLayer: DebugLayer;
  1426. /**
  1427. * Gets a boolean indicating if collisions are processed on a web worker
  1428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1429. */
  1430. workerCollisions: boolean;
  1431. /**
  1432. * Gets the octree used to boost mesh selection (picking)
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1434. */
  1435. readonly selectionOctree: Octree<AbstractMesh>;
  1436. /**
  1437. * Gets the mesh that is currently under the pointer
  1438. */
  1439. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1440. /**
  1441. * Gets the current on-screen X position of the pointer
  1442. */
  1443. readonly pointerX: number;
  1444. /**
  1445. * Gets the current on-screen Y position of the pointer
  1446. */
  1447. readonly pointerY: number;
  1448. /**
  1449. * Gets the cached material (ie. the latest rendered one)
  1450. * @returns the cached material
  1451. */
  1452. getCachedMaterial(): Nullable<Material>;
  1453. /**
  1454. * Gets the cached effect (ie. the latest rendered one)
  1455. * @returns the cached effect
  1456. */
  1457. getCachedEffect(): Nullable<Effect>;
  1458. /**
  1459. * Gets the cached visibility state (ie. the latest rendered one)
  1460. * @returns the cached visibility state
  1461. */
  1462. getCachedVisibility(): Nullable<number>;
  1463. /**
  1464. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1465. * @param material defines the current material
  1466. * @param effect defines the current effect
  1467. * @param visibility defines the current visibility state
  1468. * @returns true if one parameter is not cached
  1469. */
  1470. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1471. /**
  1472. * Gets the bounding box renderer associated with the scene
  1473. * @returns a BoundingBoxRenderer
  1474. */
  1475. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1476. /**
  1477. * Gets the outline renderer associated with the scene
  1478. * @returns a OutlineRenderer
  1479. */
  1480. getOutlineRenderer(): OutlineRenderer;
  1481. /**
  1482. * Gets the engine associated with the scene
  1483. * @returns an Engine
  1484. */
  1485. getEngine(): Engine;
  1486. /**
  1487. * Gets the total number of vertices rendered per frame
  1488. * @returns the total number of vertices rendered per frame
  1489. */
  1490. getTotalVertices(): number;
  1491. /**
  1492. * Gets the performance counter for total vertices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalVerticesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1498. * @returns the total number of active indices rendered per frame
  1499. */
  1500. getActiveIndices(): number;
  1501. /**
  1502. * Gets the performance counter for active indices
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active particles rendered per frame
  1508. * @returns the total number of active particles rendered per frame
  1509. */
  1510. getActiveParticles(): number;
  1511. /**
  1512. * Gets the performance counter for active particles
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeParticlesPerfCounter: PerfCounter;
  1516. /**
  1517. * Gets the total number of active bones rendered per frame
  1518. * @returns the total number of active bones rendered per frame
  1519. */
  1520. getActiveBones(): number;
  1521. /**
  1522. * Gets the performance counter for active bones
  1523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1524. */
  1525. readonly activeBonesPerfCounter: PerfCounter;
  1526. /** @hidden */
  1527. getInterFramePerfCounter(): number;
  1528. /** @hidden */
  1529. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getLastFrameDuration(): number;
  1532. /** @hidden */
  1533. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1534. /** @hidden */
  1535. getEvaluateActiveMeshesDuration(): number;
  1536. /** @hidden */
  1537. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1538. /**
  1539. * Gets the array of active meshes
  1540. * @returns an array of AbstractMesh
  1541. */
  1542. getActiveMeshes(): SmartArray<AbstractMesh>;
  1543. /** @hidden */
  1544. getRenderTargetsDuration(): number;
  1545. /** @hidden */
  1546. getRenderDuration(): number;
  1547. /** @hidden */
  1548. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1549. /** @hidden */
  1550. getParticlesDuration(): number;
  1551. /** @hidden */
  1552. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1553. /** @hidden */
  1554. getSpritesDuration(): number;
  1555. /** @hidden */
  1556. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1557. /**
  1558. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1559. * @returns a number
  1560. */
  1561. getAnimationRatio(): number;
  1562. /**
  1563. * Gets an unique Id for the current frame
  1564. * @returns a number
  1565. */
  1566. getRenderId(): number;
  1567. /** Call this function if you want to manually increment the render Id*/
  1568. incrementRenderId(): void;
  1569. private _updatePointerPosition(evt);
  1570. private _createUbo();
  1571. private _createAlternateUbo();
  1572. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1573. private _setRayOnPointerInfo(pointerInfo);
  1574. /**
  1575. * Use this method to simulate a pointer move on a mesh
  1576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1579. * @returns the current scene
  1580. */
  1581. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerMove(pickResult, evt);
  1583. private _checkPrePointerObservable(pickResult, evt, type);
  1584. /**
  1585. * Use this method to simulate a pointer down on a mesh
  1586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1589. * @returns the current scene
  1590. */
  1591. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1592. private _processPointerDown(pickResult, evt);
  1593. /**
  1594. * Use this method to simulate a pointer up on a mesh
  1595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1598. * @returns the current scene
  1599. */
  1600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1601. private _processPointerUp(pickResult, evt, clickInfo);
  1602. /**
  1603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1605. * @returns true if the pointer was captured
  1606. */
  1607. isPointerCaptured(pointerId?: number): boolean;
  1608. /**
  1609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1610. * @param attachUp defines if you want to attach events to pointerup
  1611. * @param attachDown defines if you want to attach events to pointerdown
  1612. * @param attachMove defines if you want to attach events to pointermove
  1613. */
  1614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1615. /** Detaches all event handlers*/
  1616. detachControl(): void;
  1617. /**
  1618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1619. * Delay loaded resources are not taking in account
  1620. * @return true if all required resources are ready
  1621. */
  1622. isReady(): boolean;
  1623. /** Resets all cached information relative to material (including effect and visibility) */
  1624. resetCachedMaterial(): void;
  1625. /**
  1626. * Registers a function to be called before every frame render
  1627. * @param func defines the function to register
  1628. */
  1629. registerBeforeRender(func: () => void): void;
  1630. /**
  1631. * Unregisters a function called before every frame render
  1632. * @param func defines the function to unregister
  1633. */
  1634. unregisterBeforeRender(func: () => void): void;
  1635. /**
  1636. * Registers a function to be called after every frame render
  1637. * @param func defines the function to register
  1638. */
  1639. registerAfterRender(func: () => void): void;
  1640. /**
  1641. * Unregisters a function called after every frame render
  1642. * @param func defines the function to unregister
  1643. */
  1644. unregisterAfterRender(func: () => void): void;
  1645. private _executeOnceBeforeRender(func);
  1646. /**
  1647. * The provided function will run before render once and will be disposed afterwards.
  1648. * A timeout delay can be provided so that the function will be executed in N ms.
  1649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1650. * @param func The function to be executed.
  1651. * @param timeout optional delay in ms
  1652. */
  1653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1654. /** @hidden */
  1655. _addPendingData(data: any): void;
  1656. /** @hidden */
  1657. _removePendingData(data: any): void;
  1658. /**
  1659. * Returns the number of items waiting to be loaded
  1660. * @returns the number of items waiting to be loaded
  1661. */
  1662. getWaitingItemsCount(): number;
  1663. /**
  1664. * Returns a boolean indicating if the scene is still loading data
  1665. */
  1666. readonly isLoading: boolean;
  1667. /**
  1668. * Registers a function to be executed when the scene is ready
  1669. * @param {Function} func - the function to be executed
  1670. */
  1671. executeWhenReady(func: () => void): void;
  1672. /**
  1673. * Returns a promise that resolves when the scene is ready
  1674. * @returns A promise that resolves when the scene is ready
  1675. */
  1676. whenReadyAsync(): Promise<void>;
  1677. /** @hidden */
  1678. _checkIsReady(): void;
  1679. /**
  1680. * Will start the animation sequence of a given target
  1681. * @param target defines the target
  1682. * @param from defines from which frame should animation start
  1683. * @param to defines until which frame should animation run.
  1684. * @param weight defines the weight to apply to the animation (1.0 by default)
  1685. * @param loop defines if the animation loops
  1686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1687. * @param onAnimationEnd defines the function to be executed when the animation ends
  1688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1689. * @returns the animatable object created for this animation
  1690. */
  1691. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1692. /**
  1693. * Will start the animation sequence of a given target
  1694. * @param target defines the target
  1695. * @param from defines from which frame should animation start
  1696. * @param to defines until which frame should animation run.
  1697. * @param loop defines if the animation loops
  1698. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1699. * @param onAnimationEnd defines the function to be executed when the animation ends
  1700. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1701. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1702. * @returns the animatable object created for this animation
  1703. */
  1704. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1705. /**
  1706. * Begin a new animation on a given node
  1707. * @param target defines the target where the animation will take place
  1708. * @param animations defines the list of animations to start
  1709. * @param from defines the initial value
  1710. * @param to defines the final value
  1711. * @param loop defines if you want animation to loop (off by default)
  1712. * @param speedRatio defines the speed ratio to apply to all animations
  1713. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1714. * @returns the list of created animatables
  1715. */
  1716. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1717. /**
  1718. * Begin a new animation on a given node and its hierarchy
  1719. * @param target defines the root node where the animation will take place
  1720. * @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.
  1721. * @param animations defines the list of animations to start
  1722. * @param from defines the initial value
  1723. * @param to defines the final value
  1724. * @param loop defines if you want animation to loop (off by default)
  1725. * @param speedRatio defines the speed ratio to apply to all animations
  1726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1727. * @returns the list of animatables created for all nodes
  1728. */
  1729. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1730. /**
  1731. * Gets the animatable associated with a specific target
  1732. * @param target defines the target of the animatable
  1733. * @returns the required animatable if found
  1734. */
  1735. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1736. /**
  1737. * Gets all animatables associated with a given target
  1738. * @param target defines the target to look animatables for
  1739. * @returns an array of Animatables
  1740. */
  1741. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1742. /**
  1743. * Gets all animatable attached to the scene
  1744. */
  1745. readonly animatables: Animatable[];
  1746. /**
  1747. * Will stop the animation of the given target
  1748. * @param target - the target
  1749. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1750. */
  1751. stopAnimation(target: any, animationName?: string): void;
  1752. /**
  1753. * Stops and removes all animations that have been applied to the scene
  1754. */
  1755. stopAllAnimations(): void;
  1756. private _animate();
  1757. /** @hidden */
  1758. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1759. private _processLateAnimationBindingsForMatrices(holder);
  1760. private _processLateAnimationBindingsForQuaternions(holder);
  1761. private _processLateAnimationBindings();
  1762. /** @hidden */
  1763. _switchToAlternateCameraConfiguration(active: boolean): void;
  1764. /**
  1765. * Gets the current view matrix
  1766. * @returns a Matrix
  1767. */
  1768. getViewMatrix(): Matrix;
  1769. /**
  1770. * Gets the current projection matrix
  1771. * @returns a Matrix
  1772. */
  1773. getProjectionMatrix(): Matrix;
  1774. /**
  1775. * Gets the current transform matrix
  1776. * @returns a Matrix made of View * Projection
  1777. */
  1778. getTransformMatrix(): Matrix;
  1779. /**
  1780. * Sets the current transform matrix
  1781. * @param view defines the View matrix to use
  1782. * @param projection defines the Projection matrix to use
  1783. */
  1784. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1785. /** @hidden */
  1786. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1787. /**
  1788. * Gets the uniform buffer used to store scene data
  1789. * @returns a UniformBuffer
  1790. */
  1791. getSceneUniformBuffer(): UniformBuffer;
  1792. /**
  1793. * Gets an unique (relatively to the current scene) Id
  1794. * @returns an unique number for the scene
  1795. */
  1796. getUniqueId(): number;
  1797. /**
  1798. * Add a mesh to the list of scene's meshes
  1799. * @param newMesh defines the mesh to add
  1800. * @param recursive if all child meshes should also be added to the scene
  1801. */
  1802. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1803. /**
  1804. * Remove a mesh for the list of scene's meshes
  1805. * @param toRemove defines the mesh to remove
  1806. * @param recursive if all child meshes should also be removed from the scene
  1807. * @returns the index where the mesh was in the mesh list
  1808. */
  1809. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1810. /**
  1811. * Add a transform node to the list of scene's transform nodes
  1812. * @param newTransformNode defines the transform node to add
  1813. */
  1814. addTransformNode(newTransformNode: TransformNode): void;
  1815. /**
  1816. * Remove a transform node for the list of scene's transform nodes
  1817. * @param toRemove defines the transform node to remove
  1818. * @returns the index where the transform node was in the transform node list
  1819. */
  1820. removeTransformNode(toRemove: TransformNode): number;
  1821. /**
  1822. * Remove a skeleton for the list of scene's skeletons
  1823. * @param toRemove defines the skeleton to remove
  1824. * @returns the index where the skeleton was in the skeleton list
  1825. */
  1826. removeSkeleton(toRemove: Skeleton): number;
  1827. /**
  1828. * Remove a morph target for the list of scene's morph targets
  1829. * @param toRemove defines the morph target to remove
  1830. * @returns the index where the morph target was in the morph target list
  1831. */
  1832. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1833. /**
  1834. * Remove a light for the list of scene's lights
  1835. * @param toRemove defines the light to remove
  1836. * @returns the index where the light was in the light list
  1837. */
  1838. removeLight(toRemove: Light): number;
  1839. /**
  1840. * Remove a camera for the list of scene's cameras
  1841. * @param toRemove defines the camera to remove
  1842. * @returns the index where the camera was in the camera list
  1843. */
  1844. removeCamera(toRemove: Camera): number;
  1845. /**
  1846. * Remove a particle system for the list of scene's particle systems
  1847. * @param toRemove defines the particle system to remove
  1848. * @returns the index where the particle system was in the particle system list
  1849. */
  1850. removeParticleSystem(toRemove: IParticleSystem): number;
  1851. /**
  1852. * Remove a animation for the list of scene's animations
  1853. * @param toRemove defines the animation to remove
  1854. * @returns the index where the animation was in the animation list
  1855. */
  1856. removeAnimation(toRemove: Animation): number;
  1857. /**
  1858. * Removes the given animation group from this scene.
  1859. * @param toRemove The animation group to remove
  1860. * @returns The index of the removed animation group
  1861. */
  1862. removeAnimationGroup(toRemove: AnimationGroup): number;
  1863. /**
  1864. * Removes the given multi-material from this scene.
  1865. * @param toRemove The multi-material to remove
  1866. * @returns The index of the removed multi-material
  1867. */
  1868. removeMultiMaterial(toRemove: MultiMaterial): number;
  1869. /**
  1870. * Removes the given material from this scene.
  1871. * @param toRemove The material to remove
  1872. * @returns The index of the removed material
  1873. */
  1874. removeMaterial(toRemove: Material): number;
  1875. /**
  1876. * Removes the given lens flare system from this scene.
  1877. * @param toRemove The lens flare system to remove
  1878. * @returns The index of the removed lens flare system
  1879. */
  1880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1881. /**
  1882. * Removes the given action manager from this scene.
  1883. * @param toRemove The action manager to remove
  1884. * @returns The index of the removed action manager
  1885. */
  1886. removeActionManager(toRemove: ActionManager): number;
  1887. /**
  1888. * Removes the given effect layer from this scene.
  1889. * @param toRemove defines the effect layer to remove
  1890. * @returns the index of the removed effect layer
  1891. */
  1892. removeEffectLayer(toRemove: EffectLayer): number;
  1893. /**
  1894. * Removes the given texture from this scene.
  1895. * @param toRemove The texture to remove
  1896. * @returns The index of the removed texture
  1897. */
  1898. removeTexture(toRemove: BaseTexture): number;
  1899. /**
  1900. * Adds the given light to this scene
  1901. * @param newLight The light to add
  1902. */
  1903. addLight(newLight: Light): void;
  1904. /**
  1905. * Sorts the list list based on light priorities
  1906. */
  1907. sortLightsByPriority(): void;
  1908. /**
  1909. * Adds the given camera to this scene
  1910. * @param newCamera The camera to add
  1911. */
  1912. addCamera(newCamera: Camera): void;
  1913. /**
  1914. * Adds the given skeleton to this scene
  1915. * @param newSkeleton The skeleton to add
  1916. */
  1917. addSkeleton(newSkeleton: Skeleton): void;
  1918. /**
  1919. * Adds the given particle system to this scene
  1920. * @param newParticleSystem The particle system to add
  1921. */
  1922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1923. /**
  1924. * Adds the given animation to this scene
  1925. * @param newAnimation The animation to add
  1926. */
  1927. addAnimation(newAnimation: Animation): void;
  1928. /**
  1929. * Adds the given animation group to this scene.
  1930. * @param newAnimationGroup The animation group to add
  1931. */
  1932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1933. /**
  1934. * Adds the given multi-material to this scene
  1935. * @param newMultiMaterial The multi-material to add
  1936. */
  1937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1938. /**
  1939. * Adds the given material to this scene
  1940. * @param newMaterial The material to add
  1941. */
  1942. addMaterial(newMaterial: Material): void;
  1943. /**
  1944. * Adds the given morph target to this scene
  1945. * @param newMorphTargetManager The morph target to add
  1946. */
  1947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1948. /**
  1949. * Adds the given geometry to this scene
  1950. * @param newGeometry The geometry to add
  1951. */
  1952. addGeometry(newGeometry: Geometry): void;
  1953. /**
  1954. * Adds the given lens flare system to this scene
  1955. * @param newLensFlareSystem The lens flare system to add
  1956. */
  1957. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1958. /**
  1959. * Adds the given effect layer to this scene
  1960. * @param newEffectLayer defines the effect layer to add
  1961. */
  1962. addEffectLayer(newEffectLayer: EffectLayer): void;
  1963. /**
  1964. * Adds the given action manager to this scene
  1965. * @param newActionManager The action manager to add
  1966. */
  1967. addActionManager(newActionManager: ActionManager): void;
  1968. /**
  1969. * Adds the given texture to this scene.
  1970. * @param newTexture The texture to add
  1971. */
  1972. addTexture(newTexture: BaseTexture): void;
  1973. /**
  1974. * Switch active camera
  1975. * @param newCamera defines the new active camera
  1976. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1977. */
  1978. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1979. /**
  1980. * sets the active camera of the scene using its ID
  1981. * @param id defines the camera's ID
  1982. * @return the new active camera or null if none found.
  1983. */
  1984. setActiveCameraByID(id: string): Nullable<Camera>;
  1985. /**
  1986. * sets the active camera of the scene using its name
  1987. * @param name defines the camera's name
  1988. * @returns the new active camera or null if none found.
  1989. */
  1990. setActiveCameraByName(name: string): Nullable<Camera>;
  1991. /**
  1992. * get an animation group using its name
  1993. * @param name defines the material's name
  1994. * @return the animation group or null if none found.
  1995. */
  1996. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1997. /**
  1998. * get a material using its id
  1999. * @param id defines the material's ID
  2000. * @return the material or null if none found.
  2001. */
  2002. getMaterialByID(id: string): Nullable<Material>;
  2003. /**
  2004. * Gets a material using its name
  2005. * @param name defines the material's name
  2006. * @return the material or null if none found.
  2007. */
  2008. getMaterialByName(name: string): Nullable<Material>;
  2009. /**
  2010. * Gets a lens flare system using its name
  2011. * @param name defines the name to look for
  2012. * @returns the lens flare system or null if not found
  2013. */
  2014. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2015. /**
  2016. * Gets a lens flare system using its id
  2017. * @param id defines the id to look for
  2018. * @returns the lens flare system or null if not found
  2019. */
  2020. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2021. /**
  2022. * Gets a camera using its id
  2023. * @param id defines the id to look for
  2024. * @returns the camera or null if not found
  2025. */
  2026. getCameraByID(id: string): Nullable<Camera>;
  2027. /**
  2028. * Gets a camera using its unique id
  2029. * @param uniqueId defines the unique id to look for
  2030. * @returns the camera or null if not found
  2031. */
  2032. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2033. /**
  2034. * Gets a camera using its name
  2035. * @param name defines the camera's name
  2036. * @return the camera or null if none found.
  2037. */
  2038. getCameraByName(name: string): Nullable<Camera>;
  2039. /**
  2040. * Gets a bone using its id
  2041. * @param id defines the bone's id
  2042. * @return the bone or null if not found
  2043. */
  2044. getBoneByID(id: string): Nullable<Bone>;
  2045. /**
  2046. * Gets a bone using its id
  2047. * @param name defines the bone's name
  2048. * @return the bone or null if not found
  2049. */
  2050. getBoneByName(name: string): Nullable<Bone>;
  2051. /**
  2052. * Gets a light node using its name
  2053. * @param name defines the the light's name
  2054. * @return the light or null if none found.
  2055. */
  2056. getLightByName(name: string): Nullable<Light>;
  2057. /**
  2058. * Gets a light node using its id
  2059. * @param id defines the light's id
  2060. * @return the light or null if none found.
  2061. */
  2062. getLightByID(id: string): Nullable<Light>;
  2063. /**
  2064. * Gets a light node using its scene-generated unique ID
  2065. * @param uniqueId defines the light's unique id
  2066. * @return the light or null if none found.
  2067. */
  2068. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2069. /**
  2070. * Gets a particle system by id
  2071. * @param id defines the particle system id
  2072. * @return the corresponding system or null if none found
  2073. */
  2074. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2075. /**
  2076. * Gets a geometry using its ID
  2077. * @param id defines the geometry's id
  2078. * @return the geometry or null if none found.
  2079. */
  2080. getGeometryByID(id: string): Nullable<Geometry>;
  2081. /**
  2082. * Add a new geometry to this scene
  2083. * @param geometry defines the geometry to be added to the scene.
  2084. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2085. * @return a boolean defining if the geometry was added or not
  2086. */
  2087. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2088. /**
  2089. * Removes an existing geometry
  2090. * @param geometry defines the geometry to be removed from the scene
  2091. * @return a boolean defining if the geometry was removed or not
  2092. */
  2093. removeGeometry(geometry: Geometry): boolean;
  2094. /**
  2095. * Gets the list of geometries attached to the scene
  2096. * @returns an array of Geometry
  2097. */
  2098. getGeometries(): Geometry[];
  2099. /**
  2100. * Gets the first added mesh found of a given ID
  2101. * @param id defines the id to search for
  2102. * @return the mesh found or null if not found at all
  2103. */
  2104. getMeshByID(id: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a list of meshes using their id
  2107. * @param id defines the id to search for
  2108. * @returns a list of meshes
  2109. */
  2110. getMeshesByID(id: string): Array<AbstractMesh>;
  2111. /**
  2112. * Gets the first added transform node found of a given ID
  2113. * @param id defines the id to search for
  2114. * @return the found transform node or null if not found at all.
  2115. */
  2116. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2117. /**
  2118. * Gets a list of transform nodes using their id
  2119. * @param id defines the id to search for
  2120. * @returns a list of transform nodes
  2121. */
  2122. getTransformNodesByID(id: string): Array<TransformNode>;
  2123. /**
  2124. * Gets a mesh with its auto-generated unique id
  2125. * @param uniqueId defines the unique id to search for
  2126. * @return the found mesh or null if not found at all.
  2127. */
  2128. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2129. /**
  2130. * Gets a the last added mesh using a given id
  2131. * @param id defines the id to search for
  2132. * @return the found mesh or null if not found at all.
  2133. */
  2134. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2135. /**
  2136. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2137. * @param id defines the id to search for
  2138. * @return the found node or null if not found at all
  2139. */
  2140. getLastEntryByID(id: string): Nullable<Node>;
  2141. /**
  2142. * Gets a node (Mesh, Camera, Light) using a given id
  2143. * @param id defines the id to search for
  2144. * @return the found node or null if not found at all
  2145. */
  2146. getNodeByID(id: string): Nullable<Node>;
  2147. /**
  2148. * Gets a node (Mesh, Camera, Light) using a given name
  2149. * @param name defines the name to search for
  2150. * @return the found node or null if not found at all.
  2151. */
  2152. getNodeByName(name: string): Nullable<Node>;
  2153. /**
  2154. * Gets a mesh using a given name
  2155. * @param name defines the name to search for
  2156. * @return the found mesh or null if not found at all.
  2157. */
  2158. getMeshByName(name: string): Nullable<AbstractMesh>;
  2159. /**
  2160. * Gets a transform node using a given name
  2161. * @param name defines the name to search for
  2162. * @return the found transform node or null if not found at all.
  2163. */
  2164. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2165. /**
  2166. * Gets a sound using a given name
  2167. * @param name defines the name to search for
  2168. * @return the found sound or null if not found at all.
  2169. */
  2170. getSoundByName(name: string): Nullable<Sound>;
  2171. /**
  2172. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2173. * @param id defines the id to search for
  2174. * @return the found skeleton or null if not found at all.
  2175. */
  2176. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2177. /**
  2178. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2179. * @param id defines the id to search for
  2180. * @return the found skeleton or null if not found at all.
  2181. */
  2182. getSkeletonById(id: string): Nullable<Skeleton>;
  2183. /**
  2184. * Gets a skeleton using a given name
  2185. * @param name defines the name to search for
  2186. * @return the found skeleton or null if not found at all.
  2187. */
  2188. getSkeletonByName(name: string): Nullable<Skeleton>;
  2189. /**
  2190. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2191. * @param id defines the id to search for
  2192. * @return the found morph target manager or null if not found at all.
  2193. */
  2194. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2195. /**
  2196. * Gets a boolean indicating if the given mesh is active
  2197. * @param mesh defines the mesh to look for
  2198. * @returns true if the mesh is in the active list
  2199. */
  2200. isActiveMesh(mesh: AbstractMesh): boolean;
  2201. /**
  2202. * Return a the first highlight layer of the scene with a given name.
  2203. * @param name The name of the highlight layer to look for.
  2204. * @return The highlight layer if found otherwise null.
  2205. */
  2206. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2207. /**
  2208. * Return a the first highlight layer of the scene with a given name.
  2209. * @param name The name of the highlight layer to look for.
  2210. * @return The highlight layer if found otherwise null.
  2211. */
  2212. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2213. /**
  2214. * Return a unique id as a string which can serve as an identifier for the scene
  2215. */
  2216. readonly uid: string;
  2217. /**
  2218. * Add an externaly attached data from its key.
  2219. * This method call will fail and return false, if such key already exists.
  2220. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2221. * @param key the unique key that identifies the data
  2222. * @param data the data object to associate to the key for this Engine instance
  2223. * @return true if no such key were already present and the data was added successfully, false otherwise
  2224. */
  2225. addExternalData<T>(key: string, data: T): boolean;
  2226. /**
  2227. * Get an externaly attached data from its key
  2228. * @param key the unique key that identifies the data
  2229. * @return the associated data, if present (can be null), or undefined if not present
  2230. */
  2231. getExternalData<T>(key: string): Nullable<T>;
  2232. /**
  2233. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2234. * @param key the unique key that identifies the data
  2235. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2236. * @return the associated data, can be null if the factory returned null.
  2237. */
  2238. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2239. /**
  2240. * Remove an externaly attached data from the Engine instance
  2241. * @param key the unique key that identifies the data
  2242. * @return true if the data was successfully removed, false if it doesn't exist
  2243. */
  2244. removeExternalData(key: string): boolean;
  2245. private _evaluateSubMesh(subMesh, mesh);
  2246. /**
  2247. * Clear the processed materials smart array preventing retention point in material dispose.
  2248. */
  2249. freeProcessedMaterials(): void;
  2250. /**
  2251. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2252. */
  2253. freeActiveMeshes(): void;
  2254. /**
  2255. * Clear the info related to rendering groups preventing retention points during dispose.
  2256. */
  2257. freeRenderingGroups(): void;
  2258. /** @hidden */
  2259. _isInIntermediateRendering(): boolean;
  2260. private _activeMeshCandidateProvider;
  2261. /**
  2262. * Defines the current active mesh candidate provider
  2263. * @param provider defines the provider to use
  2264. */
  2265. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2266. /**
  2267. * Gets the current active mesh candidate provider
  2268. * @returns the current active mesh candidate provider
  2269. */
  2270. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2271. private _activeMeshesFrozen;
  2272. /**
  2273. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2274. * @returns the current scene
  2275. */
  2276. freezeActiveMeshes(): Scene;
  2277. /**
  2278. * Use this function to restart evaluating active meshes on every frame
  2279. * @returns the current scene
  2280. */
  2281. unfreezeActiveMeshes(): Scene;
  2282. private _evaluateActiveMeshes();
  2283. private _activeMesh(sourceMesh, mesh);
  2284. /**
  2285. * Update the transform matrix to update from the current active camera
  2286. * @param force defines a boolean used to force the update even if cache is up to date
  2287. */
  2288. updateTransformMatrix(force?: boolean): void;
  2289. /**
  2290. * 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)
  2291. * @param alternateCamera defines the camera to use
  2292. */
  2293. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2294. private _renderForCamera(camera, rigParent?);
  2295. private _processSubCameras(camera);
  2296. private _checkIntersections();
  2297. /**
  2298. * Render the scene
  2299. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2300. */
  2301. render(updateCameras?: boolean): void;
  2302. private _updateAudioParameters();
  2303. /**
  2304. * Gets or sets if audio support is enabled
  2305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2306. */
  2307. audioEnabled: boolean;
  2308. private _disableAudio();
  2309. private _enableAudio();
  2310. /**
  2311. * Gets or sets if audio will be output to headphones
  2312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2313. */
  2314. headphone: boolean;
  2315. private _switchAudioModeForHeadphones();
  2316. private _switchAudioModeForNormalSpeakers();
  2317. /**
  2318. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2319. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2320. * @returns the created depth renderer
  2321. */
  2322. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2323. /**
  2324. * Disables a depth renderer for a given camera
  2325. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2326. */
  2327. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2328. /**
  2329. * Enables a GeometryBufferRender and associates it with the scene
  2330. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2331. * @returns the GeometryBufferRenderer
  2332. */
  2333. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2334. /**
  2335. * Disables the GeometryBufferRender associated with the scene
  2336. */
  2337. disableGeometryBufferRenderer(): void;
  2338. /**
  2339. * Freeze all materials
  2340. * A frozen material will not be updatable but should be faster to render
  2341. */
  2342. freezeMaterials(): void;
  2343. /**
  2344. * Unfreeze all materials
  2345. * A frozen material will not be updatable but should be faster to render
  2346. */
  2347. unfreezeMaterials(): void;
  2348. /**
  2349. * Releases all held ressources
  2350. */
  2351. dispose(): void;
  2352. /**
  2353. * Gets if the scene is already disposed
  2354. */
  2355. readonly isDisposed: boolean;
  2356. /**
  2357. * Releases sounds & soundtracks
  2358. */
  2359. disposeSounds(): void;
  2360. /**
  2361. * Call this function to reduce memory footprint of the scene.
  2362. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2363. */
  2364. clearCachedVertexData(): void;
  2365. /**
  2366. * This function will remove the local cached buffer data from texture.
  2367. * It will save memory but will prevent the texture from being rebuilt
  2368. */
  2369. cleanCachedTextureBuffer(): void;
  2370. /**
  2371. * Get the world extend vectors with an optional filter
  2372. *
  2373. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2374. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2375. */
  2376. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2377. min: Vector3;
  2378. max: Vector3;
  2379. };
  2380. /**
  2381. * Creates or updates the octree used to boost selection (picking)
  2382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2383. * @param maxCapacity defines the maximum capacity per leaf
  2384. * @param maxDepth defines the maximum depth of the octree
  2385. * @returns an octree of AbstractMesh
  2386. */
  2387. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2388. /**
  2389. * Creates a ray that can be used to pick in the scene
  2390. * @param x defines the x coordinate of the origin (on-screen)
  2391. * @param y defines the y coordinate of the origin (on-screen)
  2392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2393. * @param camera defines the camera to use for the picking
  2394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2395. * @returns a Ray
  2396. */
  2397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2398. /**
  2399. * Creates a ray that can be used to pick in the scene
  2400. * @param x defines the x coordinate of the origin (on-screen)
  2401. * @param y defines the y coordinate of the origin (on-screen)
  2402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2403. * @param result defines the ray where to store the picking ray
  2404. * @param camera defines the camera to use for the picking
  2405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2406. * @returns the current scene
  2407. */
  2408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2409. /**
  2410. * Creates a ray that can be used to pick in the scene
  2411. * @param x defines the x coordinate of the origin (on-screen)
  2412. * @param y defines the y coordinate of the origin (on-screen)
  2413. * @param camera defines the camera to use for the picking
  2414. * @returns a Ray
  2415. */
  2416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2417. /**
  2418. * Creates a ray that can be used to pick in the scene
  2419. * @param x defines the x coordinate of the origin (on-screen)
  2420. * @param y defines the y coordinate of the origin (on-screen)
  2421. * @param result defines the ray where to store the picking ray
  2422. * @param camera defines the camera to use for the picking
  2423. * @returns the current scene
  2424. */
  2425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2426. private _internalPick(rayFunction, predicate?, fastCheck?);
  2427. private _internalMultiPick(rayFunction, predicate?);
  2428. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2429. private _tempPickingRay;
  2430. /** Launch a ray to try to pick a mesh in the scene
  2431. * @param x position on screen
  2432. * @param y position on screen
  2433. * @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
  2434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2435. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2436. * @returns a PickingInfo
  2437. */
  2438. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2439. /** Launch a ray to try to pick a sprite in the scene
  2440. * @param x position on screen
  2441. * @param y position on screen
  2442. * @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
  2443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2445. * @returns a PickingInfo
  2446. */
  2447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2448. private _cachedRayForTransform;
  2449. /** Use the given ray to pick a mesh in the scene
  2450. * @param ray The ray to use to pick meshes
  2451. * @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
  2452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2453. * @returns a PickingInfo
  2454. */
  2455. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2456. /**
  2457. * Launch a ray to try to pick a mesh in the scene
  2458. * @param x X position on screen
  2459. * @param y Y position on screen
  2460. * @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
  2461. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2462. * @returns an array of PickingInfo
  2463. */
  2464. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2465. /**
  2466. * Launch a ray to try to pick a mesh in the scene
  2467. * @param ray Ray to use
  2468. * @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
  2469. * @returns an array of PickingInfo
  2470. */
  2471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2472. /**
  2473. * Force the value of meshUnderPointer
  2474. * @param mesh defines the mesh to use
  2475. */
  2476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2477. /**
  2478. * Gets the mesh under the pointer
  2479. * @returns a Mesh or null if no mesh is under the pointer
  2480. */
  2481. getPointerOverMesh(): Nullable<AbstractMesh>;
  2482. /**
  2483. * Force the sprite under the pointer
  2484. * @param sprite defines the sprite to use
  2485. */
  2486. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2487. /**
  2488. * Gets the sprite under the pointer
  2489. * @returns a Sprite or null if no sprite is under the pointer
  2490. */
  2491. getPointerOverSprite(): Nullable<Sprite>;
  2492. /**
  2493. * Gets the current physics engine
  2494. * @returns a PhysicsEngine or null if none attached
  2495. */
  2496. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2497. /**
  2498. * Enables physics to the current scene
  2499. * @param gravity defines the scene's gravity for the physics engine
  2500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2501. * @return a boolean indicating if the physics engine was initialized
  2502. */
  2503. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2504. /**
  2505. * Disables and disposes the physics engine associated with the scene
  2506. */
  2507. disablePhysicsEngine(): void;
  2508. /**
  2509. * Gets a boolean indicating if there is an active physics engine
  2510. * @returns a boolean indicating if there is an active physics engine
  2511. */
  2512. isPhysicsEnabled(): boolean;
  2513. /**
  2514. * Deletes a physics compound impostor
  2515. * @param compound defines the compound to delete
  2516. */
  2517. deleteCompoundImpostor(compound: any): void;
  2518. /** @hidden */
  2519. _rebuildGeometries(): void;
  2520. /** @hidden */
  2521. _rebuildTextures(): void;
  2522. /**
  2523. * Creates a default light for the scene.
  2524. * @param replace Whether to replace the existing lights in the scene.
  2525. */
  2526. createDefaultLight(replace?: boolean): void;
  2527. /**
  2528. * Creates a default camera for the scene.
  2529. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2530. * @param replace Whether to replace the existing active camera in the scene.
  2531. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2532. */
  2533. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2534. /**
  2535. * Creates a default camera and a default light
  2536. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2537. * @param replace defines if the camera and/or light will replace the existing ones
  2538. * @param attachCameraControls defines if attachControl will be called on the new camera
  2539. */
  2540. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2541. /**
  2542. * Creates a new sky box
  2543. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2544. * @param environmentTexture defines the texture to use as environment texture
  2545. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2546. * @param scale defines the overall scale of the skybox
  2547. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2548. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2549. * @returns a new mesh holding the sky box
  2550. */
  2551. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2552. /**
  2553. * Creates a new environment
  2554. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2555. * @param options defines the options you can use to configure the environment
  2556. * @returns the new EnvironmentHelper
  2557. */
  2558. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2559. /**
  2560. * Creates a new VREXperienceHelper
  2561. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2562. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2563. * @returns a new VREXperienceHelper
  2564. */
  2565. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2566. private _getByTags(list, tagsQuery, forEach?);
  2567. /**
  2568. * Get a list of meshes by tags
  2569. * @param tagsQuery defines the tags query to use
  2570. * @param forEach defines a predicate used to filter results
  2571. * @returns an array of Mesh
  2572. */
  2573. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2574. /**
  2575. * Get a list of cameras by tags
  2576. * @param tagsQuery defines the tags query to use
  2577. * @param forEach defines a predicate used to filter results
  2578. * @returns an array of Camera
  2579. */
  2580. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2581. /**
  2582. * Get a list of lights by tags
  2583. * @param tagsQuery defines the tags query to use
  2584. * @param forEach defines a predicate used to filter results
  2585. * @returns an array of Light
  2586. */
  2587. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2588. /**
  2589. * Get a list of materials by tags
  2590. * @param tagsQuery defines the tags query to use
  2591. * @param forEach defines a predicate used to filter results
  2592. * @returns an array of Material
  2593. */
  2594. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2595. /**
  2596. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2597. * This allowed control for front to back rendering or reversly depending of the special needs.
  2598. *
  2599. * @param renderingGroupId The rendering group id corresponding to its index
  2600. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2601. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2602. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2603. */
  2604. 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;
  2605. /**
  2606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2607. *
  2608. * @param renderingGroupId The rendering group id corresponding to its index
  2609. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2610. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2611. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2612. */
  2613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2614. /**
  2615. * Will flag all materials as dirty to trigger new shader compilation
  2616. * @param flag defines the flag used to specify which material part must be marked as dirty
  2617. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2618. */
  2619. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2620. /** @hidden */
  2621. _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;
  2622. /** @hidden */
  2623. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2624. }
  2625. }
  2626. declare module BABYLON {
  2627. type Nullable<T> = T | null;
  2628. type float = number;
  2629. type double = number;
  2630. type int = number;
  2631. type FloatArray = number[] | Float32Array;
  2632. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2633. /**
  2634. * Alias for types that can be used by a Buffer or VertexBuffer.
  2635. */
  2636. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2637. }
  2638. declare module BABYLON {
  2639. /**
  2640. * The action to be carried out following a trigger
  2641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2642. */
  2643. class Action {
  2644. /** the trigger, with or without parameters, for the action */
  2645. triggerOptions: any;
  2646. /**
  2647. * Trigger for the action
  2648. */
  2649. trigger: number;
  2650. /**
  2651. * Internal only - manager for action
  2652. * @hidden
  2653. */
  2654. _actionManager: ActionManager;
  2655. private _nextActiveAction;
  2656. private _child;
  2657. private _condition?;
  2658. private _triggerParameter;
  2659. /**
  2660. * An event triggered prior to action being executed.
  2661. */
  2662. onBeforeExecuteObservable: Observable<Action>;
  2663. /**
  2664. * Creates a new Action
  2665. * @param triggerOptions the trigger, with or without parameters, for the action
  2666. * @param condition an optional determinant of action
  2667. */
  2668. constructor(
  2669. /** the trigger, with or without parameters, for the action */
  2670. triggerOptions: any, condition?: Condition);
  2671. /**
  2672. * Internal only
  2673. * @hidden
  2674. */
  2675. _prepare(): void;
  2676. /**
  2677. * Gets the trigger parameters
  2678. * @returns the trigger parameters
  2679. */
  2680. getTriggerParameter(): any;
  2681. /**
  2682. * Internal only - executes current action event
  2683. * @hidden
  2684. */
  2685. _executeCurrent(evt?: ActionEvent): void;
  2686. /**
  2687. * Execute placeholder for child classes
  2688. * @param evt optional action event
  2689. */
  2690. execute(evt?: ActionEvent): void;
  2691. /**
  2692. * Skips to next active action
  2693. */
  2694. skipToNextActiveAction(): void;
  2695. /**
  2696. * Adds action to chain of actions, may be a DoNothingAction
  2697. * @param action defines the next action to execute
  2698. * @returns The action passed in
  2699. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2700. */
  2701. then(action: Action): Action;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getProperty(propertyPath: string): string;
  2707. /**
  2708. * Internal only
  2709. * @hidden
  2710. */
  2711. _getEffectiveTarget(target: any, propertyPath: string): any;
  2712. /**
  2713. * Serialize placeholder for child classes
  2714. * @param parent of child
  2715. * @returns the serialized object
  2716. */
  2717. serialize(parent: any): any;
  2718. /**
  2719. * Internal only called by serialize
  2720. * @hidden
  2721. */
  2722. protected _serialize(serializedAction: any, parent?: any): any;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _SerializeValueAsString: (value: any) => string;
  2728. /**
  2729. * Internal only
  2730. * @hidden
  2731. */
  2732. static _GetTargetProperty: (target: Scene | Node) => {
  2733. name: string;
  2734. targetType: string;
  2735. value: string;
  2736. };
  2737. }
  2738. }
  2739. declare module BABYLON {
  2740. /**
  2741. * ActionEvent is the event being sent when an action is triggered.
  2742. */
  2743. class ActionEvent {
  2744. /** The mesh or sprite that triggered the action */
  2745. source: any;
  2746. /** The X mouse cursor position at the time of the event */
  2747. pointerX: number;
  2748. /** The Y mouse cursor position at the time of the event */
  2749. pointerY: number;
  2750. /** The mesh that is currently pointed at (can be null) */
  2751. meshUnderPointer: Nullable<AbstractMesh>;
  2752. /** the original (browser) event that triggered the ActionEvent */
  2753. sourceEvent: any;
  2754. /** additional data for the event */
  2755. additionalData: any;
  2756. /**
  2757. * Creates a new ActionEvent
  2758. * @param source The mesh or sprite that triggered the action
  2759. * @param pointerX The X mouse cursor position at the time of the event
  2760. * @param pointerY The Y mouse cursor position at the time of the event
  2761. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2762. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2763. * @param additionalData additional data for the event
  2764. */
  2765. constructor(
  2766. /** The mesh or sprite that triggered the action */
  2767. source: any,
  2768. /** The X mouse cursor position at the time of the event */
  2769. pointerX: number,
  2770. /** The Y mouse cursor position at the time of the event */
  2771. pointerY: number,
  2772. /** The mesh that is currently pointed at (can be null) */
  2773. meshUnderPointer: Nullable<AbstractMesh>,
  2774. /** the original (browser) event that triggered the ActionEvent */
  2775. sourceEvent?: any,
  2776. /** additional data for the event */
  2777. additionalData?: any);
  2778. /**
  2779. * Helper function to auto-create an ActionEvent from a source mesh.
  2780. * @param source The source mesh that triggered the event
  2781. * @param evt The original (browser) event
  2782. * @param additionalData additional data for the event
  2783. * @returns the new ActionEvent
  2784. */
  2785. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2786. /**
  2787. * Helper function to auto-create an ActionEvent from a source sprite
  2788. * @param source The source sprite that triggered the event
  2789. * @param scene Scene associated with the sprite
  2790. * @param evt The original (browser) event
  2791. * @param additionalData additional data for the event
  2792. * @returns the new ActionEvent
  2793. */
  2794. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2795. /**
  2796. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2797. * @param scene the scene where the event occurred
  2798. * @param evt The original (browser) event
  2799. * @returns the new ActionEvent
  2800. */
  2801. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2802. /**
  2803. * Helper function to auto-create an ActionEvent from a primitive
  2804. * @param prim defines the target primitive
  2805. * @param pointerPos defines the pointer position
  2806. * @param evt The original (browser) event
  2807. * @param additionalData additional data for the event
  2808. * @returns the new ActionEvent
  2809. */
  2810. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2811. }
  2812. /**
  2813. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2814. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2816. */
  2817. class ActionManager {
  2818. private static _NothingTrigger;
  2819. private static _OnPickTrigger;
  2820. private static _OnLeftPickTrigger;
  2821. private static _OnRightPickTrigger;
  2822. private static _OnCenterPickTrigger;
  2823. private static _OnPickDownTrigger;
  2824. private static _OnDoublePickTrigger;
  2825. private static _OnPickUpTrigger;
  2826. private static _OnLongPressTrigger;
  2827. private static _OnPointerOverTrigger;
  2828. private static _OnPointerOutTrigger;
  2829. private static _OnEveryFrameTrigger;
  2830. private static _OnIntersectionEnterTrigger;
  2831. private static _OnIntersectionExitTrigger;
  2832. private static _OnKeyDownTrigger;
  2833. private static _OnKeyUpTrigger;
  2834. private static _OnPickOutTrigger;
  2835. /**
  2836. * Nothing
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly NothingTrigger: number;
  2840. /**
  2841. * On pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnPickTrigger: number;
  2845. /**
  2846. * On left pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnLeftPickTrigger: number;
  2850. /**
  2851. * On right pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnRightPickTrigger: number;
  2855. /**
  2856. * On center pick
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnCenterPickTrigger: number;
  2860. /**
  2861. * On pick down
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnPickDownTrigger: number;
  2865. /**
  2866. * On double pick
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnDoublePickTrigger: number;
  2870. /**
  2871. * On pick up
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickUpTrigger: number;
  2875. /**
  2876. * On pick out.
  2877. * This trigger will only be raised if you also declared a OnPickDown
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnPickOutTrigger: number;
  2881. /**
  2882. * On long press
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnLongPressTrigger: number;
  2886. /**
  2887. * On pointer over
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOverTrigger: number;
  2891. /**
  2892. * On pointer out
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnPointerOutTrigger: number;
  2896. /**
  2897. * On every frame
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnEveryFrameTrigger: number;
  2901. /**
  2902. * On intersection enter
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionEnterTrigger: number;
  2906. /**
  2907. * On intersection exit
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnIntersectionExitTrigger: number;
  2911. /**
  2912. * On key down
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyDownTrigger: number;
  2916. /**
  2917. * On key up
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnKeyUpTrigger: number;
  2921. /** Gets the list of active triggers */
  2922. static Triggers: {
  2923. [key: string]: number;
  2924. };
  2925. /** Gets the list of actions */
  2926. actions: Action[];
  2927. /** Gets the cursor to use when hovering items */
  2928. hoverCursor: string;
  2929. private _scene;
  2930. /**
  2931. * Creates a new action manager
  2932. * @param scene defines the hosting scene
  2933. */
  2934. constructor(scene: Scene);
  2935. /**
  2936. * Releases all associated resources
  2937. */
  2938. dispose(): void;
  2939. /**
  2940. * Gets hosting scene
  2941. * @returns the hosting scene
  2942. */
  2943. getScene(): Scene;
  2944. /**
  2945. * Does this action manager handles actions of any of the given triggers
  2946. * @param triggers defines the triggers to be tested
  2947. * @return a boolean indicating whether one (or more) of the triggers is handled
  2948. */
  2949. hasSpecificTriggers(triggers: number[]): boolean;
  2950. /**
  2951. * Does this action manager handles actions of a given trigger
  2952. * @param trigger defines the trigger to be tested
  2953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2954. * @return whether the trigger is handled
  2955. */
  2956. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2957. /**
  2958. * Does this action manager has pointer triggers
  2959. */
  2960. readonly hasPointerTriggers: boolean;
  2961. /**
  2962. * Does this action manager has pick triggers
  2963. */
  2964. readonly hasPickTriggers: boolean;
  2965. /**
  2966. * Does exist one action manager with at least one trigger
  2967. **/
  2968. static readonly HasTriggers: boolean;
  2969. /**
  2970. * Does exist one action manager with at least one pick trigger
  2971. **/
  2972. static readonly HasPickTriggers: boolean;
  2973. /**
  2974. * Does exist one action manager that handles actions of a given trigger
  2975. * @param trigger defines the trigger to be tested
  2976. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2977. **/
  2978. static HasSpecificTrigger(trigger: number): boolean;
  2979. /**
  2980. * Registers an action to this action manager
  2981. * @param action defines the action to be registered
  2982. * @return the action amended (prepared) after registration
  2983. */
  2984. registerAction(action: Action): Nullable<Action>;
  2985. /**
  2986. * Unregisters an action to this action manager
  2987. * @param action defines the action to be unregistered
  2988. * @return a boolean indicating whether the action has been unregistered
  2989. */
  2990. unregisterAction(action: Action): Boolean;
  2991. /**
  2992. * Process a specific trigger
  2993. * @param trigger defines the trigger to process
  2994. * @param evt defines the event details to be processed
  2995. */
  2996. processTrigger(trigger: number, evt?: ActionEvent): void;
  2997. /** @hidden */
  2998. _getEffectiveTarget(target: any, propertyPath: string): any;
  2999. /** @hidden */
  3000. _getProperty(propertyPath: string): string;
  3001. /**
  3002. * Serialize this manager to a JSON object
  3003. * @param name defines the property name to store this manager
  3004. * @returns a JSON representation of this manager
  3005. */
  3006. serialize(name: string): any;
  3007. /**
  3008. * Creates a new ActionManager from a JSON data
  3009. * @param parsedActions defines the JSON data to read from
  3010. * @param object defines the hosting mesh
  3011. * @param scene defines the hosting scene
  3012. */
  3013. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3014. /**
  3015. * Get a trigger name by index
  3016. * @param trigger defines the trigger index
  3017. * @returns a trigger name
  3018. */
  3019. static GetTriggerName(trigger: number): string;
  3020. }
  3021. }
  3022. declare module BABYLON {
  3023. /**
  3024. * A Condition applied to an Action
  3025. */
  3026. class Condition {
  3027. /**
  3028. * Internal only - manager for action
  3029. * @hidden
  3030. */
  3031. _actionManager: ActionManager;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _evaluationId: number;
  3037. /**
  3038. * Internal only
  3039. * @hidden
  3040. */
  3041. _currentResult: boolean;
  3042. /**
  3043. * Creates a new Condition
  3044. * @param actionManager the manager of the action the condition is applied to
  3045. */
  3046. constructor(actionManager: ActionManager);
  3047. /**
  3048. * Check if the current condition is valid
  3049. * @returns a boolean
  3050. */
  3051. isValid(): boolean;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getProperty(propertyPath: string): string;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. _getEffectiveTarget(target: any, propertyPath: string): any;
  3062. /**
  3063. * Serialize placeholder for child classes
  3064. * @returns the serialized object
  3065. */
  3066. serialize(): any;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. protected _serialize(serializedCondition: any): any;
  3072. }
  3073. /**
  3074. * Defines specific conditional operators as extensions of Condition
  3075. */
  3076. class ValueCondition extends Condition {
  3077. /** path to specify the property of the target the conditional operator uses */
  3078. propertyPath: string;
  3079. /** the value compared by the conditional operator against the current value of the property */
  3080. value: any;
  3081. /** the conditional operator, default ValueCondition.IsEqual */
  3082. operator: number;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsEqual;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsDifferent;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsGreater;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsLesser;
  3103. /**
  3104. * returns the number for IsEqual
  3105. */
  3106. static readonly IsEqual: number;
  3107. /**
  3108. * Returns the number for IsDifferent
  3109. */
  3110. static readonly IsDifferent: number;
  3111. /**
  3112. * Returns the number for IsGreater
  3113. */
  3114. static readonly IsGreater: number;
  3115. /**
  3116. * Returns the number for IsLesser
  3117. */
  3118. static readonly IsLesser: number;
  3119. /**
  3120. * Internal only The action manager for the condition
  3121. * @hidden
  3122. */
  3123. _actionManager: ActionManager;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _target;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _effectiveTarget;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _property;
  3139. /**
  3140. * Creates a new ValueCondition
  3141. * @param actionManager manager for the action the condition applies to
  3142. * @param target for the action
  3143. * @param propertyPath path to specify the property of the target the conditional operator uses
  3144. * @param value the value compared by the conditional operator against the current value of the property
  3145. * @param operator the conditional operator, default ValueCondition.IsEqual
  3146. */
  3147. constructor(actionManager: ActionManager, target: any,
  3148. /** path to specify the property of the target the conditional operator uses */
  3149. propertyPath: string,
  3150. /** the value compared by the conditional operator against the current value of the property */
  3151. value: any,
  3152. /** the conditional operator, default ValueCondition.IsEqual */
  3153. operator?: number);
  3154. /**
  3155. * Compares the given value with the property value for the specified conditional operator
  3156. * @returns the result of the comparison
  3157. */
  3158. isValid(): boolean;
  3159. /**
  3160. * Serialize the ValueCondition into a JSON compatible object
  3161. * @returns serialization object
  3162. */
  3163. serialize(): any;
  3164. /**
  3165. * Gets the name of the conditional operator for the ValueCondition
  3166. * @param operator the conditional operator
  3167. * @returns the name
  3168. */
  3169. static GetOperatorName(operator: number): string;
  3170. }
  3171. /**
  3172. * Defines a predicate condition as an extension of Condition
  3173. */
  3174. class PredicateCondition extends Condition {
  3175. /** defines the predicate function used to validate the condition */
  3176. predicate: () => boolean;
  3177. /**
  3178. * Internal only - manager for action
  3179. * @hidden
  3180. */
  3181. _actionManager: ActionManager;
  3182. /**
  3183. * Creates a new PredicateCondition
  3184. * @param actionManager manager for the action the condition applies to
  3185. * @param predicate defines the predicate function used to validate the condition
  3186. */
  3187. constructor(actionManager: ActionManager,
  3188. /** defines the predicate function used to validate the condition */
  3189. predicate: () => boolean);
  3190. /**
  3191. * @returns the validity of the predicate condition
  3192. */
  3193. isValid(): boolean;
  3194. }
  3195. /**
  3196. * Defines a state condition as an extension of Condition
  3197. */
  3198. class StateCondition extends Condition {
  3199. value: string;
  3200. /**
  3201. * Internal only - manager for action
  3202. * @hidden
  3203. */
  3204. _actionManager: ActionManager;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _target;
  3210. /**
  3211. * Creates a new StateCondition
  3212. * @param actionManager manager for the action the condition applies to
  3213. * @param target of the condition
  3214. * @param value to compare with target state
  3215. */
  3216. constructor(actionManager: ActionManager, target: any, value: string);
  3217. /**
  3218. * @returns the validity of the state
  3219. */
  3220. isValid(): boolean;
  3221. /**
  3222. * Serialize the StateCondition into a JSON compatible object
  3223. * @returns serialization object
  3224. */
  3225. serialize(): any;
  3226. }
  3227. }
  3228. declare module BABYLON {
  3229. class SwitchBooleanAction extends Action {
  3230. propertyPath: string;
  3231. private _target;
  3232. private _effectiveTarget;
  3233. private _property;
  3234. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3235. _prepare(): void;
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class SetStateAction extends Action {
  3240. value: string;
  3241. private _target;
  3242. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3243. execute(): void;
  3244. serialize(parent: any): any;
  3245. }
  3246. class SetValueAction extends Action {
  3247. propertyPath: string;
  3248. value: any;
  3249. private _target;
  3250. private _effectiveTarget;
  3251. private _property;
  3252. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3253. _prepare(): void;
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class IncrementValueAction extends Action {
  3258. propertyPath: string;
  3259. value: any;
  3260. private _target;
  3261. private _effectiveTarget;
  3262. private _property;
  3263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3264. _prepare(): void;
  3265. execute(): void;
  3266. serialize(parent: any): any;
  3267. }
  3268. class PlayAnimationAction extends Action {
  3269. from: number;
  3270. to: number;
  3271. loop: boolean | undefined;
  3272. private _target;
  3273. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class StopAnimationAction extends Action {
  3279. private _target;
  3280. constructor(triggerOptions: any, target: any, condition?: Condition);
  3281. _prepare(): void;
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class DoNothingAction extends Action {
  3286. constructor(triggerOptions?: any, condition?: Condition);
  3287. execute(): void;
  3288. serialize(parent: any): any;
  3289. }
  3290. class CombineAction extends Action {
  3291. children: Action[];
  3292. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3293. _prepare(): void;
  3294. execute(evt: ActionEvent): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class ExecuteCodeAction extends Action {
  3298. func: (evt: ActionEvent) => void;
  3299. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3300. execute(evt: ActionEvent): void;
  3301. }
  3302. class SetParentAction extends Action {
  3303. private _parent;
  3304. private _target;
  3305. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3306. _prepare(): void;
  3307. execute(): void;
  3308. serialize(parent: any): any;
  3309. }
  3310. class PlaySoundAction extends Action {
  3311. private _sound;
  3312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3313. _prepare(): void;
  3314. execute(): void;
  3315. serialize(parent: any): any;
  3316. }
  3317. class StopSoundAction extends Action {
  3318. private _sound;
  3319. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3320. _prepare(): void;
  3321. execute(): void;
  3322. serialize(parent: any): any;
  3323. }
  3324. }
  3325. declare module BABYLON {
  3326. class InterpolateValueAction extends Action {
  3327. propertyPath: string;
  3328. value: any;
  3329. duration: number;
  3330. stopOtherAnimations: boolean | undefined;
  3331. onInterpolationDone: (() => void) | undefined;
  3332. private _target;
  3333. private _effectiveTarget;
  3334. private _property;
  3335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3337. _prepare(): void;
  3338. execute(): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. }
  3342. declare module BABYLON {
  3343. class Animatable {
  3344. target: any;
  3345. fromFrame: number;
  3346. toFrame: number;
  3347. loopAnimation: boolean;
  3348. onAnimationEnd: (() => void) | null | undefined;
  3349. private _localDelayOffset;
  3350. private _pausedDelay;
  3351. private _runtimeAnimations;
  3352. private _paused;
  3353. private _scene;
  3354. private _speedRatio;
  3355. private _weight;
  3356. private _syncRoot;
  3357. animationStarted: boolean;
  3358. /**
  3359. * Observer raised when the animation ends
  3360. */
  3361. onAnimationEndObservable: Observable<Animatable>;
  3362. /**
  3363. * Gets the root Animatable used to synchronize and normalize animations
  3364. */
  3365. readonly syncRoot: Animatable;
  3366. /**
  3367. * Gets the current frame of the first RuntimeAnimation
  3368. * Used to synchronize Animatables
  3369. */
  3370. readonly masterFrame: number;
  3371. /**
  3372. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3373. */
  3374. weight: number;
  3375. /**
  3376. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3377. */
  3378. speedRatio: number;
  3379. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3380. /**
  3381. * Synchronize and normalize current Animatable with a source Animatable
  3382. * This is useful when using animation weights and when animations are not of the same length
  3383. * @param root defines the root Animatable to synchronize with
  3384. * @returns the current Animatable
  3385. */
  3386. syncWith(root: Animatable): Animatable;
  3387. getAnimations(): RuntimeAnimation[];
  3388. appendAnimations(target: any, animations: Animation[]): void;
  3389. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3390. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3391. reset(): void;
  3392. enableBlending(blendingSpeed: number): void;
  3393. disableBlending(): void;
  3394. goToFrame(frame: number): void;
  3395. pause(): void;
  3396. restart(): void;
  3397. private _raiseOnAnimationEnd();
  3398. stop(animationName?: string): void;
  3399. /**
  3400. * Wait asynchronously for the animation to end
  3401. * @returns a promise which will be fullfilled when the animation ends
  3402. */
  3403. waitAsync(): Promise<Animatable>;
  3404. /** @hidden */
  3405. _animate(delay: number): boolean;
  3406. }
  3407. }
  3408. declare module BABYLON {
  3409. /**
  3410. * Represents the range of an animation
  3411. */
  3412. class AnimationRange {
  3413. /**The name of the animation range**/
  3414. name: string;
  3415. /**The starting frame of the animation */
  3416. from: number;
  3417. /**The ending frame of the animation*/
  3418. to: number;
  3419. /**
  3420. * Initializes the range of an animation
  3421. * @param name The name of the animation range
  3422. * @param from The starting frame of the animation
  3423. * @param to The ending frame of the animation
  3424. */
  3425. constructor(
  3426. /**The name of the animation range**/
  3427. name: string,
  3428. /**The starting frame of the animation */
  3429. from: number,
  3430. /**The ending frame of the animation*/
  3431. to: number);
  3432. /**
  3433. * Makes a copy of the animation range
  3434. * @returns A copy of the animation range
  3435. */
  3436. clone(): AnimationRange;
  3437. }
  3438. /**
  3439. * Composed of a frame, and an action function
  3440. */
  3441. class AnimationEvent {
  3442. /** The frame for which the event is triggered **/
  3443. frame: number;
  3444. /** The event to perform when triggered **/
  3445. action: () => void;
  3446. /** Specifies if the event should be triggered only once**/
  3447. onlyOnce: boolean | undefined;
  3448. /**
  3449. * Specifies if the animation event is done
  3450. */
  3451. isDone: boolean;
  3452. /**
  3453. * Initializes the animation event
  3454. * @param frame The frame for which the event is triggered
  3455. * @param action The event to perform when triggered
  3456. * @param onlyOnce Specifies if the event should be triggered only once
  3457. */
  3458. constructor(
  3459. /** The frame for which the event is triggered **/
  3460. frame: number,
  3461. /** The event to perform when triggered **/
  3462. action: () => void,
  3463. /** Specifies if the event should be triggered only once**/
  3464. onlyOnce?: boolean | undefined);
  3465. /** @hidden */
  3466. _clone(): AnimationEvent;
  3467. }
  3468. /**
  3469. * A cursor which tracks a point on a path
  3470. */
  3471. class PathCursor {
  3472. private path;
  3473. /**
  3474. * Stores path cursor callbacks for when an onchange event is triggered
  3475. */
  3476. private _onchange;
  3477. /**
  3478. * The value of the path cursor
  3479. */
  3480. value: number;
  3481. /**
  3482. * The animation array of the path cursor
  3483. */
  3484. animations: Animation[];
  3485. /**
  3486. * Initializes the path cursor
  3487. * @param path The path to track
  3488. */
  3489. constructor(path: Path2);
  3490. /**
  3491. * Gets the cursor point on the path
  3492. * @returns A point on the path cursor at the cursor location
  3493. */
  3494. getPoint(): Vector3;
  3495. /**
  3496. * Moves the cursor ahead by the step amount
  3497. * @param step The amount to move the cursor forward
  3498. * @returns This path cursor
  3499. */
  3500. moveAhead(step?: number): PathCursor;
  3501. /**
  3502. * Moves the cursor behind by the step amount
  3503. * @param step The amount to move the cursor back
  3504. * @returns This path cursor
  3505. */
  3506. moveBack(step?: number): PathCursor;
  3507. /**
  3508. * Moves the cursor by the step amount
  3509. * If the step amount is greater than one, an exception is thrown
  3510. * @param step The amount to move the cursor
  3511. * @returns This path cursor
  3512. */
  3513. move(step: number): PathCursor;
  3514. /**
  3515. * Ensures that the value is limited between zero and one
  3516. * @returns This path cursor
  3517. */
  3518. private ensureLimits();
  3519. /**
  3520. * Runs onchange callbacks on change (used by the animation engine)
  3521. * @returns This path cursor
  3522. */
  3523. private raiseOnChange();
  3524. /**
  3525. * Executes a function on change
  3526. * @param f A path cursor onchange callback
  3527. * @returns This path cursor
  3528. */
  3529. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3530. }
  3531. /**
  3532. * Defines an interface which represents an animation key frame
  3533. */
  3534. interface IAnimationKey {
  3535. /**
  3536. * Frame of the key frame
  3537. */
  3538. frame: number;
  3539. /**
  3540. * Value at the specifies key frame
  3541. */
  3542. value: any;
  3543. /**
  3544. * The input tangent for the cubic hermite spline
  3545. */
  3546. inTangent?: any;
  3547. /**
  3548. * The output tangent for the cubic hermite spline
  3549. */
  3550. outTangent?: any;
  3551. /**
  3552. * The animation interpolation type
  3553. */
  3554. interpolation?: AnimationKeyInterpolation;
  3555. }
  3556. /**
  3557. * Enum for the animation key frame interpolation type
  3558. */
  3559. enum AnimationKeyInterpolation {
  3560. /**
  3561. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3562. */
  3563. STEP = 1,
  3564. }
  3565. /**
  3566. * Class used to store any kind of animation
  3567. */
  3568. class Animation {
  3569. /**Name of the animation */
  3570. name: string;
  3571. /**Property to animate */
  3572. targetProperty: string;
  3573. /**The frames per second of the animation */
  3574. framePerSecond: number;
  3575. /**The data type of the animation */
  3576. dataType: number;
  3577. /**The loop mode of the animation */
  3578. loopMode: number | undefined;
  3579. /**Specifies if blending should be enabled */
  3580. enableBlending: boolean | undefined;
  3581. /**
  3582. * Use matrix interpolation instead of using direct key value when animating matrices
  3583. */
  3584. static AllowMatricesInterpolation: boolean;
  3585. /**
  3586. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3587. */
  3588. static AllowMatrixDecomposeForInterpolation: boolean;
  3589. /**
  3590. * Stores the key frames of the animation
  3591. */
  3592. private _keys;
  3593. /**
  3594. * Stores the easing function of the animation
  3595. */
  3596. private _easingFunction;
  3597. /**
  3598. * @hidden Internal use only
  3599. */
  3600. _runtimeAnimations: RuntimeAnimation[];
  3601. /**
  3602. * The set of event that will be linked to this animation
  3603. */
  3604. private _events;
  3605. /**
  3606. * Stores an array of target property paths
  3607. */
  3608. targetPropertyPath: string[];
  3609. /**
  3610. * Stores the blending speed of the animation
  3611. */
  3612. blendingSpeed: number;
  3613. /**
  3614. * Stores the animation ranges for the animation
  3615. */
  3616. private _ranges;
  3617. /**
  3618. * @hidden Internal use
  3619. */
  3620. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3621. /**
  3622. * Sets up an animation
  3623. * @param property The property to animate
  3624. * @param animationType The animation type to apply
  3625. * @param framePerSecond The frames per second of the animation
  3626. * @param easingFunction The easing function used in the animation
  3627. * @returns The created animation
  3628. */
  3629. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3630. /**
  3631. * Create and start an animation on a node
  3632. * @param name defines the name of the global animation that will be run on all nodes
  3633. * @param node defines the root node where the animation will take place
  3634. * @param targetProperty defines property to animate
  3635. * @param framePerSecond defines the number of frame per second yo use
  3636. * @param totalFrame defines the number of frames in total
  3637. * @param from defines the initial value
  3638. * @param to defines the final value
  3639. * @param loopMode defines which loop mode you want to use (off by default)
  3640. * @param easingFunction defines the easing function to use (linear by default)
  3641. * @param onAnimationEnd defines the callback to call when animation end
  3642. * @returns the animatable created for this animation
  3643. */
  3644. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3645. /**
  3646. * Create and start an animation on a node and its descendants
  3647. * @param name defines the name of the global animation that will be run on all nodes
  3648. * @param node defines the root node where the animation will take place
  3649. * @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
  3650. * @param targetProperty defines property to animate
  3651. * @param framePerSecond defines the number of frame per second to use
  3652. * @param totalFrame defines the number of frames in total
  3653. * @param from defines the initial value
  3654. * @param to defines the final value
  3655. * @param loopMode defines which loop mode you want to use (off by default)
  3656. * @param easingFunction defines the easing function to use (linear by default)
  3657. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3658. * @returns the list of animatables created for all nodes
  3659. * @example https://www.babylonjs-playground.com/#MH0VLI
  3660. */
  3661. 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[]>;
  3662. /**
  3663. * Creates a new animation, merges it with the existing animations and starts it
  3664. * @param name Name of the animation
  3665. * @param node Node which contains the scene that begins the animations
  3666. * @param targetProperty Specifies which property to animate
  3667. * @param framePerSecond The frames per second of the animation
  3668. * @param totalFrame The total number of frames
  3669. * @param from The frame at the beginning of the animation
  3670. * @param to The frame at the end of the animation
  3671. * @param loopMode Specifies the loop mode of the animation
  3672. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3673. * @param onAnimationEnd Callback to run once the animation is complete
  3674. * @returns Nullable animation
  3675. */
  3676. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3677. /**
  3678. * Transition property of an host to the target Value
  3679. * @param property The property to transition
  3680. * @param targetValue The target Value of the property
  3681. * @param host The object where the property to animate belongs
  3682. * @param scene Scene used to run the animation
  3683. * @param frameRate Framerate (in frame/s) to use
  3684. * @param transition The transition type we want to use
  3685. * @param duration The duration of the animation, in milliseconds
  3686. * @param onAnimationEnd Callback trigger at the end of the animation
  3687. * @returns Nullable animation
  3688. */
  3689. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3690. /**
  3691. * Return the array of runtime animations currently using this animation
  3692. */
  3693. readonly runtimeAnimations: RuntimeAnimation[];
  3694. /**
  3695. * Specifies if any of the runtime animations are currently running
  3696. */
  3697. readonly hasRunningRuntimeAnimations: boolean;
  3698. /**
  3699. * Initializes the animation
  3700. * @param name Name of the animation
  3701. * @param targetProperty Property to animate
  3702. * @param framePerSecond The frames per second of the animation
  3703. * @param dataType The data type of the animation
  3704. * @param loopMode The loop mode of the animation
  3705. * @param enableBlendings Specifies if blending should be enabled
  3706. */
  3707. constructor(
  3708. /**Name of the animation */
  3709. name: string,
  3710. /**Property to animate */
  3711. targetProperty: string,
  3712. /**The frames per second of the animation */
  3713. framePerSecond: number,
  3714. /**The data type of the animation */
  3715. dataType: number,
  3716. /**The loop mode of the animation */
  3717. loopMode?: number | undefined,
  3718. /**Specifies if blending should be enabled */
  3719. enableBlending?: boolean | undefined);
  3720. /**
  3721. * Converts the animation to a string
  3722. * @param fullDetails support for multiple levels of logging within scene loading
  3723. * @returns String form of the animation
  3724. */
  3725. toString(fullDetails?: boolean): string;
  3726. /**
  3727. * Add an event to this animation
  3728. * @param event Event to add
  3729. */
  3730. addEvent(event: AnimationEvent): void;
  3731. /**
  3732. * Remove all events found at the given frame
  3733. * @param frame The frame to remove events from
  3734. */
  3735. removeEvents(frame: number): void;
  3736. /**
  3737. * Retrieves all the events from the animation
  3738. * @returns Events from the animation
  3739. */
  3740. getEvents(): AnimationEvent[];
  3741. /**
  3742. * Creates an animation range
  3743. * @param name Name of the animation range
  3744. * @param from Starting frame of the animation range
  3745. * @param to Ending frame of the animation
  3746. */
  3747. createRange(name: string, from: number, to: number): void;
  3748. /**
  3749. * Deletes an animation range by name
  3750. * @param name Name of the animation range to delete
  3751. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3752. */
  3753. deleteRange(name: string, deleteFrames?: boolean): void;
  3754. /**
  3755. * Gets the animation range by name, or null if not defined
  3756. * @param name Name of the animation range
  3757. * @returns Nullable animation range
  3758. */
  3759. getRange(name: string): Nullable<AnimationRange>;
  3760. /**
  3761. * Gets the key frames from the animation
  3762. * @returns The key frames of the animation
  3763. */
  3764. getKeys(): Array<IAnimationKey>;
  3765. /**
  3766. * Gets the highest frame rate of the animation
  3767. * @returns Highest frame rate of the animation
  3768. */
  3769. getHighestFrame(): number;
  3770. /**
  3771. * Gets the easing function of the animation
  3772. * @returns Easing function of the animation
  3773. */
  3774. getEasingFunction(): IEasingFunction;
  3775. /**
  3776. * Sets the easing function of the animation
  3777. * @param easingFunction A custom mathematical formula for animation
  3778. */
  3779. setEasingFunction(easingFunction: EasingFunction): void;
  3780. /**
  3781. * Interpolates a scalar linearly
  3782. * @param startValue Start value of the animation curve
  3783. * @param endValue End value of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns Interpolated scalar value
  3786. */
  3787. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3788. /**
  3789. * Interpolates a scalar cubically
  3790. * @param startValue Start value of the animation curve
  3791. * @param outTangent End tangent of the animation
  3792. * @param endValue End value of the animation curve
  3793. * @param inTangent Start tangent of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns Interpolated scalar value
  3796. */
  3797. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3798. /**
  3799. * Interpolates a quaternion using a spherical linear interpolation
  3800. * @param startValue Start value of the animation curve
  3801. * @param endValue End value of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated quaternion value
  3804. */
  3805. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3806. /**
  3807. * Interpolates a quaternion cubically
  3808. * @param startValue Start value of the animation curve
  3809. * @param outTangent End tangent of the animation curve
  3810. * @param endValue End value of the animation curve
  3811. * @param inTangent Start tangent of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns Interpolated quaternion value
  3814. */
  3815. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3816. /**
  3817. * Interpolates a Vector3 linearl
  3818. * @param startValue Start value of the animation curve
  3819. * @param endValue End value of the animation curve
  3820. * @param gradient Scalar amount to interpolate
  3821. * @returns Interpolated scalar value
  3822. */
  3823. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3824. /**
  3825. * Interpolates a Vector3 cubically
  3826. * @param startValue Start value of the animation curve
  3827. * @param outTangent End tangent of the animation
  3828. * @param endValue End value of the animation curve
  3829. * @param inTangent Start tangent of the animation curve
  3830. * @param gradient Scalar amount to interpolate
  3831. * @returns InterpolatedVector3 value
  3832. */
  3833. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3834. /**
  3835. * Interpolates a Vector2 linearly
  3836. * @param startValue Start value of the animation curve
  3837. * @param endValue End value of the animation curve
  3838. * @param gradient Scalar amount to interpolate
  3839. * @returns Interpolated Vector2 value
  3840. */
  3841. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3842. /**
  3843. * Interpolates a Vector2 cubically
  3844. * @param startValue Start value of the animation curve
  3845. * @param outTangent End tangent of the animation
  3846. * @param endValue End value of the animation curve
  3847. * @param inTangent Start tangent of the animation curve
  3848. * @param gradient Scalar amount to interpolate
  3849. * @returns Interpolated Vector2 value
  3850. */
  3851. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3852. /**
  3853. * Interpolates a size linearly
  3854. * @param startValue Start value of the animation curve
  3855. * @param endValue End value of the animation curve
  3856. * @param gradient Scalar amount to interpolate
  3857. * @returns Interpolated Size value
  3858. */
  3859. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3860. /**
  3861. * Interpolates a Color3 linearly
  3862. * @param startValue Start value of the animation curve
  3863. * @param endValue End value of the animation curve
  3864. * @param gradient Scalar amount to interpolate
  3865. * @returns Interpolated Color3 value
  3866. */
  3867. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3868. /**
  3869. * @hidden Internal use only
  3870. */
  3871. _getKeyValue(value: any): any;
  3872. /**
  3873. * @hidden Internal use only
  3874. */
  3875. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3876. /**
  3877. * Defines the function to use to interpolate matrices
  3878. * @param startValue defines the start matrix
  3879. * @param endValue defines the end matrix
  3880. * @param gradient defines the gradient between both matrices
  3881. * @param result defines an optional target matrix where to store the interpolation
  3882. * @returns the interpolated matrix
  3883. */
  3884. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3885. /**
  3886. * Makes a copy of the animation
  3887. * @returns Cloned animation
  3888. */
  3889. clone(): Animation;
  3890. /**
  3891. * Sets the key frames of the animation
  3892. * @param values The animation key frames to set
  3893. */
  3894. setKeys(values: Array<IAnimationKey>): void;
  3895. /**
  3896. * Serializes the animation to an object
  3897. * @returns Serialized object
  3898. */
  3899. serialize(): any;
  3900. /**
  3901. * Float animation type
  3902. */
  3903. private static _ANIMATIONTYPE_FLOAT;
  3904. /**
  3905. * Vector3 animation type
  3906. */
  3907. private static _ANIMATIONTYPE_VECTOR3;
  3908. /**
  3909. * Quaternion animation type
  3910. */
  3911. private static _ANIMATIONTYPE_QUATERNION;
  3912. /**
  3913. * Matrix animation type
  3914. */
  3915. private static _ANIMATIONTYPE_MATRIX;
  3916. /**
  3917. * Color3 animation type
  3918. */
  3919. private static _ANIMATIONTYPE_COLOR3;
  3920. /**
  3921. * Vector2 animation type
  3922. */
  3923. private static _ANIMATIONTYPE_VECTOR2;
  3924. /**
  3925. * Size animation type
  3926. */
  3927. private static _ANIMATIONTYPE_SIZE;
  3928. /**
  3929. * Relative Loop Mode
  3930. */
  3931. private static _ANIMATIONLOOPMODE_RELATIVE;
  3932. /**
  3933. * Cycle Loop Mode
  3934. */
  3935. private static _ANIMATIONLOOPMODE_CYCLE;
  3936. /**
  3937. * Constant Loop Mode
  3938. */
  3939. private static _ANIMATIONLOOPMODE_CONSTANT;
  3940. /**
  3941. * Get the float animation type
  3942. */
  3943. static readonly ANIMATIONTYPE_FLOAT: number;
  3944. /**
  3945. * Get the Vector3 animation type
  3946. */
  3947. static readonly ANIMATIONTYPE_VECTOR3: number;
  3948. /**
  3949. * Get the Vectpr2 animation type
  3950. */
  3951. static readonly ANIMATIONTYPE_VECTOR2: number;
  3952. /**
  3953. * Get the Size animation type
  3954. */
  3955. static readonly ANIMATIONTYPE_SIZE: number;
  3956. /**
  3957. * Get the Quaternion animation type
  3958. */
  3959. static readonly ANIMATIONTYPE_QUATERNION: number;
  3960. /**
  3961. * Get the Matrix animation type
  3962. */
  3963. static readonly ANIMATIONTYPE_MATRIX: number;
  3964. /**
  3965. * Get the Color3 animation type
  3966. */
  3967. static readonly ANIMATIONTYPE_COLOR3: number;
  3968. /**
  3969. * Get the Relative Loop Mode
  3970. */
  3971. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3972. /**
  3973. * Get the Cycle Loop Mode
  3974. */
  3975. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3976. /**
  3977. * Get the Constant Loop Mode
  3978. */
  3979. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3980. /** @hidden */
  3981. static _UniversalLerp(left: any, right: any, amount: number): any;
  3982. /**
  3983. * Parses an animation object and creates an animation
  3984. * @param parsedAnimation Parsed animation object
  3985. * @returns Animation object
  3986. */
  3987. static Parse(parsedAnimation: any): Animation;
  3988. /**
  3989. * Appends the serialized animations from the source animations
  3990. * @param source Source containing the animations
  3991. * @param destination Target to store the animations
  3992. */
  3993. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3994. }
  3995. }
  3996. declare module BABYLON {
  3997. /**
  3998. * This class defines the direct association between an animation and a target
  3999. */
  4000. class TargetedAnimation {
  4001. animation: Animation;
  4002. target: any;
  4003. }
  4004. /**
  4005. * Use this class to create coordinated animations on multiple targets
  4006. */
  4007. class AnimationGroup implements IDisposable {
  4008. name: string;
  4009. private _scene;
  4010. private _targetedAnimations;
  4011. private _animatables;
  4012. private _from;
  4013. private _to;
  4014. private _isStarted;
  4015. private _speedRatio;
  4016. onAnimationEndObservable: Observable<TargetedAnimation>;
  4017. /**
  4018. * This observable will notify when all animations have ended.
  4019. */
  4020. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4021. /**
  4022. * Gets the first frame
  4023. */
  4024. readonly from: number;
  4025. /**
  4026. * Gets the last frame
  4027. */
  4028. readonly to: number;
  4029. /**
  4030. * Define if the animations are started
  4031. */
  4032. readonly isStarted: boolean;
  4033. /**
  4034. * Gets or sets the speed ratio to use for all animations
  4035. */
  4036. /**
  4037. * Gets or sets the speed ratio to use for all animations
  4038. */
  4039. speedRatio: number;
  4040. /**
  4041. * Gets the targeted animations for this animation group
  4042. */
  4043. readonly targetedAnimations: Array<TargetedAnimation>;
  4044. /**
  4045. * returning the list of animatables controlled by this animation group.
  4046. */
  4047. readonly animatables: Array<Animatable>;
  4048. constructor(name: string, scene?: Nullable<Scene>);
  4049. /**
  4050. * Add an animation (with its target) in the group
  4051. * @param animation defines the animation we want to add
  4052. * @param target defines the target of the animation
  4053. * @returns the {BABYLON.TargetedAnimation} object
  4054. */
  4055. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4056. /**
  4057. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4058. * It can add constant keys at begin or end
  4059. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4060. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4061. */
  4062. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4063. /**
  4064. * Start all animations on given targets
  4065. * @param loop defines if animations must loop
  4066. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4067. * @param from defines the from key (optional)
  4068. * @param to defines the to key (optional)
  4069. * @returns the current animation group
  4070. */
  4071. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4072. /**
  4073. * Pause all animations
  4074. */
  4075. pause(): AnimationGroup;
  4076. /**
  4077. * Play all animations to initial state
  4078. * This function will start() the animations if they were not started or will restart() them if they were paused
  4079. * @param loop defines if animations must loop
  4080. */
  4081. play(loop?: boolean): AnimationGroup;
  4082. /**
  4083. * Reset all animations to initial state
  4084. */
  4085. reset(): AnimationGroup;
  4086. /**
  4087. * Restart animations from key 0
  4088. */
  4089. restart(): AnimationGroup;
  4090. /**
  4091. * Stop all animations
  4092. */
  4093. stop(): AnimationGroup;
  4094. /**
  4095. * Set animation weight for all animatables
  4096. * @param weight defines the weight to use
  4097. * @return the animationGroup
  4098. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4099. */
  4100. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4101. /**
  4102. * Synchronize and normalize all animatables with a source animatable
  4103. * @param root defines the root animatable to synchronize with
  4104. * @return the animationGroup
  4105. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4106. */
  4107. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4108. /**
  4109. * Goes to a specific frame in this animation group
  4110. * @param frame the frame number to go to
  4111. * @return the animationGroup
  4112. */
  4113. goToFrame(frame: number): AnimationGroup;
  4114. /**
  4115. * Dispose all associated resources
  4116. */
  4117. dispose(): void;
  4118. private _checkAnimationGroupEnded(animatable);
  4119. }
  4120. }
  4121. declare module BABYLON {
  4122. /**
  4123. * Class used to override all child animations of a given target
  4124. */
  4125. class AnimationPropertiesOverride {
  4126. /**
  4127. * Gets or sets a value indicating if animation blending must be used
  4128. */
  4129. enableBlending: boolean;
  4130. /**
  4131. * Gets or sets the blending speed to use when enableBlending is true
  4132. */
  4133. blendingSpeed: number;
  4134. /**
  4135. * Gets or sets the default loop mode to use
  4136. */
  4137. loopMode: number;
  4138. }
  4139. }
  4140. declare module BABYLON {
  4141. interface IEasingFunction {
  4142. ease(gradient: number): number;
  4143. }
  4144. class EasingFunction implements IEasingFunction {
  4145. private static _EASINGMODE_EASEIN;
  4146. private static _EASINGMODE_EASEOUT;
  4147. private static _EASINGMODE_EASEINOUT;
  4148. static readonly EASINGMODE_EASEIN: number;
  4149. static readonly EASINGMODE_EASEOUT: number;
  4150. static readonly EASINGMODE_EASEINOUT: number;
  4151. private _easingMode;
  4152. setEasingMode(easingMode: number): void;
  4153. getEasingMode(): number;
  4154. easeInCore(gradient: number): number;
  4155. ease(gradient: number): number;
  4156. }
  4157. class CircleEase extends EasingFunction implements IEasingFunction {
  4158. easeInCore(gradient: number): number;
  4159. }
  4160. class BackEase extends EasingFunction implements IEasingFunction {
  4161. amplitude: number;
  4162. constructor(amplitude?: number);
  4163. easeInCore(gradient: number): number;
  4164. }
  4165. class BounceEase extends EasingFunction implements IEasingFunction {
  4166. bounces: number;
  4167. bounciness: number;
  4168. constructor(bounces?: number, bounciness?: number);
  4169. easeInCore(gradient: number): number;
  4170. }
  4171. class CubicEase extends EasingFunction implements IEasingFunction {
  4172. easeInCore(gradient: number): number;
  4173. }
  4174. class ElasticEase extends EasingFunction implements IEasingFunction {
  4175. oscillations: number;
  4176. springiness: number;
  4177. constructor(oscillations?: number, springiness?: number);
  4178. easeInCore(gradient: number): number;
  4179. }
  4180. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4181. exponent: number;
  4182. constructor(exponent?: number);
  4183. easeInCore(gradient: number): number;
  4184. }
  4185. class PowerEase extends EasingFunction implements IEasingFunction {
  4186. power: number;
  4187. constructor(power?: number);
  4188. easeInCore(gradient: number): number;
  4189. }
  4190. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4191. easeInCore(gradient: number): number;
  4192. }
  4193. class QuarticEase extends EasingFunction implements IEasingFunction {
  4194. easeInCore(gradient: number): number;
  4195. }
  4196. class QuinticEase extends EasingFunction implements IEasingFunction {
  4197. easeInCore(gradient: number): number;
  4198. }
  4199. class SineEase extends EasingFunction implements IEasingFunction {
  4200. easeInCore(gradient: number): number;
  4201. }
  4202. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4203. x1: number;
  4204. y1: number;
  4205. x2: number;
  4206. y2: number;
  4207. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4208. easeInCore(gradient: number): number;
  4209. }
  4210. }
  4211. declare module BABYLON {
  4212. /**
  4213. * Defines a runtime animation
  4214. */
  4215. class RuntimeAnimation {
  4216. private _events;
  4217. /**
  4218. * The current frame of the runtime animation
  4219. */
  4220. private _currentFrame;
  4221. /**
  4222. * The animation used by the runtime animation
  4223. */
  4224. private _animation;
  4225. /**
  4226. * The target of the runtime animation
  4227. */
  4228. private _target;
  4229. /**
  4230. * The initiating animatable
  4231. */
  4232. private _host;
  4233. /**
  4234. * The original value of the runtime animation
  4235. */
  4236. private _originalValue;
  4237. /**
  4238. * The original blend value of the runtime animation
  4239. */
  4240. private _originalBlendValue;
  4241. /**
  4242. * The offsets cache of the runtime animation
  4243. */
  4244. private _offsetsCache;
  4245. /**
  4246. * The high limits cache of the runtime animation
  4247. */
  4248. private _highLimitsCache;
  4249. /**
  4250. * Specifies if the runtime animation has been stopped
  4251. */
  4252. private _stopped;
  4253. /**
  4254. * The blending factor of the runtime animation
  4255. */
  4256. private _blendingFactor;
  4257. /**
  4258. * The BabylonJS scene
  4259. */
  4260. private _scene;
  4261. /**
  4262. * The current value of the runtime animation
  4263. */
  4264. private _currentValue;
  4265. /** @hidden */
  4266. _workValue: any;
  4267. /**
  4268. * The active target of the runtime animation
  4269. */
  4270. private _activeTarget;
  4271. /**
  4272. * The target path of the runtime animation
  4273. */
  4274. private _targetPath;
  4275. /**
  4276. * The weight of the runtime animation
  4277. */
  4278. private _weight;
  4279. /**
  4280. * The ratio offset of the runtime animation
  4281. */
  4282. private _ratioOffset;
  4283. /**
  4284. * The previous delay of the runtime animation
  4285. */
  4286. private _previousDelay;
  4287. /**
  4288. * The previous ratio of the runtime animation
  4289. */
  4290. private _previousRatio;
  4291. /**
  4292. * Gets the current frame of the runtime animation
  4293. */
  4294. readonly currentFrame: number;
  4295. /**
  4296. * Gets the weight of the runtime animation
  4297. */
  4298. readonly weight: number;
  4299. /**
  4300. * Gets the current value of the runtime animation
  4301. */
  4302. readonly currentValue: any;
  4303. /**
  4304. * Gets the target path of the runtime animation
  4305. */
  4306. readonly targetPath: string;
  4307. /**
  4308. * Gets the actual target of the runtime animation
  4309. */
  4310. readonly target: any;
  4311. /**
  4312. * Create a new RuntimeAnimation object
  4313. * @param target defines the target of the animation
  4314. * @param animation defines the source animation object
  4315. * @param scene defines the hosting scene
  4316. * @param host defines the initiating Animatable
  4317. */
  4318. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4319. /**
  4320. * Gets the animation from the runtime animation
  4321. */
  4322. readonly animation: Animation;
  4323. /**
  4324. * Resets the runtime animation to the beginning
  4325. * @param restoreOriginal defines whether to restore the target property to the original value
  4326. */
  4327. reset(restoreOriginal?: boolean): void;
  4328. /**
  4329. * Specifies if the runtime animation is stopped
  4330. * @returns Boolean specifying if the runtime animation is stopped
  4331. */
  4332. isStopped(): boolean;
  4333. /**
  4334. * Disposes of the runtime animation
  4335. */
  4336. dispose(): void;
  4337. /**
  4338. * Interpolates the animation from the current frame
  4339. * @param currentFrame The frame to interpolate the animation to
  4340. * @param repeatCount The number of times that the animation should loop
  4341. * @param loopMode The type of looping mode to use
  4342. * @param offsetValue Animation offset value
  4343. * @param highLimitValue The high limit value
  4344. * @returns The interpolated value
  4345. */
  4346. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4347. /**
  4348. * Apply the interpolated value to the target
  4349. * @param currentValue defines the value computed by the animation
  4350. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4351. */
  4352. setValue(currentValue: any, weight?: number): void;
  4353. private _setValue(target, currentValue, weight, targetIndex?);
  4354. /**
  4355. * Gets the loop pmode of the runtime animation
  4356. * @returns Loop Mode
  4357. */
  4358. private _getCorrectLoopMode();
  4359. /**
  4360. * Move the current animation to a given frame
  4361. * @param frame defines the frame to move to
  4362. */
  4363. goToFrame(frame: number): void;
  4364. /**
  4365. * @hidden Internal use only
  4366. */
  4367. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4368. /**
  4369. * Execute the current animation
  4370. * @param delay defines the delay to add to the current frame
  4371. * @param from defines the lower bound of the animation range
  4372. * @param to defines the upper bound of the animation range
  4373. * @param loop defines if the current animation must loop
  4374. * @param speedRatio defines the current speed ratio
  4375. * @param weight defines the weight of the animation (default is -1 so no weight)
  4376. * @returns a boolean indicating if the animation has ended
  4377. */
  4378. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4379. }
  4380. }
  4381. declare module BABYLON {
  4382. /**
  4383. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4385. */
  4386. class Analyser {
  4387. /**
  4388. * Gets or sets the smoothing
  4389. * @ignorenaming
  4390. */
  4391. SMOOTHING: number;
  4392. /**
  4393. * Gets or sets the FFT table size
  4394. * @ignorenaming
  4395. */
  4396. FFT_SIZE: number;
  4397. /**
  4398. * Gets or sets the bar graph amplitude
  4399. * @ignorenaming
  4400. */
  4401. BARGRAPHAMPLITUDE: number;
  4402. /**
  4403. * Gets or sets the position of the debug canvas
  4404. * @ignorenaming
  4405. */
  4406. DEBUGCANVASPOS: {
  4407. x: number;
  4408. y: number;
  4409. };
  4410. /**
  4411. * Gets or sets the debug canvas size
  4412. * @ignorenaming
  4413. */
  4414. DEBUGCANVASSIZE: {
  4415. width: number;
  4416. height: number;
  4417. };
  4418. private _byteFreqs;
  4419. private _byteTime;
  4420. private _floatFreqs;
  4421. private _webAudioAnalyser;
  4422. private _debugCanvas;
  4423. private _debugCanvasContext;
  4424. private _scene;
  4425. private _registerFunc;
  4426. private _audioEngine;
  4427. /**
  4428. * Creates a new analyser
  4429. * @param scene defines hosting scene
  4430. */
  4431. constructor(scene: Scene);
  4432. /**
  4433. * Get the number of data values you will have to play with for the visualization
  4434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4435. * @returns a number
  4436. */
  4437. getFrequencyBinCount(): number;
  4438. /**
  4439. * Gets the current frequency data as a byte array
  4440. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4441. * @returns a Uint8Array
  4442. */
  4443. getByteFrequencyData(): Uint8Array;
  4444. /**
  4445. * Gets the current waveform as a byte array
  4446. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4447. * @returns a Uint8Array
  4448. */
  4449. getByteTimeDomainData(): Uint8Array;
  4450. /**
  4451. * Gets the current frequency data as a float array
  4452. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4453. * @returns a Float32Array
  4454. */
  4455. getFloatFrequencyData(): Float32Array;
  4456. /**
  4457. * Renders the debug canvas
  4458. */
  4459. drawDebugCanvas(): void;
  4460. /**
  4461. * Stops rendering the debug canvas and removes it
  4462. */
  4463. stopDebugCanvas(): void;
  4464. /**
  4465. * Connects two audio nodes
  4466. * @param inputAudioNode defines first node to connect
  4467. * @param outputAudioNode defines second node to connect
  4468. */
  4469. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4470. /**
  4471. * Releases all associated resources
  4472. */
  4473. dispose(): void;
  4474. }
  4475. }
  4476. declare module BABYLON {
  4477. class AudioEngine {
  4478. private _audioContext;
  4479. private _audioContextInitialized;
  4480. canUseWebAudio: boolean;
  4481. masterGain: GainNode;
  4482. private _connectedAnalyser;
  4483. WarnedWebAudioUnsupported: boolean;
  4484. unlocked: boolean;
  4485. onAudioUnlocked: () => any;
  4486. isMP3supported: boolean;
  4487. isOGGsupported: boolean;
  4488. readonly audioContext: Nullable<AudioContext>;
  4489. constructor();
  4490. private _unlockiOSaudio();
  4491. private _initializeAudioContext();
  4492. dispose(): void;
  4493. getGlobalVolume(): number;
  4494. setGlobalVolume(newVolume: number): void;
  4495. connectToAnalyser(analyser: Analyser): void;
  4496. }
  4497. }
  4498. declare module BABYLON {
  4499. class Sound {
  4500. name: string;
  4501. autoplay: boolean;
  4502. loop: boolean;
  4503. useCustomAttenuation: boolean;
  4504. soundTrackId: number;
  4505. spatialSound: boolean;
  4506. refDistance: number;
  4507. rolloffFactor: number;
  4508. maxDistance: number;
  4509. distanceModel: string;
  4510. private _panningModel;
  4511. onended: () => any;
  4512. private _playbackRate;
  4513. private _streaming;
  4514. private _startTime;
  4515. private _startOffset;
  4516. private _position;
  4517. private _localDirection;
  4518. private _volume;
  4519. private _isReadyToPlay;
  4520. isPlaying: boolean;
  4521. isPaused: boolean;
  4522. private _isDirectional;
  4523. private _readyToPlayCallback;
  4524. private _audioBuffer;
  4525. private _soundSource;
  4526. private _streamingSource;
  4527. private _soundPanner;
  4528. private _soundGain;
  4529. private _inputAudioNode;
  4530. private _ouputAudioNode;
  4531. private _coneInnerAngle;
  4532. private _coneOuterAngle;
  4533. private _coneOuterGain;
  4534. private _scene;
  4535. private _connectedMesh;
  4536. private _customAttenuationFunction;
  4537. private _registerFunc;
  4538. private _isOutputConnected;
  4539. private _htmlAudioElement;
  4540. private _urlType;
  4541. /**
  4542. * Create a sound and attach it to a scene
  4543. * @param name Name of your sound
  4544. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4545. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4546. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4547. */
  4548. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4549. dispose(): void;
  4550. isReady(): boolean;
  4551. private _soundLoaded(audioData);
  4552. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4553. updateOptions(options: any): void;
  4554. private _createSpatialParameters();
  4555. private _updateSpatialParameters();
  4556. switchPanningModelToHRTF(): void;
  4557. switchPanningModelToEqualPower(): void;
  4558. private _switchPanningModel();
  4559. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4560. /**
  4561. * Transform this sound into a directional source
  4562. * @param coneInnerAngle Size of the inner cone in degree
  4563. * @param coneOuterAngle Size of the outer cone in degree
  4564. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4565. */
  4566. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4567. setPosition(newPosition: Vector3): void;
  4568. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4569. private _updateDirection();
  4570. updateDistanceFromListener(): void;
  4571. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4572. /**
  4573. * Play the sound
  4574. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4575. * @param offset (optional) Start the sound setting it at a specific time
  4576. */
  4577. play(time?: number, offset?: number): void;
  4578. private _onended();
  4579. /**
  4580. * Stop the sound
  4581. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4582. */
  4583. stop(time?: number): void;
  4584. pause(): void;
  4585. setVolume(newVolume: number, time?: number): void;
  4586. setPlaybackRate(newPlaybackRate: number): void;
  4587. getVolume(): number;
  4588. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4589. detachFromMesh(): void;
  4590. private _onRegisterAfterWorldMatrixUpdate(node);
  4591. clone(): Nullable<Sound>;
  4592. getAudioBuffer(): AudioBuffer | null;
  4593. serialize(): any;
  4594. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4595. }
  4596. }
  4597. declare module BABYLON {
  4598. class SoundTrack {
  4599. private _outputAudioNode;
  4600. private _scene;
  4601. id: number;
  4602. soundCollection: Array<Sound>;
  4603. private _isMainTrack;
  4604. private _connectedAnalyser;
  4605. private _options;
  4606. private _isInitialized;
  4607. constructor(scene: Scene, options?: any);
  4608. private _initializeSoundTrackAudioGraph();
  4609. dispose(): void;
  4610. AddSound(sound: Sound): void;
  4611. RemoveSound(sound: Sound): void;
  4612. setVolume(newVolume: number): void;
  4613. switchPanningModelToHRTF(): void;
  4614. switchPanningModelToEqualPower(): void;
  4615. connectToAnalyser(analyser: Analyser): void;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * Interface used to define a behavior
  4621. */
  4622. interface Behavior<T> {
  4623. /** gets or sets behavior's name */
  4624. name: string;
  4625. /**
  4626. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4627. */
  4628. init(): void;
  4629. /**
  4630. * Called when the behavior is attached to a target
  4631. * @param target defines the target where the behavior is attached to
  4632. */
  4633. attach(target: T): void;
  4634. /**
  4635. * Called when the behavior is detached from its target
  4636. */
  4637. detach(): void;
  4638. }
  4639. /**
  4640. * Interface implemented by classes supporting behaviors
  4641. */
  4642. interface IBehaviorAware<T> {
  4643. /**
  4644. * Attach a behavior
  4645. * @param behavior defines the behavior to attach
  4646. * @returns the current host
  4647. */
  4648. addBehavior(behavior: Behavior<T>): T;
  4649. /**
  4650. * Remove a behavior from the current object
  4651. * @param behavior defines the behavior to detach
  4652. * @returns the current host
  4653. */
  4654. removeBehavior(behavior: Behavior<T>): T;
  4655. /**
  4656. * Gets a behavior using its name to search
  4657. * @param name defines the name to search
  4658. * @returns the behavior or null if not found
  4659. */
  4660. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4661. }
  4662. }
  4663. declare module BABYLON {
  4664. /**
  4665. * Class used to store bone information
  4666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4667. */
  4668. class Bone extends Node {
  4669. /**
  4670. * defines the bone name
  4671. */
  4672. name: string;
  4673. private static _tmpVecs;
  4674. private static _tmpQuat;
  4675. private static _tmpMats;
  4676. /**
  4677. * Gets the list of child bones
  4678. */
  4679. children: Bone[];
  4680. /** Gets the animations associated with this bone */
  4681. animations: Animation[];
  4682. /**
  4683. * Gets or sets bone length
  4684. */
  4685. length: number;
  4686. /**
  4687. * @hidden Internal only
  4688. * Set this value to map this bone to a different index in the transform matrices
  4689. * Set this value to -1 to exclude the bone from the transform matrices
  4690. */
  4691. _index: Nullable<number>;
  4692. private _skeleton;
  4693. private _localMatrix;
  4694. private _restPose;
  4695. private _baseMatrix;
  4696. private _absoluteTransform;
  4697. private _invertedAbsoluteTransform;
  4698. private _parent;
  4699. private _scalingDeterminant;
  4700. private _worldTransform;
  4701. private _localScaling;
  4702. private _localRotation;
  4703. private _localPosition;
  4704. private _needToDecompose;
  4705. private _needToCompose;
  4706. /** @hidden */
  4707. /** @hidden */
  4708. _matrix: Matrix;
  4709. /**
  4710. * Create a new bone
  4711. * @param name defines the bone name
  4712. * @param skeleton defines the parent skeleton
  4713. * @param parentBone defines the parent (can be null if the bone is the root)
  4714. * @param localMatrix defines the local matrix
  4715. * @param restPose defines the rest pose matrix
  4716. * @param baseMatrix defines the base matrix
  4717. * @param index defines index of the bone in the hiearchy
  4718. */
  4719. constructor(
  4720. /**
  4721. * defines the bone name
  4722. */
  4723. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4724. /**
  4725. * Gets the parent skeleton
  4726. * @returns a skeleton
  4727. */
  4728. getSkeleton(): Skeleton;
  4729. /**
  4730. * Gets parent bone
  4731. * @returns a bone or null if the bone is the root of the bone hierarchy
  4732. */
  4733. getParent(): Nullable<Bone>;
  4734. /**
  4735. * Sets the parent bone
  4736. * @param parent defines the parent (can be null if the bone is the root)
  4737. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4738. */
  4739. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4740. /**
  4741. * Gets the local matrix
  4742. * @returns a matrix
  4743. */
  4744. getLocalMatrix(): Matrix;
  4745. /**
  4746. * Gets the base matrix (initial matrix which remains unchanged)
  4747. * @returns a matrix
  4748. */
  4749. getBaseMatrix(): Matrix;
  4750. /**
  4751. * Gets the rest pose matrix
  4752. * @returns a matrix
  4753. */
  4754. getRestPose(): Matrix;
  4755. /**
  4756. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4757. */
  4758. getWorldMatrix(): Matrix;
  4759. /**
  4760. * Sets the local matrix to rest pose matrix
  4761. */
  4762. returnToRest(): void;
  4763. /**
  4764. * Gets the inverse of the absolute transform matrix.
  4765. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4766. * @returns a matrix
  4767. */
  4768. getInvertedAbsoluteTransform(): Matrix;
  4769. /**
  4770. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4771. * @returns a matrix
  4772. */
  4773. getAbsoluteTransform(): Matrix;
  4774. /** Gets or sets current position (in local space) */
  4775. position: Vector3;
  4776. /** Gets or sets current rotation (in local space) */
  4777. rotation: Vector3;
  4778. /** Gets or sets current rotation quaternion (in local space) */
  4779. rotationQuaternion: Quaternion;
  4780. /** Gets or sets current scaling (in local space) */
  4781. scaling: Vector3;
  4782. /**
  4783. * Gets the animation properties override
  4784. */
  4785. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4786. private _decompose();
  4787. private _compose();
  4788. /**
  4789. * Update the base and local matrices
  4790. * @param matrix defines the new base or local matrix
  4791. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4792. * @param updateLocalMatrix defines if the local matrix should be updated
  4793. */
  4794. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4795. /** @hidden */
  4796. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4797. /**
  4798. * Flag the bone as dirty (Forcing it to update everything)
  4799. */
  4800. markAsDirty(): void;
  4801. private _markAsDirtyAndCompose();
  4802. private _markAsDirtyAndDecompose();
  4803. /**
  4804. * Copy an animation range from another bone
  4805. * @param source defines the source bone
  4806. * @param rangeName defines the range name to copy
  4807. * @param frameOffset defines the frame offset
  4808. * @param rescaleAsRequired defines if rescaling must be applied if required
  4809. * @param skelDimensionsRatio defines the scaling ratio
  4810. * @returns true if operation was successful
  4811. */
  4812. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4813. /**
  4814. * Translate the bone in local or world space
  4815. * @param vec The amount to translate the bone
  4816. * @param space The space that the translation is in
  4817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4818. */
  4819. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4820. /**
  4821. * Set the postion of the bone in local or world space
  4822. * @param position The position to set the bone
  4823. * @param space The space that the position is in
  4824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4825. */
  4826. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4827. /**
  4828. * Set the absolute position of the bone (world space)
  4829. * @param position The position to set the bone
  4830. * @param mesh The mesh that this bone is attached to
  4831. */
  4832. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4833. /**
  4834. * Scale the bone on the x, y and z axes (in local space)
  4835. * @param x The amount to scale the bone on the x axis
  4836. * @param y The amount to scale the bone on the y axis
  4837. * @param z The amount to scale the bone on the z axis
  4838. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4839. */
  4840. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4841. /**
  4842. * Set the bone scaling in local space
  4843. * @param scale defines the scaling vector
  4844. */
  4845. setScale(scale: Vector3): void;
  4846. /**
  4847. * Gets the current scaling in local space
  4848. * @returns the current scaling vector
  4849. */
  4850. getScale(): Vector3;
  4851. /**
  4852. * Gets the current scaling in local space and stores it in a target vector
  4853. * @param result defines the target vector
  4854. */
  4855. getScaleToRef(result: Vector3): void;
  4856. /**
  4857. * Set the yaw, pitch, and roll of the bone in local or world space
  4858. * @param yaw The rotation of the bone on the y axis
  4859. * @param pitch The rotation of the bone on the x axis
  4860. * @param roll The rotation of the bone on the z axis
  4861. * @param space The space that the axes of rotation are in
  4862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4863. */
  4864. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4865. /**
  4866. * Add a rotation to the bone on an axis in local or world space
  4867. * @param axis The axis to rotate the bone on
  4868. * @param amount The amount to rotate the bone
  4869. * @param space The space that the axis is in
  4870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4871. */
  4872. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4873. /**
  4874. * Set the rotation of the bone to a particular axis angle in local or world space
  4875. * @param axis The axis to rotate the bone on
  4876. * @param angle The angle that the bone should be rotated to
  4877. * @param space The space that the axis is in
  4878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4879. */
  4880. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4881. /**
  4882. * Set the euler rotation of the bone in local of world space
  4883. * @param rotation The euler rotation that the bone should be set to
  4884. * @param space The space that the rotation is in
  4885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4886. */
  4887. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4888. /**
  4889. * Set the quaternion rotation of the bone in local of world space
  4890. * @param quat The quaternion rotation that the bone should be set to
  4891. * @param space The space that the rotation is in
  4892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4893. */
  4894. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4895. /**
  4896. * Set the rotation matrix of the bone in local of world space
  4897. * @param rotMat The rotation matrix that the bone should be set to
  4898. * @param space The space that the rotation is in
  4899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4900. */
  4901. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4902. private _rotateWithMatrix(rmat, space?, mesh?);
  4903. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4904. /**
  4905. * Get the position of the bone in local or world space
  4906. * @param space The space that the returned position is in
  4907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4908. * @returns The position of the bone
  4909. */
  4910. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4911. /**
  4912. * Copy the position of the bone to a vector3 in local or world space
  4913. * @param space The space that the returned position is in
  4914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4915. * @param result The vector3 to copy the position to
  4916. */
  4917. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4918. /**
  4919. * Get the absolute position of the bone (world space)
  4920. * @param mesh The mesh that this bone is attached to
  4921. * @returns The absolute position of the bone
  4922. */
  4923. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4924. /**
  4925. * Copy the absolute position of the bone (world space) to the result param
  4926. * @param mesh The mesh that this bone is attached to
  4927. * @param result The vector3 to copy the absolute position to
  4928. */
  4929. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4930. /**
  4931. * Compute the absolute transforms of this bone and its children
  4932. */
  4933. computeAbsoluteTransforms(): void;
  4934. /**
  4935. * Get the world direction from an axis that is in the local space of the bone
  4936. * @param localAxis The local direction that is used to compute the world direction
  4937. * @param mesh The mesh that this bone is attached to
  4938. * @returns The world direction
  4939. */
  4940. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4941. /**
  4942. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4943. * @param localAxis The local direction that is used to compute the world direction
  4944. * @param mesh The mesh that this bone is attached to
  4945. * @param result The vector3 that the world direction will be copied to
  4946. */
  4947. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4948. /**
  4949. * Get the euler rotation of the bone in local or world space
  4950. * @param space The space that the rotation should be in
  4951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4952. * @returns The euler rotation
  4953. */
  4954. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4955. /**
  4956. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4957. * @param space The space that the rotation should be in
  4958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4959. * @param result The vector3 that the rotation should be copied to
  4960. */
  4961. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4962. /**
  4963. * Get the quaternion rotation of the bone in either local or world space
  4964. * @param space The space that the rotation should be in
  4965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4966. * @returns The quaternion rotation
  4967. */
  4968. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4969. /**
  4970. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4971. * @param space The space that the rotation should be in
  4972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4973. * @param result The quaternion that the rotation should be copied to
  4974. */
  4975. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4976. /**
  4977. * Get the rotation matrix of the bone in local or world space
  4978. * @param space The space that the rotation should be in
  4979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4980. * @returns The rotation matrix
  4981. */
  4982. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4983. /**
  4984. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4985. * @param space The space that the rotation should be in
  4986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4987. * @param result The quaternion that the rotation should be copied to
  4988. */
  4989. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4990. /**
  4991. * Get the world position of a point that is in the local space of the bone
  4992. * @param position The local position
  4993. * @param mesh The mesh that this bone is attached to
  4994. * @returns The world position
  4995. */
  4996. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4997. /**
  4998. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4999. * @param position The local position
  5000. * @param mesh The mesh that this bone is attached to
  5001. * @param result The vector3 that the world position should be copied to
  5002. */
  5003. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5004. /**
  5005. * Get the local position of a point that is in world space
  5006. * @param position The world position
  5007. * @param mesh The mesh that this bone is attached to
  5008. * @returns The local position
  5009. */
  5010. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5011. /**
  5012. * Get the local position of a point that is in world space and copy it to the result param
  5013. * @param position The world position
  5014. * @param mesh The mesh that this bone is attached to
  5015. * @param result The vector3 that the local position should be copied to
  5016. */
  5017. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5018. }
  5019. }
  5020. declare module BABYLON {
  5021. /**
  5022. * Class used to apply inverse kinematics to bones
  5023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5024. */
  5025. class BoneIKController {
  5026. private static _tmpVecs;
  5027. private static _tmpQuat;
  5028. private static _tmpMats;
  5029. /**
  5030. * Gets or sets the target mesh
  5031. */
  5032. targetMesh: AbstractMesh;
  5033. /** Gets or sets the mesh used as pole */
  5034. poleTargetMesh: AbstractMesh;
  5035. /**
  5036. * Gets or sets the bone used as pole
  5037. */
  5038. poleTargetBone: Nullable<Bone>;
  5039. /**
  5040. * Gets or sets the target position
  5041. */
  5042. targetPosition: Vector3;
  5043. /**
  5044. * Gets or sets the pole target position
  5045. */
  5046. poleTargetPosition: Vector3;
  5047. /**
  5048. * Gets or sets the pole target local offset
  5049. */
  5050. poleTargetLocalOffset: Vector3;
  5051. /**
  5052. * Gets or sets the pole angle
  5053. */
  5054. poleAngle: number;
  5055. /**
  5056. * Gets or sets the mesh associated with the controller
  5057. */
  5058. mesh: AbstractMesh;
  5059. /**
  5060. * 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)
  5061. */
  5062. slerpAmount: number;
  5063. private _bone1Quat;
  5064. private _bone1Mat;
  5065. private _bone2Ang;
  5066. private _bone1;
  5067. private _bone2;
  5068. private _bone1Length;
  5069. private _bone2Length;
  5070. private _maxAngle;
  5071. private _maxReach;
  5072. private _rightHandedSystem;
  5073. private _bendAxis;
  5074. private _slerping;
  5075. private _adjustRoll;
  5076. /**
  5077. * Gets or sets maximum allowed angle
  5078. */
  5079. maxAngle: number;
  5080. /**
  5081. * Creates a new BoneIKController
  5082. * @param mesh defines the mesh to control
  5083. * @param bone defines the bone to control
  5084. * @param options defines options to set up the controller
  5085. */
  5086. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5087. targetMesh?: AbstractMesh;
  5088. poleTargetMesh?: AbstractMesh;
  5089. poleTargetBone?: Bone;
  5090. poleTargetLocalOffset?: Vector3;
  5091. poleAngle?: number;
  5092. bendAxis?: Vector3;
  5093. maxAngle?: number;
  5094. slerpAmount?: number;
  5095. });
  5096. private _setMaxAngle(ang);
  5097. /**
  5098. * Force the controller to update the bones
  5099. */
  5100. update(): void;
  5101. }
  5102. }
  5103. declare module BABYLON {
  5104. /**
  5105. * Class used to make a bone look toward a point in space
  5106. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5107. */
  5108. class BoneLookController {
  5109. private static _tmpVecs;
  5110. private static _tmpQuat;
  5111. private static _tmpMats;
  5112. /**
  5113. * The target Vector3 that the bone will look at
  5114. */
  5115. target: Vector3;
  5116. /**
  5117. * The mesh that the bone is attached to
  5118. */
  5119. mesh: AbstractMesh;
  5120. /**
  5121. * The bone that will be looking to the target
  5122. */
  5123. bone: Bone;
  5124. /**
  5125. * The up axis of the coordinate system that is used when the bone is rotated
  5126. */
  5127. upAxis: Vector3;
  5128. /**
  5129. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5130. */
  5131. upAxisSpace: Space;
  5132. /**
  5133. * Used to make an adjustment to the yaw of the bone
  5134. */
  5135. adjustYaw: number;
  5136. /**
  5137. * Used to make an adjustment to the pitch of the bone
  5138. */
  5139. adjustPitch: number;
  5140. /**
  5141. * Used to make an adjustment to the roll of the bone
  5142. */
  5143. adjustRoll: number;
  5144. /**
  5145. * 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)
  5146. */
  5147. slerpAmount: number;
  5148. private _minYaw;
  5149. private _maxYaw;
  5150. private _minPitch;
  5151. private _maxPitch;
  5152. private _minYawSin;
  5153. private _minYawCos;
  5154. private _maxYawSin;
  5155. private _maxYawCos;
  5156. private _midYawConstraint;
  5157. private _minPitchTan;
  5158. private _maxPitchTan;
  5159. private _boneQuat;
  5160. private _slerping;
  5161. private _transformYawPitch;
  5162. private _transformYawPitchInv;
  5163. private _firstFrameSkipped;
  5164. private _yawRange;
  5165. private _fowardAxis;
  5166. /**
  5167. * Gets or sets the minimum yaw angle that the bone can look to
  5168. */
  5169. minYaw: number;
  5170. /**
  5171. * Gets or sets the maximum yaw angle that the bone can look to
  5172. */
  5173. maxYaw: number;
  5174. /**
  5175. * Gets or sets the minimum pitch angle that the bone can look to
  5176. */
  5177. minPitch: number;
  5178. /**
  5179. * Gets or sets the maximum pitch angle that the bone can look to
  5180. */
  5181. maxPitch: number;
  5182. /**
  5183. * Create a BoneLookController
  5184. * @param mesh the mesh that the bone belongs to
  5185. * @param bone the bone that will be looking to the target
  5186. * @param target the target Vector3 to look at
  5187. * @param settings optional settings:
  5188. * * maxYaw: the maximum angle the bone will yaw to
  5189. * * minYaw: the minimum angle the bone will yaw to
  5190. * * maxPitch: the maximum angle the bone will pitch to
  5191. * * minPitch: the minimum angle the bone will yaw to
  5192. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5193. * * upAxis: the up axis of the coordinate system
  5194. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5195. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5196. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5197. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5198. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5199. * * adjustRoll: used to make an adjustment to the roll of the bone
  5200. **/
  5201. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5202. maxYaw?: number;
  5203. minYaw?: number;
  5204. maxPitch?: number;
  5205. minPitch?: number;
  5206. slerpAmount?: number;
  5207. upAxis?: Vector3;
  5208. upAxisSpace?: Space;
  5209. yawAxis?: Vector3;
  5210. pitchAxis?: Vector3;
  5211. adjustYaw?: number;
  5212. adjustPitch?: number;
  5213. adjustRoll?: number;
  5214. });
  5215. /**
  5216. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5217. */
  5218. update(): void;
  5219. private _getAngleDiff(ang1, ang2);
  5220. private _getAngleBetween(ang1, ang2);
  5221. private _isAngleBetween(ang, ang1, ang2);
  5222. }
  5223. }
  5224. declare module BABYLON {
  5225. /**
  5226. * Class used to handle skinning animations
  5227. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5228. */
  5229. class Skeleton implements IAnimatable {
  5230. /** defines the skeleton name */
  5231. name: string;
  5232. /** defines the skeleton Id */
  5233. id: string;
  5234. /**
  5235. * Gets the list of child bones
  5236. */
  5237. bones: Bone[];
  5238. /**
  5239. * Gets an estimate of the dimension of the skeleton at rest
  5240. */
  5241. dimensionsAtRest: Vector3;
  5242. /**
  5243. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5244. */
  5245. needInitialSkinMatrix: boolean;
  5246. /**
  5247. * Gets the list of animations attached to this skeleton
  5248. */
  5249. animations: Array<Animation>;
  5250. private _scene;
  5251. private _isDirty;
  5252. private _transformMatrices;
  5253. private _meshesWithPoseMatrix;
  5254. private _animatables;
  5255. private _identity;
  5256. private _synchronizedWithMesh;
  5257. private _ranges;
  5258. private _lastAbsoluteTransformsUpdateId;
  5259. /**
  5260. * Specifies if the skeleton should be serialized
  5261. */
  5262. doNotSerialize: boolean;
  5263. private _animationPropertiesOverride;
  5264. /**
  5265. * Gets or sets the animation properties override
  5266. */
  5267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5268. /**
  5269. * An observable triggered before computing the skeleton's matrices
  5270. */
  5271. onBeforeComputeObservable: Observable<Skeleton>;
  5272. /**
  5273. * Creates a new skeleton
  5274. * @param name defines the skeleton name
  5275. * @param id defines the skeleton Id
  5276. * @param scene defines the hosting scene
  5277. */
  5278. constructor(
  5279. /** defines the skeleton name */
  5280. name: string,
  5281. /** defines the skeleton Id */
  5282. id: string, scene: Scene);
  5283. /**
  5284. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5285. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5286. * @returns a Float32Array containing matrices data
  5287. */
  5288. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5289. /**
  5290. * Gets the current hosting scene
  5291. * @returns a scene object
  5292. */
  5293. getScene(): Scene;
  5294. /**
  5295. * Gets a string representing the current skeleton data
  5296. * @param fullDetails defines a boolean indicating if we want a verbose version
  5297. * @returns a string representing the current skeleton data
  5298. */
  5299. toString(fullDetails?: boolean): string;
  5300. /**
  5301. * Get bone's index searching by name
  5302. * @param name defines bone's name to search for
  5303. * @return the indice of the bone. Returns -1 if not found
  5304. */
  5305. getBoneIndexByName(name: string): number;
  5306. /**
  5307. * Creater a new animation range
  5308. * @param name defines the name of the range
  5309. * @param from defines the start key
  5310. * @param to defines the end key
  5311. */
  5312. createAnimationRange(name: string, from: number, to: number): void;
  5313. /**
  5314. * Delete a specific animation range
  5315. * @param name defines the name of the range
  5316. * @param deleteFrames defines if frames must be removed as well
  5317. */
  5318. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5319. /**
  5320. * Gets a specific animation range
  5321. * @param name defines the name of the range to look for
  5322. * @returns the requested animation range or null if not found
  5323. */
  5324. getAnimationRange(name: string): Nullable<AnimationRange>;
  5325. /**
  5326. * Gets the list of all animation ranges defined on this skeleton
  5327. * @returns an array
  5328. */
  5329. getAnimationRanges(): Nullable<AnimationRange>[];
  5330. /**
  5331. * Copy animation range from a source skeleton.
  5332. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5333. * @param source defines the source skeleton
  5334. * @param name defines the name of the range to copy
  5335. * @param rescaleAsRequired defines if rescaling must be applied if required
  5336. * @returns true if operation was successful
  5337. */
  5338. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5339. /**
  5340. * Forces the skeleton to go to rest pose
  5341. */
  5342. returnToRest(): void;
  5343. private _getHighestAnimationFrame();
  5344. /**
  5345. * Begin a specific animation range
  5346. * @param name defines the name of the range to start
  5347. * @param loop defines if looping must be turned on (false by default)
  5348. * @param speedRatio defines the speed ratio to apply (1 by default)
  5349. * @param onAnimationEnd defines a callback which will be called when animation will end
  5350. * @returns a new animatable
  5351. */
  5352. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5353. /** @hidden */
  5354. _markAsDirty(): void;
  5355. /** @hidden */
  5356. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5357. /** @hidden */
  5358. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5359. /** @hidden */
  5360. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5361. /**
  5362. * Build all resources required to render a skeleton
  5363. */
  5364. prepare(): void;
  5365. /**
  5366. * Gets the list of animatables currently running for this skeleton
  5367. * @returns an array of animatables
  5368. */
  5369. getAnimatables(): IAnimatable[];
  5370. /**
  5371. * Clone the current skeleton
  5372. * @param name defines the name of the new skeleton
  5373. * @param id defines the id of the enw skeleton
  5374. * @returns the new skeleton
  5375. */
  5376. clone(name: string, id: string): Skeleton;
  5377. /**
  5378. * Enable animation blending for this skeleton
  5379. * @param blendingSpeed defines the blending speed to apply
  5380. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5381. */
  5382. enableBlending(blendingSpeed?: number): void;
  5383. /**
  5384. * Releases all resources associated with the current skeleton
  5385. */
  5386. dispose(): void;
  5387. /**
  5388. * Serialize the skeleton in a JSON object
  5389. * @returns a JSON object
  5390. */
  5391. serialize(): any;
  5392. /**
  5393. * Creates a new skeleton from serialized data
  5394. * @param parsedSkeleton defines the serialized data
  5395. * @param scene defines the hosting scene
  5396. * @returns a new skeleton
  5397. */
  5398. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5399. /**
  5400. * Compute all node absolute transforms
  5401. * @param forceUpdate defines if computation must be done even if cache is up to date
  5402. */
  5403. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5404. /**
  5405. * Gets the root pose matrix
  5406. * @returns a matrix
  5407. */
  5408. getPoseMatrix(): Nullable<Matrix>;
  5409. /**
  5410. * Sorts bones per internal index
  5411. */
  5412. sortBones(): void;
  5413. private _sortBones(index, bones, visited);
  5414. }
  5415. }
  5416. declare module BABYLON {
  5417. class Collider {
  5418. /** Define if a collision was found */
  5419. collisionFound: boolean;
  5420. /**
  5421. * Define last intersection point in local space
  5422. */
  5423. intersectionPoint: Vector3;
  5424. /**
  5425. * Define last collided mesh
  5426. */
  5427. collidedMesh: Nullable<AbstractMesh>;
  5428. private _collisionPoint;
  5429. private _planeIntersectionPoint;
  5430. private _tempVector;
  5431. private _tempVector2;
  5432. private _tempVector3;
  5433. private _tempVector4;
  5434. private _edge;
  5435. private _baseToVertex;
  5436. private _destinationPoint;
  5437. private _slidePlaneNormal;
  5438. private _displacementVector;
  5439. _radius: Vector3;
  5440. _retry: number;
  5441. private _velocity;
  5442. private _basePoint;
  5443. private _epsilon;
  5444. _velocityWorldLength: number;
  5445. _basePointWorld: Vector3;
  5446. private _velocityWorld;
  5447. private _normalizedVelocity;
  5448. _initialVelocity: Vector3;
  5449. _initialPosition: Vector3;
  5450. private _nearestDistance;
  5451. private _collisionMask;
  5452. collisionMask: number;
  5453. /**
  5454. * Gets the plane normal used to compute the sliding response (in local space)
  5455. */
  5456. readonly slidePlaneNormal: Vector3;
  5457. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5458. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5459. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5460. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5461. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5462. _getResponse(pos: Vector3, vel: Vector3): void;
  5463. }
  5464. }
  5465. declare module BABYLON {
  5466. var CollisionWorker: string;
  5467. interface ICollisionCoordinator {
  5468. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5469. init(scene: Scene): void;
  5470. destroy(): void;
  5471. onMeshAdded(mesh: AbstractMesh): void;
  5472. onMeshUpdated(mesh: AbstractMesh): void;
  5473. onMeshRemoved(mesh: AbstractMesh): void;
  5474. onGeometryAdded(geometry: Geometry): void;
  5475. onGeometryUpdated(geometry: Geometry): void;
  5476. onGeometryDeleted(geometry: Geometry): void;
  5477. }
  5478. interface SerializedMesh {
  5479. id: string;
  5480. name: string;
  5481. uniqueId: number;
  5482. geometryId: Nullable<string>;
  5483. sphereCenter: Array<number>;
  5484. sphereRadius: number;
  5485. boxMinimum: Array<number>;
  5486. boxMaximum: Array<number>;
  5487. worldMatrixFromCache: any;
  5488. subMeshes: Array<SerializedSubMesh>;
  5489. checkCollisions: boolean;
  5490. }
  5491. interface SerializedSubMesh {
  5492. position: number;
  5493. verticesStart: number;
  5494. verticesCount: number;
  5495. indexStart: number;
  5496. indexCount: number;
  5497. hasMaterial: boolean;
  5498. sphereCenter: Array<number>;
  5499. sphereRadius: number;
  5500. boxMinimum: Array<number>;
  5501. boxMaximum: Array<number>;
  5502. }
  5503. /**
  5504. * Interface describing the value associated with a geometry
  5505. */
  5506. interface SerializedGeometry {
  5507. /**
  5508. * Defines the unique ID of the geometry
  5509. */
  5510. id: string;
  5511. /**
  5512. * Defines the array containing the positions
  5513. */
  5514. positions: Float32Array;
  5515. /**
  5516. * Defines the array containing the indices
  5517. */
  5518. indices: Uint32Array;
  5519. /**
  5520. * Defines the array containing the normals
  5521. */
  5522. normals: Float32Array;
  5523. }
  5524. interface BabylonMessage {
  5525. taskType: WorkerTaskType;
  5526. payload: InitPayload | CollidePayload | UpdatePayload;
  5527. }
  5528. interface SerializedColliderToWorker {
  5529. position: Array<number>;
  5530. velocity: Array<number>;
  5531. radius: Array<number>;
  5532. }
  5533. /** Defines supported task for worker process */
  5534. enum WorkerTaskType {
  5535. /** Initialization */
  5536. INIT = 0,
  5537. /** Update of geometry */
  5538. UPDATE = 1,
  5539. /** Evaluate collision */
  5540. COLLIDE = 2,
  5541. }
  5542. interface WorkerReply {
  5543. error: WorkerReplyType;
  5544. taskType: WorkerTaskType;
  5545. payload?: any;
  5546. }
  5547. interface CollisionReplyPayload {
  5548. newPosition: Array<number>;
  5549. collisionId: number;
  5550. collidedMeshUniqueId: number;
  5551. }
  5552. interface InitPayload {
  5553. }
  5554. interface CollidePayload {
  5555. collisionId: number;
  5556. collider: SerializedColliderToWorker;
  5557. maximumRetry: number;
  5558. excludedMeshUniqueId: Nullable<number>;
  5559. }
  5560. interface UpdatePayload {
  5561. updatedMeshes: {
  5562. [n: number]: SerializedMesh;
  5563. };
  5564. updatedGeometries: {
  5565. [s: string]: SerializedGeometry;
  5566. };
  5567. removedMeshes: Array<number>;
  5568. removedGeometries: Array<string>;
  5569. }
  5570. /** Defines kind of replies returned by worker */
  5571. enum WorkerReplyType {
  5572. /** Success */
  5573. SUCCESS = 0,
  5574. /** Unkown error */
  5575. UNKNOWN_ERROR = 1,
  5576. }
  5577. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5578. private _scene;
  5579. private _scaledPosition;
  5580. private _scaledVelocity;
  5581. private _collisionsCallbackArray;
  5582. private _init;
  5583. private _runningUpdated;
  5584. private _worker;
  5585. private _addUpdateMeshesList;
  5586. private _addUpdateGeometriesList;
  5587. private _toRemoveMeshesArray;
  5588. private _toRemoveGeometryArray;
  5589. constructor();
  5590. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5591. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5592. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5593. init(scene: Scene): void;
  5594. destroy(): void;
  5595. onMeshAdded(mesh: AbstractMesh): void;
  5596. onMeshUpdated: (transformNode: TransformNode) => void;
  5597. onMeshRemoved(mesh: AbstractMesh): void;
  5598. onGeometryAdded(geometry: Geometry): void;
  5599. onGeometryUpdated: (geometry: Geometry) => void;
  5600. onGeometryDeleted(geometry: Geometry): void;
  5601. private _afterRender;
  5602. private _onMessageFromWorker;
  5603. }
  5604. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5605. private _scene;
  5606. private _scaledPosition;
  5607. private _scaledVelocity;
  5608. private _finalPosition;
  5609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5610. init(scene: Scene): void;
  5611. destroy(): void;
  5612. onMeshAdded(mesh: AbstractMesh): void;
  5613. onMeshUpdated(mesh: AbstractMesh): void;
  5614. onMeshRemoved(mesh: AbstractMesh): void;
  5615. onGeometryAdded(geometry: Geometry): void;
  5616. onGeometryUpdated(geometry: Geometry): void;
  5617. onGeometryDeleted(geometry: Geometry): void;
  5618. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5619. }
  5620. }
  5621. declare function importScripts(...urls: string[]): void;
  5622. declare const safePostMessage: any;
  5623. declare module BABYLON {
  5624. var WorkerIncluded: boolean;
  5625. class CollisionCache {
  5626. private _meshes;
  5627. private _geometries;
  5628. getMeshes(): {
  5629. [n: number]: SerializedMesh;
  5630. };
  5631. getGeometries(): {
  5632. [s: number]: SerializedGeometry;
  5633. };
  5634. getMesh(id: any): SerializedMesh;
  5635. addMesh(mesh: SerializedMesh): void;
  5636. removeMesh(uniqueId: number): void;
  5637. getGeometry(id: string): SerializedGeometry;
  5638. addGeometry(geometry: SerializedGeometry): void;
  5639. removeGeometry(id: string): void;
  5640. }
  5641. class CollideWorker {
  5642. collider: Collider;
  5643. private _collisionCache;
  5644. private finalPosition;
  5645. private collisionsScalingMatrix;
  5646. private collisionTranformationMatrix;
  5647. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5648. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5649. private checkCollision(mesh);
  5650. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5651. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5652. private checkSubmeshCollision(subMesh);
  5653. }
  5654. interface ICollisionDetector {
  5655. onInit(payload: InitPayload): void;
  5656. onUpdate(payload: UpdatePayload): void;
  5657. onCollision(payload: CollidePayload): void;
  5658. }
  5659. class CollisionDetectorTransferable implements ICollisionDetector {
  5660. private _collisionCache;
  5661. onInit(payload: InitPayload): void;
  5662. onUpdate(payload: UpdatePayload): void;
  5663. onCollision(payload: CollidePayload): void;
  5664. }
  5665. }
  5666. declare module BABYLON {
  5667. class IntersectionInfo {
  5668. bu: Nullable<number>;
  5669. bv: Nullable<number>;
  5670. distance: number;
  5671. faceId: number;
  5672. subMeshId: number;
  5673. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5674. }
  5675. /**
  5676. * Information about the result of picking within a scene
  5677. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5678. */
  5679. class PickingInfo {
  5680. /**
  5681. * If the pick collided with an object
  5682. */
  5683. hit: boolean;
  5684. /**
  5685. * Distance away where the pick collided
  5686. */
  5687. distance: number;
  5688. /**
  5689. * The location of pick collision
  5690. */
  5691. pickedPoint: Nullable<Vector3>;
  5692. /**
  5693. * The mesh corrisponding the the pick collision
  5694. */
  5695. pickedMesh: Nullable<AbstractMesh>;
  5696. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5697. bu: number;
  5698. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5699. bv: number;
  5700. /** The id of the face on the mesh that was picked */
  5701. faceId: number;
  5702. /** Id of the the submesh that was picked */
  5703. subMeshId: number;
  5704. /** If a sprite was picked, this will be the sprite the pick collided with */
  5705. pickedSprite: Nullable<Sprite>;
  5706. /**
  5707. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5708. */
  5709. originMesh: Nullable<AbstractMesh>;
  5710. /**
  5711. * The ray that was used to perform the picking.
  5712. */
  5713. ray: Nullable<Ray>;
  5714. /**
  5715. * Gets the normal corrispodning to the face the pick collided with
  5716. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5717. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5718. * @returns The normal corrispodning to the face the pick collided with
  5719. */
  5720. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5721. /**
  5722. * Gets the texture coordinates of where the pick occured
  5723. * @returns the vector containing the coordnates of the texture
  5724. */
  5725. getTextureCoordinates(): Nullable<Vector2>;
  5726. }
  5727. }
  5728. declare module BABYLON {
  5729. class ArcRotateCamera extends TargetCamera {
  5730. alpha: number;
  5731. beta: number;
  5732. radius: number;
  5733. protected _target: Vector3;
  5734. protected _targetHost: Nullable<AbstractMesh>;
  5735. target: Vector3;
  5736. inertialAlphaOffset: number;
  5737. inertialBetaOffset: number;
  5738. inertialRadiusOffset: number;
  5739. lowerAlphaLimit: Nullable<number>;
  5740. upperAlphaLimit: Nullable<number>;
  5741. lowerBetaLimit: number;
  5742. upperBetaLimit: number;
  5743. lowerRadiusLimit: Nullable<number>;
  5744. upperRadiusLimit: Nullable<number>;
  5745. inertialPanningX: number;
  5746. inertialPanningY: number;
  5747. pinchToPanMaxDistance: number;
  5748. panningDistanceLimit: Nullable<number>;
  5749. panningOriginTarget: Vector3;
  5750. panningInertia: number;
  5751. angularSensibilityX: number;
  5752. angularSensibilityY: number;
  5753. pinchPrecision: number;
  5754. pinchDeltaPercentage: number;
  5755. panningSensibility: number;
  5756. keysUp: number[];
  5757. keysDown: number[];
  5758. keysLeft: number[];
  5759. keysRight: number[];
  5760. wheelPrecision: number;
  5761. wheelDeltaPercentage: number;
  5762. zoomOnFactor: number;
  5763. targetScreenOffset: Vector2;
  5764. allowUpsideDown: boolean;
  5765. _viewMatrix: Matrix;
  5766. _useCtrlForPanning: boolean;
  5767. _panningMouseButton: number;
  5768. inputs: ArcRotateCameraInputsManager;
  5769. _reset: () => void;
  5770. panningAxis: Vector3;
  5771. protected _localDirection: Vector3;
  5772. protected _transformedDirection: Vector3;
  5773. private _bouncingBehavior;
  5774. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5775. useBouncingBehavior: boolean;
  5776. private _framingBehavior;
  5777. readonly framingBehavior: Nullable<FramingBehavior>;
  5778. useFramingBehavior: boolean;
  5779. private _autoRotationBehavior;
  5780. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5781. useAutoRotationBehavior: boolean;
  5782. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5783. onCollide: (collidedMesh: AbstractMesh) => void;
  5784. checkCollisions: boolean;
  5785. collisionRadius: Vector3;
  5786. protected _collider: Collider;
  5787. protected _previousPosition: Vector3;
  5788. protected _collisionVelocity: Vector3;
  5789. protected _newPosition: Vector3;
  5790. protected _previousAlpha: number;
  5791. protected _previousBeta: number;
  5792. protected _previousRadius: number;
  5793. protected _collisionTriggered: boolean;
  5794. protected _targetBoundingCenter: Nullable<Vector3>;
  5795. private _computationVector;
  5796. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5797. _initCache(): void;
  5798. _updateCache(ignoreParentClass?: boolean): void;
  5799. protected _getTargetPosition(): Vector3;
  5800. /**
  5801. * Store current camera state (fov, position, etc..)
  5802. */
  5803. private _storedAlpha;
  5804. private _storedBeta;
  5805. private _storedRadius;
  5806. private _storedTarget;
  5807. storeState(): Camera;
  5808. /**
  5809. * Restored camera state. You must call storeState() first
  5810. */
  5811. _restoreStateValues(): boolean;
  5812. _isSynchronizedViewMatrix(): boolean;
  5813. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5814. detachControl(element: HTMLElement): void;
  5815. _checkInputs(): void;
  5816. protected _checkLimits(): void;
  5817. rebuildAnglesAndRadius(): void;
  5818. setPosition(position: Vector3): void;
  5819. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5820. _getViewMatrix(): Matrix;
  5821. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5822. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5823. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5824. min: Vector3;
  5825. max: Vector3;
  5826. distance: number;
  5827. }, doNotUpdateMaxZ?: boolean): void;
  5828. /**
  5829. * @override
  5830. * Override Camera.createRigCamera
  5831. */
  5832. createRigCamera(name: string, cameraIndex: number): Camera;
  5833. /**
  5834. * @override
  5835. * Override Camera._updateRigCameras
  5836. */
  5837. _updateRigCameras(): void;
  5838. dispose(): void;
  5839. getClassName(): string;
  5840. }
  5841. }
  5842. declare module BABYLON {
  5843. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5844. constructor(camera: ArcRotateCamera);
  5845. addMouseWheel(): ArcRotateCameraInputsManager;
  5846. addPointers(): ArcRotateCameraInputsManager;
  5847. addKeyboard(): ArcRotateCameraInputsManager;
  5848. addGamepad(): ArcRotateCameraInputsManager;
  5849. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5850. }
  5851. }
  5852. declare module BABYLON {
  5853. class Camera extends Node {
  5854. inputs: CameraInputsManager<Camera>;
  5855. private static _PERSPECTIVE_CAMERA;
  5856. private static _ORTHOGRAPHIC_CAMERA;
  5857. private static _FOVMODE_VERTICAL_FIXED;
  5858. private static _FOVMODE_HORIZONTAL_FIXED;
  5859. private static _RIG_MODE_NONE;
  5860. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5861. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5862. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5863. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5864. private static _RIG_MODE_VR;
  5865. private static _RIG_MODE_WEBVR;
  5866. static readonly PERSPECTIVE_CAMERA: number;
  5867. static readonly ORTHOGRAPHIC_CAMERA: number;
  5868. /**
  5869. * This is the default FOV mode for perspective cameras.
  5870. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5871. *
  5872. */
  5873. static readonly FOVMODE_VERTICAL_FIXED: number;
  5874. /**
  5875. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5876. *
  5877. */
  5878. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5879. static readonly RIG_MODE_NONE: number;
  5880. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5881. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5882. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5883. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5884. static readonly RIG_MODE_VR: number;
  5885. static readonly RIG_MODE_WEBVR: number;
  5886. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5887. static UseAlternateWebVRRendering: boolean;
  5888. position: Vector3;
  5889. /**
  5890. * The vector the camera should consider as up.
  5891. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5892. */
  5893. upVector: Vector3;
  5894. orthoLeft: Nullable<number>;
  5895. orthoRight: Nullable<number>;
  5896. orthoBottom: Nullable<number>;
  5897. orthoTop: Nullable<number>;
  5898. /**
  5899. * FOV is set in Radians. (default is 0.8)
  5900. */
  5901. fov: number;
  5902. minZ: number;
  5903. maxZ: number;
  5904. inertia: number;
  5905. mode: number;
  5906. isIntermediate: boolean;
  5907. viewport: Viewport;
  5908. /**
  5909. * Restricts the camera to viewing objects with the same layerMask.
  5910. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5911. */
  5912. layerMask: number;
  5913. /**
  5914. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5915. */
  5916. fovMode: number;
  5917. cameraRigMode: number;
  5918. interaxialDistance: number;
  5919. isStereoscopicSideBySide: boolean;
  5920. _cameraRigParams: any;
  5921. _rigCameras: Camera[];
  5922. _rigPostProcess: Nullable<PostProcess>;
  5923. protected _webvrViewMatrix: Matrix;
  5924. _skipRendering: boolean;
  5925. _alternateCamera: Camera;
  5926. customRenderTargets: RenderTargetTexture[];
  5927. onViewMatrixChangedObservable: Observable<Camera>;
  5928. onProjectionMatrixChangedObservable: Observable<Camera>;
  5929. onAfterCheckInputsObservable: Observable<Camera>;
  5930. onRestoreStateObservable: Observable<Camera>;
  5931. private _computedViewMatrix;
  5932. _projectionMatrix: Matrix;
  5933. private _doNotComputeProjectionMatrix;
  5934. private _worldMatrix;
  5935. _postProcesses: Nullable<PostProcess>[];
  5936. private _transformMatrix;
  5937. _activeMeshes: SmartArray<AbstractMesh>;
  5938. protected _globalPosition: Vector3;
  5939. private _frustumPlanes;
  5940. private _refreshFrustumPlanes;
  5941. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5942. private _storedFov;
  5943. private _stateStored;
  5944. /**
  5945. * Store current camera state (fov, position, etc..)
  5946. */
  5947. storeState(): Camera;
  5948. /**
  5949. * Restores the camera state values if it has been stored. You must call storeState() first
  5950. */
  5951. protected _restoreStateValues(): boolean;
  5952. /**
  5953. * Restored camera state. You must call storeState() first
  5954. */
  5955. restoreState(): boolean;
  5956. getClassName(): string;
  5957. /**
  5958. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5959. */
  5960. toString(fullDetails?: boolean): string;
  5961. readonly globalPosition: Vector3;
  5962. getActiveMeshes(): SmartArray<AbstractMesh>;
  5963. isActiveMesh(mesh: Mesh): boolean;
  5964. /**
  5965. * Is this camera ready to be used/rendered
  5966. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5967. * @return true if the camera is ready
  5968. */
  5969. isReady(completeCheck?: boolean): boolean;
  5970. _initCache(): void;
  5971. _updateCache(ignoreParentClass?: boolean): void;
  5972. _isSynchronized(): boolean;
  5973. _isSynchronizedViewMatrix(): boolean;
  5974. _isSynchronizedProjectionMatrix(): boolean;
  5975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5976. detachControl(element: HTMLElement): void;
  5977. update(): void;
  5978. _checkInputs(): void;
  5979. readonly rigCameras: Camera[];
  5980. readonly rigPostProcess: Nullable<PostProcess>;
  5981. /**
  5982. * Internal, gets the first post proces.
  5983. * @returns the first post process to be run on this camera.
  5984. */
  5985. _getFirstPostProcess(): Nullable<PostProcess>;
  5986. private _cascadePostProcessesToRigCams();
  5987. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5988. detachPostProcess(postProcess: PostProcess): void;
  5989. getWorldMatrix(): Matrix;
  5990. _getViewMatrix(): Matrix;
  5991. getViewMatrix(force?: boolean): Matrix;
  5992. freezeProjectionMatrix(projection?: Matrix): void;
  5993. unfreezeProjectionMatrix(): void;
  5994. getProjectionMatrix(force?: boolean): Matrix;
  5995. getTranformationMatrix(): Matrix;
  5996. private updateFrustumPlanes();
  5997. isInFrustum(target: ICullable): boolean;
  5998. isCompletelyInFrustum(target: ICullable): boolean;
  5999. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6000. /**
  6001. * Releases resources associated with this node.
  6002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6004. */
  6005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6006. readonly leftCamera: Nullable<FreeCamera>;
  6007. readonly rightCamera: Nullable<FreeCamera>;
  6008. getLeftTarget(): Nullable<Vector3>;
  6009. getRightTarget(): Nullable<Vector3>;
  6010. setCameraRigMode(mode: number, rigParams: any): void;
  6011. private _getVRProjectionMatrix();
  6012. protected _updateCameraRotationMatrix(): void;
  6013. protected _updateWebVRCameraRotationMatrix(): void;
  6014. /**
  6015. * This function MUST be overwritten by the different WebVR cameras available.
  6016. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6017. */
  6018. protected _getWebVRProjectionMatrix(): Matrix;
  6019. /**
  6020. * This function MUST be overwritten by the different WebVR cameras available.
  6021. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6022. */
  6023. protected _getWebVRViewMatrix(): Matrix;
  6024. setCameraRigParameter(name: string, value: any): void;
  6025. /**
  6026. * needs to be overridden by children so sub has required properties to be copied
  6027. */
  6028. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6029. /**
  6030. * May need to be overridden by children
  6031. */
  6032. _updateRigCameras(): void;
  6033. _setupInputs(): void;
  6034. serialize(): any;
  6035. clone(name: string): Camera;
  6036. getDirection(localAxis: Vector3): Vector3;
  6037. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6038. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6039. computeWorldMatrix(): Matrix;
  6040. static Parse(parsedCamera: any, scene: Scene): Camera;
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. var CameraInputTypes: {};
  6045. interface ICameraInput<TCamera extends Camera> {
  6046. camera: Nullable<TCamera>;
  6047. getClassName(): string;
  6048. getSimpleName(): string;
  6049. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6050. detachControl: (element: Nullable<HTMLElement>) => void;
  6051. checkInputs?: () => void;
  6052. }
  6053. interface CameraInputsMap<TCamera extends Camera> {
  6054. [name: string]: ICameraInput<TCamera>;
  6055. [idx: number]: ICameraInput<TCamera>;
  6056. }
  6057. class CameraInputsManager<TCamera extends Camera> {
  6058. attached: CameraInputsMap<TCamera>;
  6059. attachedElement: Nullable<HTMLElement>;
  6060. noPreventDefault: boolean;
  6061. camera: TCamera;
  6062. checkInputs: () => void;
  6063. constructor(camera: TCamera);
  6064. /**
  6065. * Add an input method to a camera.
  6066. * builtin inputs example: camera.inputs.addGamepad();
  6067. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6068. * @param input camera input method
  6069. */
  6070. add(input: ICameraInput<TCamera>): void;
  6071. /**
  6072. * Remove a specific input method from a camera
  6073. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6074. * @param inputToRemove camera input method
  6075. */
  6076. remove(inputToRemove: ICameraInput<TCamera>): void;
  6077. removeByType(inputType: string): void;
  6078. private _addCheckInputs(fn);
  6079. attachInput(input: ICameraInput<TCamera>): void;
  6080. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6081. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6082. rebuildInputCheck(): void;
  6083. /**
  6084. * Remove all attached input methods from a camera
  6085. */
  6086. clear(): void;
  6087. serialize(serializedCamera: any): void;
  6088. parse(parsedCamera: any): void;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. /**
  6093. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6094. * being tilted forward or back and left or right.
  6095. */
  6096. class DeviceOrientationCamera extends FreeCamera {
  6097. private _initialQuaternion;
  6098. private _quaternionCache;
  6099. /**
  6100. * Creates a new device orientation camera
  6101. * @param name The name of the camera
  6102. * @param position The start position camera
  6103. * @param scene The scene the camera belongs to
  6104. */
  6105. constructor(name: string, position: Vector3, scene: Scene);
  6106. /**
  6107. * Gets the current instance class name ("DeviceOrientationCamera").
  6108. * This helps avoiding instanceof at run time.
  6109. * @returns the class name
  6110. */
  6111. getClassName(): string;
  6112. /**
  6113. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6114. */
  6115. _checkInputs(): void;
  6116. /**
  6117. * Reset the camera to its default orientation on the specified axis only.
  6118. * @param axis The axis to reset
  6119. */
  6120. resetToCurrentRotation(axis?: Axis): void;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. class FollowCamera extends TargetCamera {
  6125. radius: number;
  6126. rotationOffset: number;
  6127. heightOffset: number;
  6128. cameraAcceleration: number;
  6129. maxCameraSpeed: number;
  6130. lockedTarget: Nullable<AbstractMesh>;
  6131. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6132. private getRadians(degrees);
  6133. private follow(cameraTarget);
  6134. _checkInputs(): void;
  6135. getClassName(): string;
  6136. }
  6137. class ArcFollowCamera extends TargetCamera {
  6138. alpha: number;
  6139. beta: number;
  6140. radius: number;
  6141. target: Nullable<AbstractMesh>;
  6142. private _cartesianCoordinates;
  6143. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6144. private follow();
  6145. _checkInputs(): void;
  6146. getClassName(): string;
  6147. }
  6148. }
  6149. declare module BABYLON {
  6150. class FreeCamera extends TargetCamera {
  6151. ellipsoid: Vector3;
  6152. ellipsoidOffset: Vector3;
  6153. checkCollisions: boolean;
  6154. applyGravity: boolean;
  6155. inputs: FreeCameraInputsManager;
  6156. /**
  6157. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6158. * Higher values reduce sensitivity.
  6159. */
  6160. /**
  6161. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6162. * Higher values reduce sensitivity.
  6163. */
  6164. angularSensibility: number;
  6165. keysUp: number[];
  6166. keysDown: number[];
  6167. keysLeft: number[];
  6168. keysRight: number[];
  6169. onCollide: (collidedMesh: AbstractMesh) => void;
  6170. private _collider;
  6171. private _needMoveForGravity;
  6172. private _oldPosition;
  6173. private _diffPosition;
  6174. private _newPosition;
  6175. _localDirection: Vector3;
  6176. _transformedDirection: Vector3;
  6177. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6179. detachControl(element: HTMLElement): void;
  6180. private _collisionMask;
  6181. collisionMask: number;
  6182. _collideWithWorld(displacement: Vector3): void;
  6183. private _onCollisionPositionChange;
  6184. _checkInputs(): void;
  6185. _decideIfNeedsToMove(): boolean;
  6186. _updatePosition(): void;
  6187. dispose(): void;
  6188. getClassName(): string;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6193. constructor(camera: FreeCamera);
  6194. addKeyboard(): FreeCameraInputsManager;
  6195. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6196. addGamepad(): FreeCameraInputsManager;
  6197. addDeviceOrientation(): FreeCameraInputsManager;
  6198. addTouch(): FreeCameraInputsManager;
  6199. addVirtualJoystick(): FreeCameraInputsManager;
  6200. }
  6201. }
  6202. declare module BABYLON {
  6203. class GamepadCamera extends UniversalCamera {
  6204. gamepadAngularSensibility: number;
  6205. gamepadMoveSensibility: number;
  6206. constructor(name: string, position: Vector3, scene: Scene);
  6207. getClassName(): string;
  6208. }
  6209. }
  6210. declare module BABYLON {
  6211. /**
  6212. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6213. */
  6214. class AnaglyphFreeCamera extends FreeCamera {
  6215. /**
  6216. * Creates a new AnaglyphFreeCamera
  6217. * @param name defines camera name
  6218. * @param position defines initial position
  6219. * @param interaxialDistance defines distance between each color axis
  6220. * @param scene defines the hosting scene
  6221. */
  6222. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6223. /**
  6224. * Gets camera class name
  6225. * @returns AnaglyphFreeCamera
  6226. */
  6227. getClassName(): string;
  6228. }
  6229. /**
  6230. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6231. */
  6232. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6233. /**
  6234. * Creates a new AnaglyphArcRotateCamera
  6235. * @param name defines camera name
  6236. * @param alpha defines alpha angle (in radians)
  6237. * @param beta defines beta angle (in radians)
  6238. * @param radius defines radius
  6239. * @param target defines camera target
  6240. * @param interaxialDistance defines distance between each color axis
  6241. * @param scene defines the hosting scene
  6242. */
  6243. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6244. /**
  6245. * Gets camera class name
  6246. * @returns AnaglyphArcRotateCamera
  6247. */
  6248. getClassName(): string;
  6249. }
  6250. /**
  6251. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6252. */
  6253. class AnaglyphGamepadCamera extends GamepadCamera {
  6254. /**
  6255. * Creates a new AnaglyphGamepadCamera
  6256. * @param name defines camera name
  6257. * @param position defines initial position
  6258. * @param interaxialDistance defines distance between each color axis
  6259. * @param scene defines the hosting scene
  6260. */
  6261. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6262. /**
  6263. * Gets camera class name
  6264. * @returns AnaglyphGamepadCamera
  6265. */
  6266. getClassName(): string;
  6267. }
  6268. /**
  6269. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6270. */
  6271. class AnaglyphUniversalCamera extends UniversalCamera {
  6272. /**
  6273. * Creates a new AnaglyphUniversalCamera
  6274. * @param name defines camera name
  6275. * @param position defines initial position
  6276. * @param interaxialDistance defines distance between each color axis
  6277. * @param scene defines the hosting scene
  6278. */
  6279. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6280. /**
  6281. * Gets camera class name
  6282. * @returns AnaglyphUniversalCamera
  6283. */
  6284. getClassName(): string;
  6285. }
  6286. /**
  6287. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6288. */
  6289. class StereoscopicFreeCamera extends FreeCamera {
  6290. /**
  6291. * Creates a new StereoscopicFreeCamera
  6292. * @param name defines camera name
  6293. * @param position defines initial position
  6294. * @param interaxialDistance defines distance between each color axis
  6295. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6296. * @param scene defines the hosting scene
  6297. */
  6298. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6299. /**
  6300. * Gets camera class name
  6301. * @returns StereoscopicFreeCamera
  6302. */
  6303. getClassName(): string;
  6304. }
  6305. /**
  6306. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6307. */
  6308. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6309. /**
  6310. * Creates a new StereoscopicArcRotateCamera
  6311. * @param name defines camera name
  6312. * @param alpha defines alpha angle (in radians)
  6313. * @param beta defines beta angle (in radians)
  6314. * @param radius defines radius
  6315. * @param target defines camera target
  6316. * @param interaxialDistance defines distance between each color axis
  6317. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6318. * @param scene defines the hosting scene
  6319. */
  6320. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6321. /**
  6322. * Gets camera class name
  6323. * @returns StereoscopicArcRotateCamera
  6324. */
  6325. getClassName(): string;
  6326. }
  6327. /**
  6328. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6329. */
  6330. class StereoscopicGamepadCamera extends GamepadCamera {
  6331. /**
  6332. * Creates a new StereoscopicGamepadCamera
  6333. * @param name defines camera name
  6334. * @param position defines initial position
  6335. * @param interaxialDistance defines distance between each color axis
  6336. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6337. * @param scene defines the hosting scene
  6338. */
  6339. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6340. /**
  6341. * Gets camera class name
  6342. * @returns StereoscopicGamepadCamera
  6343. */
  6344. getClassName(): string;
  6345. }
  6346. /**
  6347. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6348. */
  6349. class StereoscopicUniversalCamera extends UniversalCamera {
  6350. /**
  6351. * Creates a new StereoscopicUniversalCamera
  6352. * @param name defines camera name
  6353. * @param position defines initial position
  6354. * @param interaxialDistance defines distance between each color axis
  6355. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6356. * @param scene defines the hosting scene
  6357. */
  6358. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6359. /**
  6360. * Gets camera class name
  6361. * @returns StereoscopicUniversalCamera
  6362. */
  6363. getClassName(): string;
  6364. }
  6365. }
  6366. declare module BABYLON {
  6367. class TargetCamera extends Camera {
  6368. cameraDirection: Vector3;
  6369. cameraRotation: Vector2;
  6370. rotation: Vector3;
  6371. rotationQuaternion: Quaternion;
  6372. speed: number;
  6373. noRotationConstraint: boolean;
  6374. lockedTarget: any;
  6375. _currentTarget: Vector3;
  6376. _viewMatrix: Matrix;
  6377. _camMatrix: Matrix;
  6378. _cameraTransformMatrix: Matrix;
  6379. _cameraRotationMatrix: Matrix;
  6380. private _rigCamTransformMatrix;
  6381. _referencePoint: Vector3;
  6382. private _currentUpVector;
  6383. _transformedReferencePoint: Vector3;
  6384. protected _globalCurrentTarget: Vector3;
  6385. protected _globalCurrentUpVector: Vector3;
  6386. _reset: () => void;
  6387. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6388. getFrontPosition(distance: number): Vector3;
  6389. _getLockedTargetPosition(): Nullable<Vector3>;
  6390. /**
  6391. * Store current camera state (fov, position, etc..)
  6392. */
  6393. private _storedPosition;
  6394. private _storedRotation;
  6395. private _storedRotationQuaternion;
  6396. storeState(): Camera;
  6397. /**
  6398. * Restored camera state. You must call storeState() first
  6399. */
  6400. _restoreStateValues(): boolean;
  6401. _initCache(): void;
  6402. _updateCache(ignoreParentClass?: boolean): void;
  6403. _isSynchronizedViewMatrix(): boolean;
  6404. _computeLocalCameraSpeed(): number;
  6405. setTarget(target: Vector3): void;
  6406. /**
  6407. * Return the current target position of the camera. This value is expressed in local space.
  6408. */
  6409. getTarget(): Vector3;
  6410. _decideIfNeedsToMove(): boolean;
  6411. _updatePosition(): void;
  6412. _checkInputs(): void;
  6413. protected _updateCameraRotationMatrix(): void;
  6414. _getViewMatrix(): Matrix;
  6415. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6416. /**
  6417. * @override
  6418. * Override Camera.createRigCamera
  6419. */
  6420. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6421. /**
  6422. * @override
  6423. * Override Camera._updateRigCameras
  6424. */
  6425. _updateRigCameras(): void;
  6426. private _getRigCamPosition(halfSpace, result);
  6427. getClassName(): string;
  6428. }
  6429. }
  6430. declare module BABYLON {
  6431. class TouchCamera extends FreeCamera {
  6432. touchAngularSensibility: number;
  6433. touchMoveSensibility: number;
  6434. constructor(name: string, position: Vector3, scene: Scene);
  6435. getClassName(): string;
  6436. _setupInputs(): void;
  6437. }
  6438. }
  6439. declare module BABYLON {
  6440. class UniversalCamera extends TouchCamera {
  6441. gamepadAngularSensibility: number;
  6442. gamepadMoveSensibility: number;
  6443. constructor(name: string, position: Vector3, scene: Scene);
  6444. getClassName(): string;
  6445. }
  6446. }
  6447. declare module BABYLON {
  6448. class VirtualJoysticksCamera extends FreeCamera {
  6449. constructor(name: string, position: Vector3, scene: Scene);
  6450. getClassName(): string;
  6451. }
  6452. }
  6453. interface VRDisplay extends EventTarget {
  6454. /**
  6455. * Dictionary of capabilities describing the VRDisplay.
  6456. */
  6457. readonly capabilities: VRDisplayCapabilities;
  6458. /**
  6459. * z-depth defining the far plane of the eye view frustum
  6460. * enables mapping of values in the render target depth
  6461. * attachment to scene coordinates. Initially set to 10000.0.
  6462. */
  6463. depthFar: number;
  6464. /**
  6465. * z-depth defining the near plane of the eye view frustum
  6466. * enables mapping of values in the render target depth
  6467. * attachment to scene coordinates. Initially set to 0.01.
  6468. */
  6469. depthNear: number;
  6470. /**
  6471. * An identifier for this distinct VRDisplay. Used as an
  6472. * association point in the Gamepad API.
  6473. */
  6474. readonly displayId: number;
  6475. /**
  6476. * A display name, a user-readable name identifying it.
  6477. */
  6478. readonly displayName: string;
  6479. readonly isConnected: boolean;
  6480. readonly isPresenting: boolean;
  6481. /**
  6482. * If this VRDisplay supports room-scale experiences, the optional
  6483. * stage attribute contains details on the room-scale parameters.
  6484. */
  6485. readonly stageParameters: VRStageParameters | null;
  6486. /**
  6487. * Passing the value returned by `requestAnimationFrame` to
  6488. * `cancelAnimationFrame` will unregister the callback.
  6489. */
  6490. cancelAnimationFrame(handle: number): void;
  6491. /**
  6492. * Stops presenting to the VRDisplay.
  6493. */
  6494. exitPresent(): Promise<void>;
  6495. getEyeParameters(whichEye: string): VREyeParameters;
  6496. /**
  6497. * Populates the passed VRFrameData with the information required to render
  6498. * the current frame.
  6499. */
  6500. getFrameData(frameData: VRFrameData): boolean;
  6501. /**
  6502. * Get the layers currently being presented.
  6503. */
  6504. getLayers(): VRLayer[];
  6505. /**
  6506. * Return a VRPose containing the future predicted pose of the VRDisplay
  6507. * when the current frame will be presented. The value returned will not
  6508. * change until JavaScript has returned control to the browser.
  6509. *
  6510. * The VRPose will contain the position, orientation, velocity,
  6511. * and acceleration of each of these properties.
  6512. */
  6513. getPose(): VRPose;
  6514. /**
  6515. * Return the current instantaneous pose of the VRDisplay, with no
  6516. * prediction applied.
  6517. */
  6518. getImmediatePose(): VRPose;
  6519. /**
  6520. * The callback passed to `requestAnimationFrame` will be called
  6521. * any time a new frame should be rendered. When the VRDisplay is
  6522. * presenting the callback will be called at the native refresh
  6523. * rate of the HMD. When not presenting this function acts
  6524. * identically to how window.requestAnimationFrame acts. Content should
  6525. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6526. * asynchronously from other displays and at differing refresh rates.
  6527. */
  6528. requestAnimationFrame(callback: FrameRequestCallback): number;
  6529. /**
  6530. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6531. * Repeat calls while already presenting will update the VRLayers being displayed.
  6532. */
  6533. requestPresent(layers: VRLayer[]): Promise<void>;
  6534. /**
  6535. * Reset the pose for this display, treating its current position and
  6536. * orientation as the "origin/zero" values. VRPose.position,
  6537. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6538. * updated when calling resetPose(). This should be called in only
  6539. * sitting-space experiences.
  6540. */
  6541. resetPose(): void;
  6542. /**
  6543. * The VRLayer provided to the VRDisplay will be captured and presented
  6544. * in the HMD. Calling this function has the same effect on the source
  6545. * canvas as any other operation that uses its source image, and canvases
  6546. * created without preserveDrawingBuffer set to true will be cleared.
  6547. */
  6548. submitFrame(pose?: VRPose): void;
  6549. }
  6550. declare var VRDisplay: {
  6551. prototype: VRDisplay;
  6552. new (): VRDisplay;
  6553. };
  6554. interface VRLayer {
  6555. leftBounds?: number[] | null;
  6556. rightBounds?: number[] | null;
  6557. source?: HTMLCanvasElement | null;
  6558. }
  6559. interface VRDisplayCapabilities {
  6560. readonly canPresent: boolean;
  6561. readonly hasExternalDisplay: boolean;
  6562. readonly hasOrientation: boolean;
  6563. readonly hasPosition: boolean;
  6564. readonly maxLayers: number;
  6565. }
  6566. interface VREyeParameters {
  6567. /** @deprecated */
  6568. readonly fieldOfView: VRFieldOfView;
  6569. readonly offset: Float32Array;
  6570. readonly renderHeight: number;
  6571. readonly renderWidth: number;
  6572. }
  6573. interface VRFieldOfView {
  6574. readonly downDegrees: number;
  6575. readonly leftDegrees: number;
  6576. readonly rightDegrees: number;
  6577. readonly upDegrees: number;
  6578. }
  6579. interface VRFrameData {
  6580. readonly leftProjectionMatrix: Float32Array;
  6581. readonly leftViewMatrix: Float32Array;
  6582. readonly pose: VRPose;
  6583. readonly rightProjectionMatrix: Float32Array;
  6584. readonly rightViewMatrix: Float32Array;
  6585. readonly timestamp: number;
  6586. }
  6587. interface VRPose {
  6588. readonly angularAcceleration: Float32Array | null;
  6589. readonly angularVelocity: Float32Array | null;
  6590. readonly linearAcceleration: Float32Array | null;
  6591. readonly linearVelocity: Float32Array | null;
  6592. readonly orientation: Float32Array | null;
  6593. readonly position: Float32Array | null;
  6594. readonly timestamp: number;
  6595. }
  6596. interface VRStageParameters {
  6597. sittingToStandingTransform?: Float32Array;
  6598. sizeX?: number;
  6599. sizeY?: number;
  6600. }
  6601. interface Navigator {
  6602. getVRDisplays(): Promise<VRDisplay[]>;
  6603. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6604. }
  6605. interface Window {
  6606. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6607. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6608. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6609. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6610. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6611. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6612. }
  6613. interface Gamepad {
  6614. readonly displayId: number;
  6615. }
  6616. declare module BABYLON {
  6617. class BoundingBox implements ICullable {
  6618. vectors: Vector3[];
  6619. center: Vector3;
  6620. centerWorld: Vector3;
  6621. extendSize: Vector3;
  6622. extendSizeWorld: Vector3;
  6623. directions: Vector3[];
  6624. vectorsWorld: Vector3[];
  6625. minimumWorld: Vector3;
  6626. maximumWorld: Vector3;
  6627. minimum: Vector3;
  6628. maximum: Vector3;
  6629. private _worldMatrix;
  6630. /**
  6631. * Creates a new bounding box
  6632. * @param min defines the minimum vector (in local space)
  6633. * @param max defines the maximum vector (in local space)
  6634. */
  6635. constructor(min: Vector3, max: Vector3);
  6636. /**
  6637. * Recreates the entire bounding box from scratch
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. */
  6641. reConstruct(min: Vector3, max: Vector3): void;
  6642. getWorldMatrix(): Matrix;
  6643. setWorldMatrix(matrix: Matrix): BoundingBox;
  6644. _update(world: Matrix): void;
  6645. isInFrustum(frustumPlanes: Plane[]): boolean;
  6646. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6647. intersectsPoint(point: Vector3): boolean;
  6648. intersectsSphere(sphere: BoundingSphere): boolean;
  6649. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6650. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6651. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6652. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6653. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6654. }
  6655. }
  6656. declare module BABYLON {
  6657. interface ICullable {
  6658. isInFrustum(frustumPlanes: Plane[]): boolean;
  6659. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6660. }
  6661. class BoundingInfo implements ICullable {
  6662. minimum: Vector3;
  6663. maximum: Vector3;
  6664. boundingBox: BoundingBox;
  6665. boundingSphere: BoundingSphere;
  6666. private _isLocked;
  6667. constructor(minimum: Vector3, maximum: Vector3);
  6668. isLocked: boolean;
  6669. update(world: Matrix): void;
  6670. /**
  6671. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6672. * @param center New center of the bounding info
  6673. * @param extend New extend of the bounding info
  6674. */
  6675. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6676. isInFrustum(frustumPlanes: Plane[]): boolean;
  6677. /**
  6678. * Gets the world distance between the min and max points of the bounding box
  6679. */
  6680. readonly diagonalLength: number;
  6681. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6682. _checkCollision(collider: Collider): boolean;
  6683. intersectsPoint(point: Vector3): boolean;
  6684. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6685. }
  6686. }
  6687. declare module BABYLON {
  6688. class BoundingSphere {
  6689. center: Vector3;
  6690. radius: number;
  6691. centerWorld: Vector3;
  6692. radiusWorld: number;
  6693. minimum: Vector3;
  6694. maximum: Vector3;
  6695. private _tempRadiusVector;
  6696. /**
  6697. * Creates a new bounding sphere
  6698. * @param min defines the minimum vector (in local space)
  6699. * @param max defines the maximum vector (in local space)
  6700. */
  6701. constructor(min: Vector3, max: Vector3);
  6702. /**
  6703. * Recreates the entire bounding sphere from scratch
  6704. * @param min defines the new minimum vector (in local space)
  6705. * @param max defines the new maximum vector (in local space)
  6706. */
  6707. reConstruct(min: Vector3, max: Vector3): void;
  6708. _update(world: Matrix): void;
  6709. isInFrustum(frustumPlanes: Plane[]): boolean;
  6710. intersectsPoint(point: Vector3): boolean;
  6711. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. class Ray {
  6716. origin: Vector3;
  6717. direction: Vector3;
  6718. length: number;
  6719. private _edge1;
  6720. private _edge2;
  6721. private _pvec;
  6722. private _tvec;
  6723. private _qvec;
  6724. private _tmpRay;
  6725. constructor(origin: Vector3, direction: Vector3, length?: number);
  6726. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6727. intersectsBox(box: BoundingBox): boolean;
  6728. intersectsSphere(sphere: BoundingSphere): boolean;
  6729. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6730. intersectsPlane(plane: Plane): Nullable<number>;
  6731. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6732. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6733. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  6734. private static smallnum;
  6735. private static rayl;
  6736. /**
  6737. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6738. * @param sega the first point of the segment to test the intersection against
  6739. * @param segb the second point of the segment to test the intersection against
  6740. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6741. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6742. */
  6743. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6744. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6745. static Zero(): Ray;
  6746. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6747. /**
  6748. * 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
  6749. * transformed to the given world matrix.
  6750. * @param origin The origin point
  6751. * @param end The end point
  6752. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6753. */
  6754. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6755. static Transform(ray: Ray, matrix: Matrix): Ray;
  6756. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6757. }
  6758. }
  6759. /**
  6760. * Module Debug contains the (visual) components to debug a scene correctly
  6761. */
  6762. declare module BABYLON.Debug {
  6763. /**
  6764. * The Axes viewer will show 3 axes in a specific point in space
  6765. */
  6766. class AxesViewer {
  6767. private _xline;
  6768. private _yline;
  6769. private _zline;
  6770. private _xmesh;
  6771. private _ymesh;
  6772. private _zmesh;
  6773. /**
  6774. * Gets the hosting scene
  6775. */
  6776. scene: Nullable<Scene>;
  6777. /**
  6778. * Gets or sets a number used to scale line length
  6779. */
  6780. scaleLines: number;
  6781. /**
  6782. * Creates a new AxesViewer
  6783. * @param scene defines the hosting scene
  6784. * @param scaleLines defines a number used to scale line length (1 by default)
  6785. */
  6786. constructor(scene: Scene, scaleLines?: number);
  6787. /**
  6788. * Force the viewer to update
  6789. * @param position defines the position of the viewer
  6790. * @param xaxis defines the x axis of the viewer
  6791. * @param yaxis defines the y axis of the viewer
  6792. * @param zaxis defines the z axis of the viewer
  6793. */
  6794. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6795. /** Releases resources */
  6796. dispose(): void;
  6797. }
  6798. }
  6799. declare module BABYLON.Debug {
  6800. /**
  6801. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6802. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6803. */
  6804. class BoneAxesViewer extends AxesViewer {
  6805. /**
  6806. * Gets or sets the target mesh where to display the axes viewer
  6807. */
  6808. mesh: Nullable<Mesh>;
  6809. /**
  6810. * Gets or sets the target bone where to display the axes viewer
  6811. */
  6812. bone: Nullable<Bone>;
  6813. /** Gets current position */
  6814. pos: Vector3;
  6815. /** Gets direction of X axis */
  6816. xaxis: Vector3;
  6817. /** Gets direction of Y axis */
  6818. yaxis: Vector3;
  6819. /** Gets direction of Z axis */
  6820. zaxis: Vector3;
  6821. /**
  6822. * Creates a new BoneAxesViewer
  6823. * @param scene defines the hosting scene
  6824. * @param bone defines the target bone
  6825. * @param mesh defines the target mesh
  6826. * @param scaleLines defines a scaling factor for line length (1 by default)
  6827. */
  6828. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6829. /**
  6830. * Force the viewer to update
  6831. */
  6832. update(): void;
  6833. /** Releases resources */
  6834. dispose(): void;
  6835. }
  6836. }
  6837. declare module BABYLON {
  6838. class DebugLayer {
  6839. private _scene;
  6840. static InspectorURL: string;
  6841. private _inspector;
  6842. private BJSINSPECTOR;
  6843. onPropertyChangedObservable: BABYLON.Observable<{
  6844. object: any;
  6845. property: string;
  6846. value: any;
  6847. initialValue: any;
  6848. }>;
  6849. constructor(scene: Scene);
  6850. /** Creates the inspector window. */
  6851. private _createInspector(config?);
  6852. isVisible(): boolean;
  6853. hide(): void;
  6854. /**
  6855. *
  6856. * Launch the debugLayer.
  6857. *
  6858. * initialTab:
  6859. * | Value | Tab Name |
  6860. * | --- | --- |
  6861. * | 0 | Scene |
  6862. * | 1 | Console |
  6863. * | 2 | Stats |
  6864. * | 3 | Textures |
  6865. * | 4 | Mesh |
  6866. * | 5 | Light |
  6867. * | 6 | Material |
  6868. * | 7 | GLTF |
  6869. * | 8 | GUI |
  6870. * | 9 | Physics |
  6871. * | 10 | Camera |
  6872. * | 11 | Audio |
  6873. *
  6874. */
  6875. show(config?: {
  6876. popup?: boolean;
  6877. initialTab?: number;
  6878. parentElement?: HTMLElement;
  6879. newColors?: {
  6880. backgroundColor?: string;
  6881. backgroundColorLighter?: string;
  6882. backgroundColorLighter2?: string;
  6883. backgroundColorLighter3?: string;
  6884. color?: string;
  6885. colorTop?: string;
  6886. colorBot?: string;
  6887. };
  6888. }): void;
  6889. /**
  6890. * Gets the active tab
  6891. * @return the index of the active tab or -1 if the inspector is hidden
  6892. */
  6893. getActiveTab(): number;
  6894. }
  6895. }
  6896. declare module BABYLON.Debug {
  6897. /**
  6898. * Used to show the physics impostor around the specific mesh
  6899. */
  6900. class PhysicsViewer {
  6901. /** @hidden */
  6902. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6903. /** @hidden */
  6904. protected _meshes: Array<Nullable<AbstractMesh>>;
  6905. /** @hidden */
  6906. protected _scene: Nullable<Scene>;
  6907. /** @hidden */
  6908. protected _numMeshes: number;
  6909. /** @hidden */
  6910. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6911. private _renderFunction;
  6912. private _debugBoxMesh;
  6913. private _debugSphereMesh;
  6914. private _debugMaterial;
  6915. /**
  6916. * Creates a new PhysicsViewer
  6917. * @param scene defines the hosting scene
  6918. */
  6919. constructor(scene: Scene);
  6920. /** @hidden */
  6921. protected _updateDebugMeshes(): void;
  6922. /**
  6923. * Renders a specified physic impostor
  6924. * @param impostor defines the impostor to render
  6925. */
  6926. showImpostor(impostor: PhysicsImpostor): void;
  6927. /**
  6928. * Hides a specified physic impostor
  6929. * @param impostor defines the impostor to hide
  6930. */
  6931. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6932. private _getDebugMaterial(scene);
  6933. private _getDebugBoxMesh(scene);
  6934. private _getDebugSphereMesh(scene);
  6935. private _getDebugMesh(impostor, scene);
  6936. /** Releases all resources */
  6937. dispose(): void;
  6938. }
  6939. }
  6940. declare module BABYLON {
  6941. class RayHelper {
  6942. ray: Nullable<Ray>;
  6943. private _renderPoints;
  6944. private _renderLine;
  6945. private _renderFunction;
  6946. private _scene;
  6947. private _updateToMeshFunction;
  6948. private _attachedToMesh;
  6949. private _meshSpaceDirection;
  6950. private _meshSpaceOrigin;
  6951. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6952. constructor(ray: Ray);
  6953. show(scene: Scene, color?: Color3): void;
  6954. hide(): void;
  6955. private _render();
  6956. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6957. detachFromMesh(): void;
  6958. private _updateToMesh();
  6959. dispose(): void;
  6960. }
  6961. }
  6962. declare module BABYLON.Debug {
  6963. /**
  6964. * Class used to render a debug view of a given skeleton
  6965. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6966. */
  6967. class SkeletonViewer {
  6968. /** defines the skeleton to render */
  6969. skeleton: Skeleton;
  6970. /** defines the mesh attached to the skeleton */
  6971. mesh: AbstractMesh;
  6972. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6973. autoUpdateBonesMatrices: boolean;
  6974. /** defines the rendering group id to use with the viewer */
  6975. renderingGroupId: number;
  6976. /** Gets or sets the color used to render the skeleton */
  6977. color: Color3;
  6978. private _scene;
  6979. private _debugLines;
  6980. private _debugMesh;
  6981. private _isEnabled;
  6982. private _renderFunction;
  6983. /**
  6984. * Creates a new SkeletonViewer
  6985. * @param skeleton defines the skeleton to render
  6986. * @param mesh defines the mesh attached to the skeleton
  6987. * @param scene defines the hosting scene
  6988. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6989. * @param renderingGroupId defines the rendering group id to use with the viewer
  6990. */
  6991. constructor(
  6992. /** defines the skeleton to render */
  6993. skeleton: Skeleton,
  6994. /** defines the mesh attached to the skeleton */
  6995. mesh: AbstractMesh, scene: Scene,
  6996. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6997. autoUpdateBonesMatrices?: boolean,
  6998. /** defines the rendering group id to use with the viewer */
  6999. renderingGroupId?: number);
  7000. /** Gets or sets a boolean indicating if the viewer is enabled */
  7001. isEnabled: boolean;
  7002. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  7003. private _getLinesForBonesWithLength(bones, meshMat);
  7004. private _getLinesForBonesNoLength(bones, meshMat);
  7005. /** Update the viewer to sync with current skeleton state */
  7006. update(): void;
  7007. /** Release associated resources */
  7008. dispose(): void;
  7009. }
  7010. }
  7011. declare module BABYLON {
  7012. /**
  7013. * Interface for attribute information associated with buffer instanciation
  7014. */
  7015. class InstancingAttributeInfo {
  7016. /**
  7017. * Index/offset of the attribute in the vertex shader
  7018. */
  7019. index: number;
  7020. /**
  7021. * size of the attribute, 1, 2, 3 or 4
  7022. */
  7023. attributeSize: number;
  7024. /**
  7025. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7026. * default is FLOAT
  7027. */
  7028. attribyteType: number;
  7029. /**
  7030. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7031. */
  7032. normalized: boolean;
  7033. /**
  7034. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7035. */
  7036. offset: number;
  7037. /**
  7038. * Name of the GLSL attribute, for debugging purpose only
  7039. */
  7040. attributeName: string;
  7041. }
  7042. /**
  7043. * Define options used to create a render target texture
  7044. */
  7045. class RenderTargetCreationOptions {
  7046. /**
  7047. * Specifies is mipmaps must be generated
  7048. */
  7049. generateMipMaps?: boolean;
  7050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7051. generateDepthBuffer?: boolean;
  7052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7053. generateStencilBuffer?: boolean;
  7054. /** Defines texture type (int by default) */
  7055. type?: number;
  7056. /** Defines sampling mode (trilinear by default) */
  7057. samplingMode?: number;
  7058. /** Defines format (RGBA by default) */
  7059. format?: number;
  7060. }
  7061. /**
  7062. * Define options used to create a depth texture
  7063. */
  7064. class DepthTextureCreationOptions {
  7065. /** Specifies whether or not a stencil should be allocated in the texture */
  7066. generateStencil?: boolean;
  7067. /** Specifies whether or not bilinear filtering is enable on the texture */
  7068. bilinearFiltering?: boolean;
  7069. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7070. comparisonFunction?: number;
  7071. /** Specifies if the created texture is a cube texture */
  7072. isCube?: boolean;
  7073. }
  7074. /**
  7075. * Class used to describe the capabilities of the engine relatively to the current browser
  7076. */
  7077. class EngineCapabilities {
  7078. /** Maximum textures units per fragment shader */
  7079. maxTexturesImageUnits: number;
  7080. /** Maximum texture units per vertex shader */
  7081. maxVertexTextureImageUnits: number;
  7082. /** Maximum textures units in the entire pipeline */
  7083. maxCombinedTexturesImageUnits: number;
  7084. /** Maximum texture size */
  7085. maxTextureSize: number;
  7086. /** Maximum cube texture size */
  7087. maxCubemapTextureSize: number;
  7088. /** Maximum render texture size */
  7089. maxRenderTextureSize: number;
  7090. /** Maximum number of vertex attributes */
  7091. maxVertexAttribs: number;
  7092. /** Maximum number of varyings */
  7093. maxVaryingVectors: number;
  7094. /** Maximum number of uniforms per vertex shader */
  7095. maxVertexUniformVectors: number;
  7096. /** Maximum number of uniforms per fragment shader */
  7097. maxFragmentUniformVectors: number;
  7098. /** Defines if standard derivates (dx/dy) are supported */
  7099. standardDerivatives: boolean;
  7100. /** Defines if s3tc texture compression is supported */
  7101. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7102. /** Defines if pvrtc texture compression is supported */
  7103. pvrtc: any;
  7104. /** Defines if etc1 texture compression is supported */
  7105. etc1: any;
  7106. /** Defines if etc2 texture compression is supported */
  7107. etc2: any;
  7108. /** Defines if astc texture compression is supported */
  7109. astc: any;
  7110. /** Defines if float textures are supported */
  7111. textureFloat: boolean;
  7112. /** Defines if vertex array objects are supported */
  7113. vertexArrayObject: boolean;
  7114. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7115. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7116. /** Gets the maximum level of anisotropy supported */
  7117. maxAnisotropy: number;
  7118. /** Defines if instancing is supported */
  7119. instancedArrays: boolean;
  7120. /** Defines if 32 bits indices are supported */
  7121. uintIndices: boolean;
  7122. /** Defines if high precision shaders are supported */
  7123. highPrecisionShaderSupported: boolean;
  7124. /** Defines if depth reading in the fragment shader is supported */
  7125. fragmentDepthSupported: boolean;
  7126. /** Defines if float texture linear filtering is supported*/
  7127. textureFloatLinearFiltering: boolean;
  7128. /** Defines if rendering to float textures is supported */
  7129. textureFloatRender: boolean;
  7130. /** Defines if half float textures are supported*/
  7131. textureHalfFloat: boolean;
  7132. /** Defines if half float texture linear filtering is supported*/
  7133. textureHalfFloatLinearFiltering: boolean;
  7134. /** Defines if rendering to half float textures is supported */
  7135. textureHalfFloatRender: boolean;
  7136. /** Defines if textureLOD shader command is supported */
  7137. textureLOD: boolean;
  7138. /** Defines if draw buffers extension is supported */
  7139. drawBuffersExtension: boolean;
  7140. /** Defines if depth textures are supported */
  7141. depthTextureExtension: boolean;
  7142. /** Defines if float color buffer are supported */
  7143. colorBufferFloat: boolean;
  7144. /** Gets disjoint timer query extension (null if not supported) */
  7145. timerQuery: EXT_disjoint_timer_query;
  7146. /** Defines if timestamp can be used with timer query */
  7147. canUseTimestampForTimerQuery: boolean;
  7148. }
  7149. /** Interface defining initialization parameters for Engine class */
  7150. interface EngineOptions extends WebGLContextAttributes {
  7151. /**
  7152. * Defines if the engine should no exceed a specified device ratio
  7153. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7154. */
  7155. limitDeviceRatio?: number;
  7156. /**
  7157. * Defines if webvr should be enabled automatically
  7158. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7159. */
  7160. autoEnableWebVR?: boolean;
  7161. /**
  7162. * Defines if webgl2 should be turned off even if supported
  7163. * @see http://doc.babylonjs.com/features/webgl2
  7164. */
  7165. disableWebGL2Support?: boolean;
  7166. /**
  7167. * Defines if webaudio should be initialized as well
  7168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7169. */
  7170. audioEngine?: boolean;
  7171. /**
  7172. * Defines if animations should run using a deterministic lock step
  7173. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7174. */
  7175. deterministicLockstep?: boolean;
  7176. /** Defines the maximum steps to use with deterministic lock step mode */
  7177. lockstepMaxSteps?: number;
  7178. /**
  7179. * Defines that engine should ignore context lost events
  7180. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7181. */
  7182. doNotHandleContextLost?: boolean;
  7183. }
  7184. /**
  7185. * Defines the interface used by display changed events
  7186. */
  7187. interface IDisplayChangedEventArgs {
  7188. /** Gets the vrDisplay object (if any) */
  7189. vrDisplay: Nullable<any>;
  7190. /** Gets a boolean indicating if webVR is supported */
  7191. vrSupported: boolean;
  7192. }
  7193. /**
  7194. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7195. */
  7196. class Engine {
  7197. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7198. static ExceptionList: ({
  7199. key: string;
  7200. capture: string;
  7201. captureConstraint: number;
  7202. targets: string[];
  7203. } | {
  7204. key: string;
  7205. capture: null;
  7206. captureConstraint: null;
  7207. targets: string[];
  7208. })[];
  7209. /** Gets the list of created engines */
  7210. static Instances: Engine[];
  7211. /**
  7212. * Gets the latest created engine
  7213. */
  7214. static readonly LastCreatedEngine: Nullable<Engine>;
  7215. /**
  7216. * Gets the latest created scene
  7217. */
  7218. static readonly LastCreatedScene: Nullable<Scene>;
  7219. /**
  7220. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7221. * @param flag defines which part of the materials must be marked as dirty
  7222. * @param predicate defines a predicate used to filter which materials should be affected
  7223. */
  7224. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7225. private static _ALPHA_DISABLE;
  7226. private static _ALPHA_ADD;
  7227. private static _ALPHA_COMBINE;
  7228. private static _ALPHA_SUBTRACT;
  7229. private static _ALPHA_MULTIPLY;
  7230. private static _ALPHA_MAXIMIZED;
  7231. private static _ALPHA_ONEONE;
  7232. private static _ALPHA_PREMULTIPLIED;
  7233. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  7234. private static _ALPHA_INTERPOLATE;
  7235. private static _ALPHA_SCREENMODE;
  7236. private static _DELAYLOADSTATE_NONE;
  7237. private static _DELAYLOADSTATE_LOADED;
  7238. private static _DELAYLOADSTATE_LOADING;
  7239. private static _DELAYLOADSTATE_NOTLOADED;
  7240. private static _TEXTUREFORMAT_ALPHA;
  7241. private static _TEXTUREFORMAT_LUMINANCE;
  7242. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7243. private static _TEXTUREFORMAT_RGB;
  7244. private static _TEXTUREFORMAT_RGBA;
  7245. private static _TEXTUREFORMAT_R;
  7246. private static _TEXTUREFORMAT_RG;
  7247. private static _TEXTURETYPE_UNSIGNED_INT;
  7248. private static _TEXTURETYPE_FLOAT;
  7249. private static _TEXTURETYPE_HALF_FLOAT;
  7250. private static _NEVER;
  7251. private static _ALWAYS;
  7252. private static _LESS;
  7253. private static _EQUAL;
  7254. private static _LEQUAL;
  7255. private static _GREATER;
  7256. private static _GEQUAL;
  7257. private static _NOTEQUAL;
  7258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7259. static readonly NEVER: number;
  7260. /** 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 */
  7261. static readonly ALWAYS: number;
  7262. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7263. static readonly LESS: number;
  7264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7265. static readonly EQUAL: number;
  7266. /** 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 */
  7267. static readonly LEQUAL: number;
  7268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7269. static readonly GREATER: number;
  7270. /** 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 */
  7271. static readonly GEQUAL: number;
  7272. /** 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 */
  7273. static readonly NOTEQUAL: number;
  7274. private static _KEEP;
  7275. private static _REPLACE;
  7276. private static _INCR;
  7277. private static _DECR;
  7278. private static _INVERT;
  7279. private static _INCR_WRAP;
  7280. private static _DECR_WRAP;
  7281. /** Passed to stencilOperation to specify that stencil value must be kept */
  7282. static readonly KEEP: number;
  7283. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7284. static readonly REPLACE: number;
  7285. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7286. static readonly INCR: number;
  7287. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7288. static readonly DECR: number;
  7289. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7290. static readonly INVERT: number;
  7291. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7292. static readonly INCR_WRAP: number;
  7293. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7294. static readonly DECR_WRAP: number;
  7295. /** Defines that alpha blending is disabled */
  7296. static readonly ALPHA_DISABLE: number;
  7297. /** Defines that alpha blending to SRC + DEST */
  7298. static readonly ALPHA_ONEONE: number;
  7299. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7300. static readonly ALPHA_ADD: number;
  7301. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7302. static readonly ALPHA_COMBINE: number;
  7303. /** Defines that alpha blending to DEST - SRC * DEST */
  7304. static readonly ALPHA_SUBTRACT: number;
  7305. /** Defines that alpha blending to SRC * DEST */
  7306. static readonly ALPHA_MULTIPLY: number;
  7307. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7308. static readonly ALPHA_MAXIMIZED: number;
  7309. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7310. static readonly ALPHA_PREMULTIPLIED: number;
  7311. /**
  7312. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7313. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7314. */
  7315. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7316. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7317. static readonly ALPHA_INTERPOLATE: number;
  7318. /**
  7319. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7320. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7321. */
  7322. static readonly ALPHA_SCREENMODE: number;
  7323. /** Defines that the ressource is not delayed*/
  7324. static readonly DELAYLOADSTATE_NONE: number;
  7325. /** Defines that the ressource was successfully delay loaded */
  7326. static readonly DELAYLOADSTATE_LOADED: number;
  7327. /** Defines that the ressource is currently delay loading */
  7328. static readonly DELAYLOADSTATE_LOADING: number;
  7329. /** Defines that the ressource is delayed and has not started loading */
  7330. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7331. /** ALPHA */
  7332. static readonly TEXTUREFORMAT_ALPHA: number;
  7333. /** LUMINANCE */
  7334. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7335. /**
  7336. * R
  7337. */
  7338. static readonly TEXTUREFORMAT_R: number;
  7339. /**
  7340. * RG
  7341. */
  7342. static readonly TEXTUREFORMAT_RG: number;
  7343. /** LUMINANCE_ALPHA */
  7344. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7345. /** RGB */
  7346. static readonly TEXTUREFORMAT_RGB: number;
  7347. /** RGBA */
  7348. static readonly TEXTUREFORMAT_RGBA: number;
  7349. /** UNSIGNED_INT */
  7350. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7351. /** FLOAT */
  7352. static readonly TEXTURETYPE_FLOAT: number;
  7353. /** HALF_FLOAT */
  7354. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7355. private static _SCALEMODE_FLOOR;
  7356. private static _SCALEMODE_NEAREST;
  7357. private static _SCALEMODE_CEILING;
  7358. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7359. static readonly SCALEMODE_FLOOR: number;
  7360. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7361. static readonly SCALEMODE_NEAREST: number;
  7362. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7363. static readonly SCALEMODE_CEILING: number;
  7364. /**
  7365. * Returns the current version of the framework
  7366. */
  7367. static readonly Version: string;
  7368. /**
  7369. * Gets or sets the epsilon value used by collision engine
  7370. */
  7371. static CollisionsEpsilon: number;
  7372. /**
  7373. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7374. */
  7375. static CodeRepository: string;
  7376. /**
  7377. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7378. */
  7379. static ShadersRepository: string;
  7380. /**
  7381. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7382. */
  7383. forcePOTTextures: boolean;
  7384. /**
  7385. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7386. */
  7387. isFullscreen: boolean;
  7388. /**
  7389. * Gets a boolean indicating if the pointer is currently locked
  7390. */
  7391. isPointerLock: boolean;
  7392. /**
  7393. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7394. */
  7395. cullBackFaces: boolean;
  7396. /**
  7397. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7398. */
  7399. renderEvenInBackground: boolean;
  7400. /**
  7401. * Gets or sets a boolean indicating that cache can be kept between frames
  7402. */
  7403. preventCacheWipeBetweenFrames: boolean;
  7404. /**
  7405. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7406. **/
  7407. enableOfflineSupport: boolean;
  7408. /**
  7409. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  7410. **/
  7411. disableManifestCheck: boolean;
  7412. /**
  7413. * Gets the list of created scenes
  7414. */
  7415. scenes: Scene[];
  7416. /**
  7417. * Gets the list of created postprocesses
  7418. */
  7419. postProcesses: PostProcess[];
  7420. /**
  7421. * Observable event triggered each time the rendering canvas is resized
  7422. */
  7423. onResizeObservable: Observable<Engine>;
  7424. /**
  7425. * Observable event triggered each time the canvas loses focus
  7426. */
  7427. onCanvasBlurObservable: Observable<Engine>;
  7428. /**
  7429. * Observable event triggered each time the canvas gains focus
  7430. */
  7431. onCanvasFocusObservable: Observable<Engine>;
  7432. /**
  7433. * Observable event triggered each time the canvas receives pointerout event
  7434. */
  7435. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7436. /**
  7437. * Observable event triggered before each texture is initialized
  7438. */
  7439. onBeforeTextureInitObservable: Observable<Texture>;
  7440. private _vrDisplay;
  7441. private _vrSupported;
  7442. private _oldSize;
  7443. private _oldHardwareScaleFactor;
  7444. private _vrExclusivePointerMode;
  7445. private _webVRInitPromise;
  7446. /**
  7447. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7448. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7449. */
  7450. readonly isInVRExclusivePointerMode: boolean;
  7451. /**
  7452. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7453. */
  7454. disableUniformBuffers: boolean;
  7455. /** @hidden */
  7456. _uniformBuffers: UniformBuffer[];
  7457. /**
  7458. * Gets a boolean indicating that the engine supports uniform buffers
  7459. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7460. */
  7461. readonly supportsUniformBuffers: boolean;
  7462. /**
  7463. * Observable raised when the engine begins a new frame
  7464. */
  7465. onBeginFrameObservable: Observable<Engine>;
  7466. /**
  7467. * Observable raised when the engine ends the current frame
  7468. */
  7469. onEndFrameObservable: Observable<Engine>;
  7470. /**
  7471. * Observable raised when the engine is about to compile a shader
  7472. */
  7473. onBeforeShaderCompilationObservable: Observable<Engine>;
  7474. /**
  7475. * Observable raised when the engine has jsut compiled a shader
  7476. */
  7477. onAfterShaderCompilationObservable: Observable<Engine>;
  7478. private _gl;
  7479. private _renderingCanvas;
  7480. private _windowIsBackground;
  7481. private _webGLVersion;
  7482. /**
  7483. * Gets a boolean indicating that only power of 2 textures are supported
  7484. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7485. */
  7486. readonly needPOTTextures: boolean;
  7487. /** @hidden */
  7488. _badOS: boolean;
  7489. /** @hidden */
  7490. _badDesktopOS: boolean;
  7491. /**
  7492. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7493. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7494. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7495. */
  7496. disableTextureBindingOptimization: boolean;
  7497. /**
  7498. * Gets the audio engine
  7499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7500. * @ignorenaming
  7501. */
  7502. static audioEngine: AudioEngine;
  7503. private _onFocus;
  7504. private _onBlur;
  7505. private _onCanvasPointerOut;
  7506. private _onCanvasBlur;
  7507. private _onCanvasFocus;
  7508. private _onFullscreenChange;
  7509. private _onPointerLockChange;
  7510. private _onVRDisplayPointerRestricted;
  7511. private _onVRDisplayPointerUnrestricted;
  7512. private _onVrDisplayConnect;
  7513. private _onVrDisplayDisconnect;
  7514. private _onVrDisplayPresentChange;
  7515. /**
  7516. * Observable signaled when VR display mode changes
  7517. */
  7518. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7519. /**
  7520. * Observable signaled when VR request present is complete
  7521. */
  7522. onVRRequestPresentComplete: Observable<boolean>;
  7523. /**
  7524. * Observable signaled when VR request present starts
  7525. */
  7526. onVRRequestPresentStart: Observable<Engine>;
  7527. private _hardwareScalingLevel;
  7528. /** @hidden */
  7529. protected _caps: EngineCapabilities;
  7530. private _pointerLockRequested;
  7531. private _isStencilEnable;
  7532. private _colorWrite;
  7533. private _loadingScreen;
  7534. /** @hidden */
  7535. _drawCalls: PerfCounter;
  7536. /** @hidden */
  7537. _textureCollisions: PerfCounter;
  7538. private _glVersion;
  7539. private _glRenderer;
  7540. private _glVendor;
  7541. private _videoTextureSupported;
  7542. private _renderingQueueLaunched;
  7543. private _activeRenderLoops;
  7544. private _deterministicLockstep;
  7545. private _lockstepMaxSteps;
  7546. /**
  7547. * Observable signaled when a context lost event is raised
  7548. */
  7549. onContextLostObservable: Observable<Engine>;
  7550. /**
  7551. * Observable signaled when a context restored event is raised
  7552. */
  7553. onContextRestoredObservable: Observable<Engine>;
  7554. private _onContextLost;
  7555. private _onContextRestored;
  7556. private _contextWasLost;
  7557. private _doNotHandleContextLost;
  7558. /**
  7559. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7561. */
  7562. doNotHandleContextLost: boolean;
  7563. private _performanceMonitor;
  7564. private _fps;
  7565. private _deltaTime;
  7566. /**
  7567. * Turn this value on if you want to pause FPS computation when in background
  7568. */
  7569. disablePerformanceMonitorInBackground: boolean;
  7570. /**
  7571. * Gets the performance monitor attached to this engine
  7572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7573. */
  7574. readonly performanceMonitor: PerformanceMonitor;
  7575. /** @hidden */
  7576. protected _depthCullingState: _DepthCullingState;
  7577. /** @hidden */
  7578. protected _stencilState: _StencilState;
  7579. /** @hidden */
  7580. protected _alphaState: _AlphaState;
  7581. /** @hidden */
  7582. protected _alphaMode: number;
  7583. protected _internalTexturesCache: InternalTexture[];
  7584. /** @hidden */
  7585. protected _activeChannel: number;
  7586. private _currentTextureChannel;
  7587. /** @hidden */
  7588. protected _boundTexturesCache: {
  7589. [key: string]: Nullable<InternalTexture>;
  7590. };
  7591. /** @hidden */
  7592. protected _currentEffect: Nullable<Effect>;
  7593. /** @hidden */
  7594. protected _currentProgram: Nullable<WebGLProgram>;
  7595. private _compiledEffects;
  7596. private _vertexAttribArraysEnabled;
  7597. /** @hidden */
  7598. protected _cachedViewport: Nullable<Viewport>;
  7599. private _cachedVertexArrayObject;
  7600. /** @hidden */
  7601. protected _cachedVertexBuffers: any;
  7602. /** @hidden */
  7603. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7604. /** @hidden */
  7605. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7606. /** @hidden */
  7607. protected _currentRenderTarget: Nullable<InternalTexture>;
  7608. private _uintIndicesCurrentlySet;
  7609. private _currentBoundBuffer;
  7610. /** @hidden */
  7611. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7612. private _currentBufferPointers;
  7613. private _currentInstanceLocations;
  7614. private _currentInstanceBuffers;
  7615. private _textureUnits;
  7616. private _firstBoundInternalTextureTracker;
  7617. private _lastBoundInternalTextureTracker;
  7618. private _workingCanvas;
  7619. private _workingContext;
  7620. private _rescalePostProcess;
  7621. private _dummyFramebuffer;
  7622. private _externalData;
  7623. private _bindedRenderFunction;
  7624. private _vaoRecordInProgress;
  7625. private _mustWipeVertexAttributes;
  7626. private _emptyTexture;
  7627. private _emptyCubeTexture;
  7628. private _emptyTexture3D;
  7629. private _frameHandler;
  7630. private _nextFreeTextureSlots;
  7631. private _maxSimultaneousTextures;
  7632. private _activeRequests;
  7633. private _texturesSupported;
  7634. private _textureFormatInUse;
  7635. /**
  7636. * Gets the list of texture formats supported
  7637. */
  7638. readonly texturesSupported: Array<string>;
  7639. /**
  7640. * Gets the list of texture formats in use
  7641. */
  7642. readonly textureFormatInUse: Nullable<string>;
  7643. /**
  7644. * Gets the current viewport
  7645. */
  7646. readonly currentViewport: Nullable<Viewport>;
  7647. /**
  7648. * Gets the default empty texture
  7649. */
  7650. readonly emptyTexture: InternalTexture;
  7651. /**
  7652. * Gets the default empty 3D texture
  7653. */
  7654. readonly emptyTexture3D: InternalTexture;
  7655. /**
  7656. * Gets the default empty cube texture
  7657. */
  7658. readonly emptyCubeTexture: InternalTexture;
  7659. /**
  7660. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7661. */
  7662. readonly premultipliedAlpha: boolean;
  7663. /**
  7664. * Creates a new engine
  7665. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7666. * @param antialias defines enable antialiasing (default: false)
  7667. * @param options defines further options to be sent to the getContext() function
  7668. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7669. */
  7670. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7671. private _rebuildInternalTextures();
  7672. private _rebuildEffects();
  7673. private _rebuildBuffers();
  7674. private _initGLContext();
  7675. /**
  7676. * Gets version of the current webGL context
  7677. */
  7678. readonly webGLVersion: number;
  7679. /**
  7680. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7681. */
  7682. readonly isStencilEnable: boolean;
  7683. private _prepareWorkingCanvas();
  7684. /**
  7685. * Reset the texture cache to empty state
  7686. */
  7687. resetTextureCache(): void;
  7688. /**
  7689. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7690. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7691. * @returns true if engine is in deterministic lock step mode
  7692. */
  7693. isDeterministicLockStep(): boolean;
  7694. /**
  7695. * Gets the max steps when engine is running in deterministic lock step
  7696. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7697. * @returns the max steps
  7698. */
  7699. getLockstepMaxSteps(): number;
  7700. /**
  7701. * Gets an object containing information about the current webGL context
  7702. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7703. */
  7704. getGlInfo(): {
  7705. vendor: string;
  7706. renderer: string;
  7707. version: string;
  7708. };
  7709. /**
  7710. * Gets current aspect ratio
  7711. * @param camera defines the camera to use to get the aspect ratio
  7712. * @param useScreen defines if screen size must be used (or the current render target if any)
  7713. * @returns a number defining the aspect ratio
  7714. */
  7715. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7716. /**
  7717. * Gets current screen aspect ratio
  7718. * @returns a number defining the aspect ratio
  7719. */
  7720. getScreenAspectRatio(): number;
  7721. /**
  7722. * Gets the current render width
  7723. * @param useScreen defines if screen size must be used (or the current render target if any)
  7724. * @returns a number defining the current render width
  7725. */
  7726. getRenderWidth(useScreen?: boolean): number;
  7727. /**
  7728. * Gets the current render height
  7729. * @param useScreen defines if screen size must be used (or the current render target if any)
  7730. * @returns a number defining the current render height
  7731. */
  7732. getRenderHeight(useScreen?: boolean): number;
  7733. /**
  7734. * Gets the HTML canvas attached with the current webGL context
  7735. * @returns a HTML canvas
  7736. */
  7737. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7738. /**
  7739. * Gets the client rect of the HTML canvas attached with the current webGL context
  7740. * @returns a client rectanglee
  7741. */
  7742. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7743. /**
  7744. * Defines the hardware scaling level.
  7745. * By default the hardware scaling level is computed from the window device ratio.
  7746. * 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.
  7747. * @param level defines the level to use
  7748. */
  7749. setHardwareScalingLevel(level: number): void;
  7750. /**
  7751. * Gets the current hardware scaling level.
  7752. * By default the hardware scaling level is computed from the window device ratio.
  7753. * 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.
  7754. * @returns a number indicating the current hardware scaling level
  7755. */
  7756. getHardwareScalingLevel(): number;
  7757. /**
  7758. * Gets the list of loaded textures
  7759. * @returns an array containing all loaded textures
  7760. */
  7761. getLoadedTexturesCache(): InternalTexture[];
  7762. /**
  7763. * Gets the object containing all engine capabilities
  7764. * @returns the EngineCapabilities object
  7765. */
  7766. getCaps(): EngineCapabilities;
  7767. /** @hidden */
  7768. readonly drawCalls: number;
  7769. /** @hidden */
  7770. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7771. /**
  7772. * Gets the current depth function
  7773. * @returns a number defining the depth function
  7774. */
  7775. getDepthFunction(): Nullable<number>;
  7776. /**
  7777. * Sets the current depth function
  7778. * @param depthFunc defines the function to use
  7779. */
  7780. setDepthFunction(depthFunc: number): void;
  7781. /**
  7782. * Sets the current depth function to GREATER
  7783. */
  7784. setDepthFunctionToGreater(): void;
  7785. /**
  7786. * Sets the current depth function to GEQUAL
  7787. */
  7788. setDepthFunctionToGreaterOrEqual(): void;
  7789. /**
  7790. * Sets the current depth function to LESS
  7791. */
  7792. setDepthFunctionToLess(): void;
  7793. /**
  7794. * Sets the current depth function to LEQUAL
  7795. */
  7796. setDepthFunctionToLessOrEqual(): void;
  7797. /**
  7798. * Gets a boolean indicating if stencil buffer is enabled
  7799. * @returns the current stencil buffer state
  7800. */
  7801. getStencilBuffer(): boolean;
  7802. /**
  7803. * Enable or disable the stencil buffer
  7804. * @param enable defines if the stencil buffer must be enabled or disabled
  7805. */
  7806. setStencilBuffer(enable: boolean): void;
  7807. /**
  7808. * Gets the current stencil mask
  7809. * @returns a number defining the new stencil mask to use
  7810. */
  7811. getStencilMask(): number;
  7812. /**
  7813. * Sets the current stencil mask
  7814. * @param mask defines the new stencil mask to use
  7815. */
  7816. setStencilMask(mask: number): void;
  7817. /**
  7818. * Gets the current stencil function
  7819. * @returns a number defining the stencil function to use
  7820. */
  7821. getStencilFunction(): number;
  7822. /**
  7823. * Gets the current stencil reference value
  7824. * @returns a number defining the stencil reference value to use
  7825. */
  7826. getStencilFunctionReference(): number;
  7827. /**
  7828. * Gets the current stencil mask
  7829. * @returns a number defining the stencil mask to use
  7830. */
  7831. getStencilFunctionMask(): number;
  7832. /**
  7833. * Sets the current stencil function
  7834. * @param stencilFunc defines the new stencil function to use
  7835. */
  7836. setStencilFunction(stencilFunc: number): void;
  7837. /**
  7838. * Sets the current stencil reference
  7839. * @param reference defines the new stencil reference to use
  7840. */
  7841. setStencilFunctionReference(reference: number): void;
  7842. /**
  7843. * Sets the current stencil mask
  7844. * @param mask defines the new stencil mask to use
  7845. */
  7846. setStencilFunctionMask(mask: number): void;
  7847. /**
  7848. * Gets the current stencil operation when stencil fails
  7849. * @returns a number defining stencil operation to use when stencil fails
  7850. */
  7851. getStencilOperationFail(): number;
  7852. /**
  7853. * Gets the current stencil operation when depth fails
  7854. * @returns a number defining stencil operation to use when depth fails
  7855. */
  7856. getStencilOperationDepthFail(): number;
  7857. /**
  7858. * Gets the current stencil operation when stencil passes
  7859. * @returns a number defining stencil operation to use when stencil passes
  7860. */
  7861. getStencilOperationPass(): number;
  7862. /**
  7863. * Sets the stencil operation to use when stencil fails
  7864. * @param operation defines the stencil operation to use when stencil fails
  7865. */
  7866. setStencilOperationFail(operation: number): void;
  7867. /**
  7868. * Sets the stencil operation to use when depth fails
  7869. * @param operation defines the stencil operation to use when depth fails
  7870. */
  7871. setStencilOperationDepthFail(operation: number): void;
  7872. /**
  7873. * Sets the stencil operation to use when stencil passes
  7874. * @param operation defines the stencil operation to use when stencil passes
  7875. */
  7876. setStencilOperationPass(operation: number): void;
  7877. /**
  7878. * Sets a boolean indicating if the dithering state is enabled or disabled
  7879. * @param value defines the dithering state
  7880. */
  7881. setDitheringState(value: boolean): void;
  7882. /**
  7883. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7884. * @param value defines the rasterizer state
  7885. */
  7886. setRasterizerState(value: boolean): void;
  7887. /**
  7888. * stop executing a render loop function and remove it from the execution array
  7889. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7890. */
  7891. stopRenderLoop(renderFunction?: () => void): void;
  7892. /** @hidden */
  7893. _renderLoop(): void;
  7894. /**
  7895. * Register and execute a render loop. The engine can have more than one render function
  7896. * @param renderFunction defines the function to continuously execute
  7897. */
  7898. runRenderLoop(renderFunction: () => void): void;
  7899. /**
  7900. * Toggle full screen mode
  7901. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7902. * @param options defines an option object to be sent to the requestFullscreen function
  7903. */
  7904. switchFullscreen(requestPointerLock: boolean): void;
  7905. /**
  7906. * Clear the current render buffer or the current render target (if any is set up)
  7907. * @param color defines the color to use
  7908. * @param backBuffer defines if the back buffer must be cleared
  7909. * @param depth defines if the depth buffer must be cleared
  7910. * @param stencil defines if the stencil buffer must be cleared
  7911. */
  7912. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7913. /**
  7914. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7915. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7916. * @param y defines the y-coordinate of the corner of the clear rectangle
  7917. * @param width defines the width of the clear rectangle
  7918. * @param height defines the height of the clear rectangle
  7919. * @param clearColor defines the clear color
  7920. */
  7921. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7922. private _viewportCached;
  7923. /** @hidden */
  7924. _viewport(x: number, y: number, width: number, height: number): void;
  7925. /**
  7926. * Set the WebGL's viewport
  7927. * @param viewport defines the viewport element to be used
  7928. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7929. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7930. */
  7931. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7932. /**
  7933. * Directly set the WebGL Viewport
  7934. * @param x defines the x coordinate of the viewport (in screen space)
  7935. * @param y defines the y coordinate of the viewport (in screen space)
  7936. * @param width defines the width of the viewport (in screen space)
  7937. * @param height defines the height of the viewport (in screen space)
  7938. * @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
  7939. */
  7940. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7941. /**
  7942. * Begin a new frame
  7943. */
  7944. beginFrame(): void;
  7945. /**
  7946. * Enf the current frame
  7947. */
  7948. endFrame(): void;
  7949. /**
  7950. * Resize the view according to the canvas' size
  7951. */
  7952. resize(): void;
  7953. /**
  7954. * Force a specific size of the canvas
  7955. * @param width defines the new canvas' width
  7956. * @param height defines the new canvas' height
  7957. */
  7958. setSize(width: number, height: number): void;
  7959. /**
  7960. * Gets a boolean indicating if a webVR device was detected
  7961. * @returns true if a webVR device was detected
  7962. */
  7963. isVRDevicePresent(): boolean;
  7964. /**
  7965. * Gets the current webVR device
  7966. * @returns the current webVR device (or null)
  7967. */
  7968. getVRDevice(): any;
  7969. /**
  7970. * Initializes a webVR display and starts listening to display change events
  7971. * The onVRDisplayChangedObservable will be notified upon these changes
  7972. * @returns The onVRDisplayChangedObservable
  7973. */
  7974. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7975. /**
  7976. * Initializes a webVR display and starts listening to display change events
  7977. * The onVRDisplayChangedObservable will be notified upon these changes
  7978. * @returns A promise containing a VRDisplay and if vr is supported
  7979. */
  7980. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7981. /**
  7982. * Call this function to switch to webVR mode
  7983. * Will do nothing if webVR is not supported or if there is no webVR device
  7984. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7985. */
  7986. enableVR(): void;
  7987. /**
  7988. * Call this function to leave webVR mode
  7989. * Will do nothing if webVR is not supported or if there is no webVR device
  7990. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7991. */
  7992. disableVR(): void;
  7993. private _onVRFullScreenTriggered;
  7994. private _getVRDisplaysAsync();
  7995. /**
  7996. * Binds the frame buffer to the specified texture.
  7997. * @param texture The texture to render to or null for the default canvas
  7998. * @param faceIndex The face of the texture to render to in case of cube texture
  7999. * @param requiredWidth The width of the target to render to
  8000. * @param requiredHeight The height of the target to render to
  8001. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8002. * @param depthStencilTexture The depth stencil texture to use to render
  8003. * @param lodLevel defines le lod level to bind to the frame buffer
  8004. */
  8005. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8006. private bindUnboundFramebuffer(framebuffer);
  8007. /**
  8008. * Unbind the current render target texture from the webGL context
  8009. * @param texture defines the render target texture to unbind
  8010. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8011. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8012. */
  8013. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8014. /**
  8015. * Unbind a list of render target textures from the webGL context
  8016. * This is used only when drawBuffer extension or webGL2 are active
  8017. * @param textures defines the render target textures to unbind
  8018. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8019. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8020. */
  8021. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8022. /**
  8023. * Force the mipmap generation for the given render target texture
  8024. * @param texture defines the render target texture to use
  8025. */
  8026. generateMipMapsForCubemap(texture: InternalTexture): void;
  8027. /**
  8028. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8029. */
  8030. flushFramebuffer(): void;
  8031. /**
  8032. * Unbind the current render target and bind the default framebuffer
  8033. */
  8034. restoreDefaultFramebuffer(): void;
  8035. /**
  8036. * Create an uniform buffer
  8037. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8038. * @param elements defines the content of the uniform buffer
  8039. * @returns the webGL uniform buffer
  8040. */
  8041. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8042. /**
  8043. * Create a dynamic uniform buffer
  8044. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8045. * @param elements defines the content of the uniform buffer
  8046. * @returns the webGL uniform buffer
  8047. */
  8048. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8049. /**
  8050. * Update an existing uniform buffer
  8051. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8052. * @param uniformBuffer defines the target uniform buffer
  8053. * @param elements defines the content to update
  8054. * @param offset defines the offset in the uniform buffer where update should start
  8055. * @param count defines the size of the data to update
  8056. */
  8057. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8058. private _resetVertexBufferBinding();
  8059. /**
  8060. * Creates a vertex buffer
  8061. * @param data the data for the vertex buffer
  8062. * @returns the new WebGL static buffer
  8063. */
  8064. createVertexBuffer(data: DataArray): WebGLBuffer;
  8065. /**
  8066. * Creates a dynamic vertex buffer
  8067. * @param data the data for the dynamic vertex buffer
  8068. * @returns the new WebGL dynamic buffer
  8069. */
  8070. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8071. /**
  8072. * Update a dynamic index buffer
  8073. * @param indexBuffer defines the target index buffer
  8074. * @param indices defines the data to update
  8075. * @param offset defines the offset in the target index buffer where update should start
  8076. */
  8077. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8078. /**
  8079. * Updates a dynamic vertex buffer.
  8080. * @param vertexBuffer the vertex buffer to update
  8081. * @param data the data used to update the vertex buffer
  8082. * @param byteOffset the byte offset of the data
  8083. * @param byteLength the byte length of the data
  8084. */
  8085. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8086. private _resetIndexBufferBinding();
  8087. /**
  8088. * Creates a new index buffer
  8089. * @param indices defines the content of the index buffer
  8090. * @param updatable defines if the index buffer must be updatable
  8091. * @returns a new webGL buffer
  8092. */
  8093. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8094. /**
  8095. * Bind a webGL buffer to the webGL context
  8096. * @param buffer defines the buffer to bind
  8097. */
  8098. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8099. /**
  8100. * Bind an uniform buffer to the current webGL context
  8101. * @param buffer defines the buffer to bind
  8102. */
  8103. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8104. /**
  8105. * Bind a buffer to the current webGL context at a given location
  8106. * @param buffer defines the buffer to bind
  8107. * @param location defines the index where to bind the buffer
  8108. */
  8109. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8110. /**
  8111. * Bind a specific block at a given index in a specific shader program
  8112. * @param shaderProgram defines the shader program
  8113. * @param blockName defines the block name
  8114. * @param index defines the index where to bind the block
  8115. */
  8116. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8117. private bindIndexBuffer(buffer);
  8118. private bindBuffer(buffer, target);
  8119. /**
  8120. * update the bound buffer with the given data
  8121. * @param data defines the data to update
  8122. */
  8123. updateArrayBuffer(data: Float32Array): void;
  8124. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  8125. private _bindIndexBufferWithCache(indexBuffer);
  8126. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  8127. /**
  8128. * Records a vertex array object
  8129. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8130. * @param vertexBuffers defines the list of vertex buffers to store
  8131. * @param indexBuffer defines the index buffer to store
  8132. * @param effect defines the effect to store
  8133. * @returns the new vertex array object
  8134. */
  8135. recordVertexArrayObject(vertexBuffers: {
  8136. [key: string]: VertexBuffer;
  8137. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8138. /**
  8139. * Bind a specific vertex array object
  8140. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8141. * @param vertexArrayObject defines the vertex array object to bind
  8142. * @param indexBuffer defines the index buffer to bind
  8143. */
  8144. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8145. /**
  8146. * Bind webGl buffers directly to the webGL context
  8147. * @param vertexBuffer defines the vertex buffer to bind
  8148. * @param indexBuffer defines the index buffer to bind
  8149. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8150. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8151. * @param effect defines the effect associated with the vertex buffer
  8152. */
  8153. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8154. private _unbindVertexArrayObject();
  8155. /**
  8156. * Bind a list of vertex buffers to the webGL context
  8157. * @param vertexBuffers defines the list of vertex buffers to bind
  8158. * @param indexBuffer defines the index buffer to bind
  8159. * @param effect defines the effect associated with the vertex buffers
  8160. */
  8161. bindBuffers(vertexBuffers: {
  8162. [key: string]: Nullable<VertexBuffer>;
  8163. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8164. /**
  8165. * Unbind all instance attributes
  8166. */
  8167. unbindInstanceAttributes(): void;
  8168. /**
  8169. * Release and free the memory of a vertex array object
  8170. * @param vao defines the vertex array object to delete
  8171. */
  8172. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8173. /** @hidden */
  8174. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8175. /**
  8176. * Creates a webGL buffer to use with instanciation
  8177. * @param capacity defines the size of the buffer
  8178. * @returns the webGL buffer
  8179. */
  8180. createInstancesBuffer(capacity: number): WebGLBuffer;
  8181. /**
  8182. * Delete a webGL buffer used with instanciation
  8183. * @param buffer defines the webGL buffer to delete
  8184. */
  8185. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8186. /**
  8187. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8188. * @param instancesBuffer defines the webGL buffer to update and bind
  8189. * @param data defines the data to store in the buffer
  8190. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8191. */
  8192. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8193. /**
  8194. * Apply all cached states (depth, culling, stencil and alpha)
  8195. */
  8196. applyStates(): void;
  8197. /**
  8198. * Send a draw order
  8199. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8200. * @param indexStart defines the starting index
  8201. * @param indexCount defines the number of index to draw
  8202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8203. */
  8204. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8205. /**
  8206. * Draw a list of points
  8207. * @param verticesStart defines the index of first vertex to draw
  8208. * @param verticesCount defines the count of vertices to draw
  8209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8210. */
  8211. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8212. /**
  8213. * Draw a list of unindexed primitives
  8214. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8215. * @param verticesStart defines the index of first vertex to draw
  8216. * @param verticesCount defines the count of vertices to draw
  8217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8218. */
  8219. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8220. /**
  8221. * Draw a list of indexed primitives
  8222. * @param fillMode defines the primitive to use
  8223. * @param indexStart defines the starting index
  8224. * @param indexCount defines the number of index to draw
  8225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8226. */
  8227. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8228. /**
  8229. * Draw a list of unindexed primitives
  8230. * @param fillMode defines the primitive to use
  8231. * @param verticesStart defines the index of first vertex to draw
  8232. * @param verticesCount defines the count of vertices to draw
  8233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8234. */
  8235. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8236. private _drawMode(fillMode);
  8237. /** @hidden */
  8238. _releaseEffect(effect: Effect): void;
  8239. /** @hidden */
  8240. _deleteProgram(program: WebGLProgram): void;
  8241. /**
  8242. * Create a new effect (used to store vertex/fragment shaders)
  8243. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8244. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8245. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8246. * @param samplers defines an array of string used to represent textures
  8247. * @param defines defines the string containing the defines to use to compile the shaders
  8248. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8249. * @param onCompiled defines a function to call when the effect creation is successful
  8250. * @param onError defines a function to call when the effect creation has failed
  8251. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8252. * @returns the new Effect
  8253. */
  8254. 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;
  8255. /**
  8256. * Create an effect to use with particle systems.
  8257. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  8258. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8259. * @param uniformsNames defines a list of attribute names
  8260. * @param samplers defines an array of string used to represent textures
  8261. * @param defines defines the string containing the defines to use to compile the shaders
  8262. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8263. * @param onCompiled defines a function to call when the effect creation is successful
  8264. * @param onError defines a function to call when the effect creation has failed
  8265. * @returns the new Effect
  8266. */
  8267. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8268. /**
  8269. * Directly creates a webGL program
  8270. * @param vertexCode defines the vertex shader code to use
  8271. * @param fragmentCode defines the fragment shader code to use
  8272. * @param context defines the webGL context to use (if not set, the current one will be used)
  8273. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8274. * @returns the new webGL program
  8275. */
  8276. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8277. /**
  8278. * Creates a webGL program
  8279. * @param vertexCode defines the vertex shader code to use
  8280. * @param fragmentCode defines the fragment shader code to use
  8281. * @param defines defines the string containing the defines to use to compile the shaders
  8282. * @param context defines the webGL context to use (if not set, the current one will be used)
  8283. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8284. * @returns the new webGL program
  8285. */
  8286. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8287. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8288. /**
  8289. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8290. * @param shaderProgram defines the webGL program to use
  8291. * @param uniformsNames defines the list of uniform names
  8292. * @returns an array of webGL uniform locations
  8293. */
  8294. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8295. /**
  8296. * Gets the lsit of active attributes for a given webGL program
  8297. * @param shaderProgram defines the webGL program to use
  8298. * @param attributesNames defines the list of attribute names to get
  8299. * @returns an array of indices indicating the offset of each attribute
  8300. */
  8301. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8302. /**
  8303. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8304. * @param effect defines the effect to activate
  8305. */
  8306. enableEffect(effect: Nullable<Effect>): void;
  8307. /**
  8308. * Set the value of an uniform to an array of int32
  8309. * @param uniform defines the webGL uniform location where to store the value
  8310. * @param array defines the array of int32 to store
  8311. */
  8312. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8313. /**
  8314. * Set the value of an uniform to an array of int32 (stored as vec2)
  8315. * @param uniform defines the webGL uniform location where to store the value
  8316. * @param array defines the array of int32 to store
  8317. */
  8318. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8319. /**
  8320. * Set the value of an uniform to an array of int32 (stored as vec3)
  8321. * @param uniform defines the webGL uniform location where to store the value
  8322. * @param array defines the array of int32 to store
  8323. */
  8324. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8325. /**
  8326. * Set the value of an uniform to an array of int32 (stored as vec4)
  8327. * @param uniform defines the webGL uniform location where to store the value
  8328. * @param array defines the array of int32 to store
  8329. */
  8330. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8331. /**
  8332. * Set the value of an uniform to an array of float32
  8333. * @param uniform defines the webGL uniform location where to store the value
  8334. * @param array defines the array of float32 to store
  8335. */
  8336. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8337. /**
  8338. * Set the value of an uniform to an array of float32 (stored as vec2)
  8339. * @param uniform defines the webGL uniform location where to store the value
  8340. * @param array defines the array of float32 to store
  8341. */
  8342. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8343. /**
  8344. * Set the value of an uniform to an array of float32 (stored as vec3)
  8345. * @param uniform defines the webGL uniform location where to store the value
  8346. * @param array defines the array of float32 to store
  8347. */
  8348. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8349. /**
  8350. * Set the value of an uniform to an array of float32 (stored as vec4)
  8351. * @param uniform defines the webGL uniform location where to store the value
  8352. * @param array defines the array of float32 to store
  8353. */
  8354. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8355. /**
  8356. * Set the value of an uniform to an array of number
  8357. * @param uniform defines the webGL uniform location where to store the value
  8358. * @param array defines the array of number to store
  8359. */
  8360. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8361. /**
  8362. * Set the value of an uniform to an array of number (stored as vec2)
  8363. * @param uniform defines the webGL uniform location where to store the value
  8364. * @param array defines the array of number to store
  8365. */
  8366. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8367. /**
  8368. * Set the value of an uniform to an array of number (stored as vec3)
  8369. * @param uniform defines the webGL uniform location where to store the value
  8370. * @param array defines the array of number to store
  8371. */
  8372. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8373. /**
  8374. * Set the value of an uniform to an array of number (stored as vec4)
  8375. * @param uniform defines the webGL uniform location where to store the value
  8376. * @param array defines the array of number to store
  8377. */
  8378. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8379. /**
  8380. * Set the value of an uniform to an array of float32 (stored as matrices)
  8381. * @param uniform defines the webGL uniform location where to store the value
  8382. * @param matrices defines the array of float32 to store
  8383. */
  8384. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8385. /**
  8386. * Set the value of an uniform to a matrix
  8387. * @param uniform defines the webGL uniform location where to store the value
  8388. * @param matrix defines the matrix to store
  8389. */
  8390. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8391. /**
  8392. * Set the value of an uniform to a matrix (3x3)
  8393. * @param uniform defines the webGL uniform location where to store the value
  8394. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8395. */
  8396. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8397. /**
  8398. * Set the value of an uniform to a matrix (2x2)
  8399. * @param uniform defines the webGL uniform location where to store the value
  8400. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8401. */
  8402. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8403. /**
  8404. * Set the value of an uniform to a number (int)
  8405. * @param uniform defines the webGL uniform location where to store the value
  8406. * @param value defines the int number to store
  8407. */
  8408. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8409. /**
  8410. * Set the value of an uniform to a number (float)
  8411. * @param uniform defines the webGL uniform location where to store the value
  8412. * @param value defines the float number to store
  8413. */
  8414. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8415. /**
  8416. * Set the value of an uniform to a vec2
  8417. * @param uniform defines the webGL uniform location where to store the value
  8418. * @param x defines the 1st component of the value
  8419. * @param y defines the 2nd component of the value
  8420. */
  8421. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8422. /**
  8423. * Set the value of an uniform to a vec3
  8424. * @param uniform defines the webGL uniform location where to store the value
  8425. * @param x defines the 1st component of the value
  8426. * @param y defines the 2nd component of the value
  8427. * @param z defines the 3rd component of the value
  8428. */
  8429. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8430. /**
  8431. * Set the value of an uniform to a boolean
  8432. * @param uniform defines the webGL uniform location where to store the value
  8433. * @param bool defines the boolean to store
  8434. */
  8435. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8436. /**
  8437. * Set the value of an uniform to a vec4
  8438. * @param uniform defines the webGL uniform location where to store the value
  8439. * @param x defines the 1st component of the value
  8440. * @param y defines the 2nd component of the value
  8441. * @param z defines the 3rd component of the value
  8442. * @param w defines the 4th component of the value
  8443. */
  8444. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8445. /**
  8446. * Set the value of an uniform to a Color3
  8447. * @param uniform defines the webGL uniform location where to store the value
  8448. * @param color3 defines the color to store
  8449. */
  8450. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8451. /**
  8452. * Set the value of an uniform to a Color3 and an alpha value
  8453. * @param uniform defines the webGL uniform location where to store the value
  8454. * @param color3 defines the color to store
  8455. * @param alpha defines the alpha component to store
  8456. */
  8457. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8458. /**
  8459. * Sets a Color4 on a uniform variable
  8460. * @param uniform defines the uniform location
  8461. * @param color4 defines the value to be set
  8462. */
  8463. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8464. /**
  8465. * Set various states to the webGL context
  8466. * @param culling defines backface culling state
  8467. * @param zOffset defines the value to apply to zOffset (0 by default)
  8468. * @param force defines if states must be applied even if cache is up to date
  8469. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8470. */
  8471. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8472. /**
  8473. * Set the z offset to apply to current rendering
  8474. * @param value defines the offset to apply
  8475. */
  8476. setZOffset(value: number): void;
  8477. /**
  8478. * Gets the current value of the zOffset
  8479. * @returns the current zOffset state
  8480. */
  8481. getZOffset(): number;
  8482. /**
  8483. * Enable or disable depth buffering
  8484. * @param enable defines the state to set
  8485. */
  8486. setDepthBuffer(enable: boolean): void;
  8487. /**
  8488. * Gets a boolean indicating if depth writing is enabled
  8489. * @returns the current depth writing state
  8490. */
  8491. getDepthWrite(): boolean;
  8492. /**
  8493. * Enable or disable depth writing
  8494. * @param enable defines the state to set
  8495. */
  8496. setDepthWrite(enable: boolean): void;
  8497. /**
  8498. * Enable or disable color writing
  8499. * @param enable defines the state to set
  8500. */
  8501. setColorWrite(enable: boolean): void;
  8502. /**
  8503. * Gets a boolean indicating if color writing is enabled
  8504. * @returns the current color writing state
  8505. */
  8506. getColorWrite(): boolean;
  8507. /**
  8508. * Sets alpha constants used by some alpha blending modes
  8509. * @param r defines the red component
  8510. * @param g defines the green component
  8511. * @param b defines the blue component
  8512. * @param a defines the alpha component
  8513. */
  8514. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8515. /**
  8516. * Sets the current alpha mode
  8517. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8518. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8519. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8520. */
  8521. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8522. /**
  8523. * Gets the current alpha mode
  8524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8525. * @returns the current alpha mode
  8526. */
  8527. getAlphaMode(): number;
  8528. /**
  8529. * Clears the list of texture accessible through engine.
  8530. * This can help preventing texture load conflict due to name collision.
  8531. */
  8532. clearInternalTexturesCache(): void;
  8533. /**
  8534. * Force the entire cache to be cleared
  8535. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8536. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8537. */
  8538. wipeCaches(bruteForce?: boolean): void;
  8539. /**
  8540. * Set the compressed texture format to use, based on the formats you have, and the formats
  8541. * supported by the hardware / browser.
  8542. *
  8543. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8544. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8545. * to API arguments needed to compressed textures. This puts the burden on the container
  8546. * generator to house the arcane code for determining these for current & future formats.
  8547. *
  8548. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8549. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8550. *
  8551. * Note: The result of this call is not taken into account when a texture is base64.
  8552. *
  8553. * @param formatsAvailable defines the list of those format families you have created
  8554. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8555. *
  8556. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8557. * @returns The extension selected.
  8558. */
  8559. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8560. /** @hidden */
  8561. _createTexture(): WebGLTexture;
  8562. /**
  8563. * Usually called from BABYLON.Texture.ts.
  8564. * Passed information to create a WebGLTexture
  8565. * @param urlArg defines a value which contains one of the following:
  8566. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8567. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8568. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8569. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8570. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8571. * @param scene needed for loading to the correct scene
  8572. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8573. * @param onLoad optional callback to be called upon successful completion
  8574. * @param onError optional callback to be called upon failure
  8575. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  8576. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8577. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8578. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8579. */
  8580. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8581. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8582. /**
  8583. * Update a raw texture
  8584. * @param texture defines the texture to update
  8585. * @param data defines the data to store in the texture
  8586. * @param format defines the format of the data
  8587. * @param invertY defines if data must be stored with Y axis inverted
  8588. * @param compression defines the compression used (null by default)
  8589. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8590. */
  8591. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8592. /**
  8593. * Creates a raw texture
  8594. * @param data defines the data to store in the texture
  8595. * @param width defines the width of the texture
  8596. * @param height defines the height of the texture
  8597. * @param format defines the format of the data
  8598. * @param generateMipMaps defines if the engine should generate the mip levels
  8599. * @param invertY defines if data must be stored with Y axis inverted
  8600. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8601. * @param compression defines the compression used (null by default)
  8602. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8603. * @returns the raw texture inside an InternalTexture
  8604. */
  8605. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8606. private _unpackFlipYCached;
  8607. /** @hidden */
  8608. _unpackFlipY(value: boolean): void;
  8609. /**
  8610. * Creates a dynamic texture
  8611. * @param width defines the width of the texture
  8612. * @param height defines the height of the texture
  8613. * @param generateMipMaps defines if the engine should generate the mip levels
  8614. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8615. * @returns the dynamic texture inside an InternalTexture
  8616. */
  8617. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8618. /**
  8619. * Update the sampling mode of a given texture
  8620. * @param samplingMode defines the required sampling mode
  8621. * @param texture defines the texture to update
  8622. */
  8623. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8624. /**
  8625. * Update the content of a dynamic texture
  8626. * @param texture defines the texture to update
  8627. * @param canvas defines the canvas containing the source
  8628. * @param invertY defines if data must be stored with Y axis inverted
  8629. * @param premulAlpha defines if alpha is stored as premultiplied
  8630. * @param format defines the format of the data
  8631. */
  8632. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8633. /**
  8634. * Update a video texture
  8635. * @param texture defines the texture to update
  8636. * @param video defines the video element to use
  8637. * @param invertY defines if data must be stored with Y axis inverted
  8638. */
  8639. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8640. /**
  8641. * Updates a depth texture Comparison Mode and Function.
  8642. * If the comparison Function is equal to 0, the mode will be set to none.
  8643. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8644. * @param texture The texture to set the comparison function for
  8645. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8646. */
  8647. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8648. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8649. /**
  8650. * Creates a depth stencil texture.
  8651. * This is only available in WebGL 2 or with the depth texture extension available.
  8652. * @param size The size of face edge in the texture.
  8653. * @param options The options defining the texture.
  8654. * @returns The texture
  8655. */
  8656. createDepthStencilTexture(size: number | {
  8657. width: number;
  8658. height: number;
  8659. }, options: DepthTextureCreationOptions): InternalTexture;
  8660. /**
  8661. * Creates a depth stencil texture.
  8662. * This is only available in WebGL 2 or with the depth texture extension available.
  8663. * @param size The size of face edge in the texture.
  8664. * @param options The options defining the texture.
  8665. * @returns The texture
  8666. */
  8667. private _createDepthStencilTexture(size, options);
  8668. /**
  8669. * Creates a depth stencil cube texture.
  8670. * This is only available in WebGL 2.
  8671. * @param size The size of face edge in the cube texture.
  8672. * @param options The options defining the cube texture.
  8673. * @returns The cube texture
  8674. */
  8675. private _createDepthStencilCubeTexture(size, options);
  8676. /**
  8677. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8678. * @param renderTarget The render target to set the frame buffer for
  8679. */
  8680. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8681. /**
  8682. * Creates a new render target texture
  8683. * @param size defines the size of the texture
  8684. * @param options defines the options used to create the texture
  8685. * @returns a new render target texture stored in an InternalTexture
  8686. */
  8687. createRenderTargetTexture(size: number | {
  8688. width: number;
  8689. height: number;
  8690. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8691. /**
  8692. * Create a multi render target texture
  8693. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8694. * @param size defines the size of the texture
  8695. * @param options defines the creation options
  8696. * @returns the cube texture as an InternalTexture
  8697. */
  8698. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8699. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8700. /**
  8701. * Updates the sample count of a render target texture
  8702. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8703. * @param texture defines the texture to update
  8704. * @param samples defines the sample count to set
  8705. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8706. */
  8707. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8708. /**
  8709. * Update the sample count for a given multiple render target texture
  8710. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8711. * @param textures defines the textures to update
  8712. * @param samples defines the sample count to set
  8713. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8714. */
  8715. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8716. /** @hidden */
  8717. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8718. /** @hidden */
  8719. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8720. /** @hidden */
  8721. _uploadImageToTexture(texture: InternalTexture, faceIndex: number, lod: number, image: HTMLImageElement): void;
  8722. /**
  8723. * Creates a new render target cube texture
  8724. * @param size defines the size of the texture
  8725. * @param options defines the options used to create the texture
  8726. * @returns a new render target cube texture stored in an InternalTexture
  8727. */
  8728. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8729. /**
  8730. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8731. * @param rootUrl defines the url where the file to load is located
  8732. * @param scene defines the current scene
  8733. * @param lodScale defines scale to apply to the mip map selection
  8734. * @param lodOffset defines offset to apply to the mip map selection
  8735. * @param onLoad defines an optional callback raised when the texture is loaded
  8736. * @param onError defines an optional callback raised if there is an issue to load the texture
  8737. * @param format defines the format of the data
  8738. * @param forcedExtension defines the extension to use to pick the right loader
  8739. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8740. * @returns the cube texture as an InternalTexture
  8741. */
  8742. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8743. /**
  8744. * Creates a cube texture
  8745. * @param rootUrl defines the url where the files to load is located
  8746. * @param scene defines the current scene
  8747. * @param files defines the list of files to load (1 per face)
  8748. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8749. * @param onLoad defines an optional callback raised when the texture is loaded
  8750. * @param onError defines an optional callback raised if there is an issue to load the texture
  8751. * @param format defines the format of the data
  8752. * @param forcedExtension defines the extension to use to pick the right loader
  8753. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8756. * @returns the cube texture as an InternalTexture
  8757. */
  8758. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number): InternalTexture;
  8759. private setCubeMapTextureParams(gl, loadMipmap);
  8760. /**
  8761. * Update a raw cube texture
  8762. * @param texture defines the texture to udpdate
  8763. * @param data defines the data to store
  8764. * @param format defines the data format
  8765. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8766. * @param invertY defines if data must be stored with Y axis inverted
  8767. * @param compression defines the compression used (null by default)
  8768. * @param level defines which level of the texture to update
  8769. */
  8770. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8771. /**
  8772. * Creates a new raw cube texture
  8773. * @param data defines the array of data to use to create each face
  8774. * @param size defines the size of the textures
  8775. * @param format defines the format of the data
  8776. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8777. * @param generateMipMaps defines if the engine should generate the mip levels
  8778. * @param invertY defines if data must be stored with Y axis inverted
  8779. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8780. * @param compression defines the compression used (null by default)
  8781. * @returns the cube texture as an InternalTexture
  8782. */
  8783. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8784. /**
  8785. * Creates a new raw cube texture from a specified url
  8786. * @param url defines the url where the data is located
  8787. * @param scene defines the current scene
  8788. * @param size defines the size of the textures
  8789. * @param format defines the format of the data
  8790. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8791. * @param noMipmap defines if the engine should avoid generating the mip levels
  8792. * @param callback defines a callback used to extract texture data from loaded data
  8793. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8794. * @param onLoad defines a callback called when texture is loaded
  8795. * @param onError defines a callback called if there is an error
  8796. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8797. * @param invertY defines if data must be stored with Y axis inverted
  8798. * @returns the cube texture as an InternalTexture
  8799. */
  8800. 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;
  8801. /**
  8802. * Update a raw 3D texture
  8803. * @param texture defines the texture to update
  8804. * @param data defines the data to store
  8805. * @param format defines the data format
  8806. * @param invertY defines if data must be stored with Y axis inverted
  8807. * @param compression defines the used compression (can be null)
  8808. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8809. */
  8810. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8811. /**
  8812. * Creates a new raw 3D texture
  8813. * @param data defines the data used to create the texture
  8814. * @param width defines the width of the texture
  8815. * @param height defines the height of the texture
  8816. * @param depth defines the depth of the texture
  8817. * @param format defines the format of the texture
  8818. * @param generateMipMaps defines if the engine must generate mip levels
  8819. * @param invertY defines if data must be stored with Y axis inverted
  8820. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8821. * @param compression defines the compressed used (can be null)
  8822. * @param textureType defines the compressed used (can be null)
  8823. * @returns a new raw 3D texture (stored in an InternalTexture)
  8824. */
  8825. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8826. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8827. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8828. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8829. /** @hidden */
  8830. _releaseFramebufferObjects(texture: InternalTexture): void;
  8831. /** @hidden */
  8832. _releaseTexture(texture: InternalTexture): void;
  8833. private setProgram(program);
  8834. private _boundUniforms;
  8835. /**
  8836. * Binds an effect to the webGL context
  8837. * @param effect defines the effect to bind
  8838. */
  8839. bindSamplers(effect: Effect): void;
  8840. private _moveBoundTextureOnTop(internalTexture);
  8841. private _getCorrectTextureChannel(channel, internalTexture);
  8842. private _linkTrackers(previous, next);
  8843. private _removeDesignatedSlot(internalTexture);
  8844. private _activateCurrentTexture();
  8845. /** @hidden */
  8846. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8847. /** @hidden */
  8848. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8849. /**
  8850. * Sets a texture to the webGL context from a postprocess
  8851. * @param channel defines the channel to use
  8852. * @param postProcess defines the source postprocess
  8853. */
  8854. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8855. /**
  8856. * Binds the output of the passed in post process to the texture channel specified
  8857. * @param channel The channel the texture should be bound to
  8858. * @param postProcess The post process which's output should be bound
  8859. */
  8860. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8861. /**
  8862. * Unbind all textures from the webGL context
  8863. */
  8864. unbindAllTextures(): void;
  8865. /**
  8866. * Sets a texture to the according uniform.
  8867. * @param channel The texture channel
  8868. * @param uniform The uniform to set
  8869. * @param texture The texture to apply
  8870. */
  8871. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8872. /**
  8873. * Sets a depth stencil texture from a render target to the according uniform.
  8874. * @param channel The texture channel
  8875. * @param uniform The uniform to set
  8876. * @param texture The render target texture containing the depth stencil texture to apply
  8877. */
  8878. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8879. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8880. private _getTextureWrapMode(mode);
  8881. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8882. /**
  8883. * Sets an array of texture to the webGL context
  8884. * @param channel defines the channel where the texture array must be set
  8885. * @param uniform defines the associated uniform location
  8886. * @param textures defines the array of textures to bind
  8887. */
  8888. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8889. /** @hidden */
  8890. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8891. private _setTextureParameterFloat(target, parameter, value, texture);
  8892. private _setTextureParameterInteger(target, parameter, value, texture?);
  8893. /**
  8894. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8895. * @param x defines the x coordinate of the rectangle where pixels must be read
  8896. * @param y defines the y coordinate of the rectangle where pixels must be read
  8897. * @param width defines the width of the rectangle where pixels must be read
  8898. * @param height defines the height of the rectangle where pixels must be read
  8899. * @returns a Uint8Array containing RGBA colors
  8900. */
  8901. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8902. /**
  8903. * Add an externaly attached data from its key.
  8904. * This method call will fail and return false, if such key already exists.
  8905. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8906. * @param key the unique key that identifies the data
  8907. * @param data the data object to associate to the key for this Engine instance
  8908. * @return true if no such key were already present and the data was added successfully, false otherwise
  8909. */
  8910. addExternalData<T>(key: string, data: T): boolean;
  8911. /**
  8912. * Get an externaly attached data from its key
  8913. * @param key the unique key that identifies the data
  8914. * @return the associated data, if present (can be null), or undefined if not present
  8915. */
  8916. getExternalData<T>(key: string): T;
  8917. /**
  8918. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8919. * @param key the unique key that identifies the data
  8920. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8921. * @return the associated data, can be null if the factory returned null.
  8922. */
  8923. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8924. /**
  8925. * Remove an externaly attached data from the Engine instance
  8926. * @param key the unique key that identifies the data
  8927. * @return true if the data was successfully removed, false if it doesn't exist
  8928. */
  8929. removeExternalData(key: string): boolean;
  8930. /**
  8931. * Unbind all vertex attributes from the webGL context
  8932. */
  8933. unbindAllAttributes(): void;
  8934. /**
  8935. * 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
  8936. */
  8937. releaseEffects(): void;
  8938. /**
  8939. * Dispose and release all associated resources
  8940. */
  8941. dispose(): void;
  8942. /**
  8943. * Display the loading screen
  8944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8945. */
  8946. displayLoadingUI(): void;
  8947. /**
  8948. * Hide the loading screen
  8949. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8950. */
  8951. hideLoadingUI(): void;
  8952. /**
  8953. * Gets the current loading screen object
  8954. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8955. */
  8956. /**
  8957. * Sets the current loading screen object
  8958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8959. */
  8960. loadingScreen: ILoadingScreen;
  8961. /**
  8962. * Sets the current loading screen text
  8963. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8964. */
  8965. loadingUIText: string;
  8966. /**
  8967. * Sets the current loading screen background color
  8968. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8969. */
  8970. loadingUIBackgroundColor: string;
  8971. /**
  8972. * Attach a new callback raised when context lost event is fired
  8973. * @param callback defines the callback to call
  8974. */
  8975. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8976. /**
  8977. * Attach a new callback raised when context restored event is fired
  8978. * @param callback defines the callback to call
  8979. */
  8980. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8981. /**
  8982. * Gets the source code of the vertex shader associated with a specific webGL program
  8983. * @param program defines the program to use
  8984. * @returns a string containing the source code of the vertex shader associated with the program
  8985. */
  8986. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8987. /**
  8988. * Gets the source code of the fragment shader associated with a specific webGL program
  8989. * @param program defines the program to use
  8990. * @returns a string containing the source code of the fragment shader associated with the program
  8991. */
  8992. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8993. /**
  8994. * Get the current error code of the webGL context
  8995. * @returns the error code
  8996. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8997. */
  8998. getError(): number;
  8999. /**
  9000. * Gets the current framerate
  9001. * @returns a number representing the framerate
  9002. */
  9003. getFps(): number;
  9004. /**
  9005. * Gets the time spent between current and previous frame
  9006. * @returns a number representing the delta time in ms
  9007. */
  9008. getDeltaTime(): number;
  9009. private _measureFps();
  9010. /** @hidden */
  9011. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9012. private _canRenderToFloatFramebuffer();
  9013. private _canRenderToHalfFloatFramebuffer();
  9014. private _canRenderToFramebuffer(type);
  9015. /** @hidden */
  9016. _getWebGLTextureType(type: number): number;
  9017. private _getInternalFormat(format);
  9018. /** @hidden */
  9019. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9020. /** @hidden */
  9021. _getRGBAMultiSampleBufferFormat(type: number): number;
  9022. /**
  9023. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  9024. * @return the new query
  9025. */
  9026. createQuery(): WebGLQuery;
  9027. /**
  9028. * Delete and release a webGL query
  9029. * @param query defines the query to delete
  9030. * @return the current engine
  9031. */
  9032. deleteQuery(query: WebGLQuery): Engine;
  9033. /**
  9034. * Check if a given query has resolved and got its value
  9035. * @param query defines the query to check
  9036. * @returns true if the query got its value
  9037. */
  9038. isQueryResultAvailable(query: WebGLQuery): boolean;
  9039. /**
  9040. * Gets the value of a given query
  9041. * @param query defines the query to check
  9042. * @returns the value of the query
  9043. */
  9044. getQueryResult(query: WebGLQuery): number;
  9045. /**
  9046. * Initiates an occlusion query
  9047. * @param algorithmType defines the algorithm to use
  9048. * @param query defines the query to use
  9049. * @returns the current engine
  9050. * @see http://doc.babylonjs.com/features/occlusionquery
  9051. */
  9052. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  9053. /**
  9054. * Ends an occlusion query
  9055. * @see http://doc.babylonjs.com/features/occlusionquery
  9056. * @param algorithmType defines the algorithm to use
  9057. * @returns the current engine
  9058. */
  9059. endOcclusionQuery(algorithmType: number): Engine;
  9060. private _createTimeQuery();
  9061. private _deleteTimeQuery(query);
  9062. private _getTimeQueryResult(query);
  9063. private _getTimeQueryAvailability(query);
  9064. private _currentNonTimestampToken;
  9065. /**
  9066. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  9067. * Please note that only one query can be issued at a time
  9068. * @returns a time token used to track the time span
  9069. */
  9070. startTimeQuery(): Nullable<_TimeToken>;
  9071. /**
  9072. * Ends a time query
  9073. * @param token defines the token used to measure the time span
  9074. * @returns the time spent (in ns)
  9075. */
  9076. endTimeQuery(token: _TimeToken): int;
  9077. private getGlAlgorithmType(algorithmType);
  9078. /**
  9079. * Creates a webGL transform feedback object
  9080. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  9081. * @returns the webGL transform feedback object
  9082. */
  9083. createTransformFeedback(): WebGLTransformFeedback;
  9084. /**
  9085. * Delete a webGL transform feedback object
  9086. * @param value defines the webGL transform feedback object to delete
  9087. */
  9088. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  9089. /**
  9090. * Bind a webGL transform feedback object to the webgl context
  9091. * @param value defines the webGL transform feedback object to bind
  9092. */
  9093. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  9094. /**
  9095. * Begins a transform feedback operation
  9096. * @param usePoints defines if points or triangles must be used
  9097. */
  9098. beginTransformFeedback(usePoints?: boolean): void;
  9099. /**
  9100. * Ends a transform feedback operation
  9101. */
  9102. endTransformFeedback(): void;
  9103. /**
  9104. * Specify the varyings to use with transform feedback
  9105. * @param program defines the associated webGL program
  9106. * @param value defines the list of strings representing the varying names
  9107. */
  9108. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  9109. /**
  9110. * Bind a webGL buffer for a transform feedback operation
  9111. * @param value defines the webGL buffer to bind
  9112. */
  9113. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  9114. /** @hidden */
  9115. _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;
  9116. /** @hidden */
  9117. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9118. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  9119. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  9120. /**
  9121. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9122. * @returns true if the engine can be created
  9123. * @ignorenaming
  9124. */
  9125. static isSupported(): boolean;
  9126. }
  9127. }
  9128. declare module BABYLON {
  9129. class NullEngineOptions {
  9130. renderWidth: number;
  9131. renderHeight: number;
  9132. textureSize: number;
  9133. deterministicLockstep: boolean;
  9134. lockstepMaxSteps: number;
  9135. }
  9136. /**
  9137. * The null engine class provides support for headless version of babylon.js.
  9138. * This can be used in server side scenario or for testing purposes
  9139. */
  9140. class NullEngine extends Engine {
  9141. private _options;
  9142. isDeterministicLockStep(): boolean;
  9143. getLockstepMaxSteps(): number;
  9144. getHardwareScalingLevel(): number;
  9145. constructor(options?: NullEngineOptions);
  9146. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9147. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9148. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9149. getRenderWidth(useScreen?: boolean): number;
  9150. getRenderHeight(useScreen?: boolean): number;
  9151. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9152. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9153. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9154. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9155. bindSamplers(effect: Effect): void;
  9156. enableEffect(effect: Effect): void;
  9157. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9158. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9159. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9160. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9161. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9162. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9163. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9164. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9165. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9166. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9167. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9168. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9169. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9170. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9171. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9172. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9173. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9174. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9175. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9176. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9177. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9178. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9179. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9180. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9181. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9182. bindBuffers(vertexBuffers: {
  9183. [key: string]: VertexBuffer;
  9184. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9185. wipeCaches(bruteForce?: boolean): void;
  9186. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9187. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9188. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9189. _createTexture(): WebGLTexture;
  9190. _releaseTexture(texture: InternalTexture): void;
  9191. 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;
  9192. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9193. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9195. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9196. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9197. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9198. /**
  9199. * Updates a dynamic vertex buffer.
  9200. * @param vertexBuffer the vertex buffer to update
  9201. * @param data the data used to update the vertex buffer
  9202. * @param byteOffset the byte offset of the data (optional)
  9203. * @param byteLength the byte length of the data (optional)
  9204. */
  9205. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9206. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9207. _bindTexture(channel: number, texture: InternalTexture): void;
  9208. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9209. releaseEffects(): void;
  9210. }
  9211. }
  9212. interface WebGLRenderingContext {
  9213. readonly RASTERIZER_DISCARD: number;
  9214. readonly DEPTH_COMPONENT24: number;
  9215. readonly TEXTURE_3D: number;
  9216. readonly TEXTURE_2D_ARRAY: number;
  9217. readonly TEXTURE_COMPARE_FUNC: number;
  9218. readonly TEXTURE_COMPARE_MODE: number;
  9219. readonly COMPARE_REF_TO_TEXTURE: number;
  9220. readonly TEXTURE_WRAP_R: number;
  9221. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9222. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9223. 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;
  9224. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9225. readonly TRANSFORM_FEEDBACK: number;
  9226. readonly INTERLEAVED_ATTRIBS: number;
  9227. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9228. createTransformFeedback(): WebGLTransformFeedback;
  9229. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9230. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9231. beginTransformFeedback(primitiveMode: number): void;
  9232. endTransformFeedback(): void;
  9233. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9234. }
  9235. interface ImageBitmap {
  9236. readonly width: number;
  9237. readonly height: number;
  9238. close(): void;
  9239. }
  9240. interface WebGLQuery extends WebGLObject {
  9241. }
  9242. declare var WebGLQuery: {
  9243. prototype: WebGLQuery;
  9244. new (): WebGLQuery;
  9245. };
  9246. interface WebGLSampler extends WebGLObject {
  9247. }
  9248. declare var WebGLSampler: {
  9249. prototype: WebGLSampler;
  9250. new (): WebGLSampler;
  9251. };
  9252. interface WebGLSync extends WebGLObject {
  9253. }
  9254. declare var WebGLSync: {
  9255. prototype: WebGLSync;
  9256. new (): WebGLSync;
  9257. };
  9258. interface WebGLTransformFeedback extends WebGLObject {
  9259. }
  9260. declare var WebGLTransformFeedback: {
  9261. prototype: WebGLTransformFeedback;
  9262. new (): WebGLTransformFeedback;
  9263. };
  9264. interface WebGLVertexArrayObject extends WebGLObject {
  9265. }
  9266. declare var WebGLVertexArrayObject: {
  9267. prototype: WebGLVertexArrayObject;
  9268. new (): WebGLVertexArrayObject;
  9269. };
  9270. declare module BABYLON {
  9271. class KeyboardEventTypes {
  9272. static _KEYDOWN: number;
  9273. static _KEYUP: number;
  9274. static readonly KEYDOWN: number;
  9275. static readonly KEYUP: number;
  9276. }
  9277. class KeyboardInfo {
  9278. type: number;
  9279. event: KeyboardEvent;
  9280. constructor(type: number, event: KeyboardEvent);
  9281. }
  9282. /**
  9283. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9284. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9285. */
  9286. class KeyboardInfoPre extends KeyboardInfo {
  9287. constructor(type: number, event: KeyboardEvent);
  9288. skipOnPointerObservable: boolean;
  9289. }
  9290. }
  9291. declare module BABYLON {
  9292. class PointerEventTypes {
  9293. static _POINTERDOWN: number;
  9294. static _POINTERUP: number;
  9295. static _POINTERMOVE: number;
  9296. static _POINTERWHEEL: number;
  9297. static _POINTERPICK: number;
  9298. static _POINTERTAP: number;
  9299. static _POINTERDOUBLETAP: number;
  9300. static readonly POINTERDOWN: number;
  9301. static readonly POINTERUP: number;
  9302. static readonly POINTERMOVE: number;
  9303. static readonly POINTERWHEEL: number;
  9304. static readonly POINTERPICK: number;
  9305. static readonly POINTERTAP: number;
  9306. static readonly POINTERDOUBLETAP: number;
  9307. }
  9308. class PointerInfoBase {
  9309. type: number;
  9310. event: PointerEvent | MouseWheelEvent;
  9311. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9312. }
  9313. /**
  9314. * This class is used to store pointer related info for the onPrePointerObservable event.
  9315. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9316. */
  9317. class PointerInfoPre extends PointerInfoBase {
  9318. /**
  9319. * Ray from a pointer if availible (eg. 6dof controller)
  9320. */
  9321. ray: Nullable<Ray>;
  9322. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9323. localPosition: Vector2;
  9324. skipOnPointerObservable: boolean;
  9325. }
  9326. /**
  9327. * This type contains all the data related to a pointer event in Babylon.js.
  9328. * 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.
  9329. */
  9330. class PointerInfo extends PointerInfoBase {
  9331. pickInfo: Nullable<PickingInfo>;
  9332. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9333. }
  9334. }
  9335. declare module BABYLON {
  9336. class StickValues {
  9337. x: number;
  9338. y: number;
  9339. constructor(x: number, y: number);
  9340. }
  9341. interface GamepadButtonChanges {
  9342. changed: boolean;
  9343. pressChanged: boolean;
  9344. touchChanged: boolean;
  9345. valueChanged: boolean;
  9346. }
  9347. class Gamepad {
  9348. id: string;
  9349. index: number;
  9350. browserGamepad: any;
  9351. type: number;
  9352. private _leftStick;
  9353. private _rightStick;
  9354. _isConnected: boolean;
  9355. private _leftStickAxisX;
  9356. private _leftStickAxisY;
  9357. private _rightStickAxisX;
  9358. private _rightStickAxisY;
  9359. private _onleftstickchanged;
  9360. private _onrightstickchanged;
  9361. static GAMEPAD: number;
  9362. static GENERIC: number;
  9363. static XBOX: number;
  9364. static POSE_ENABLED: number;
  9365. protected _invertLeftStickY: boolean;
  9366. readonly isConnected: boolean;
  9367. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9368. onleftstickchanged(callback: (values: StickValues) => void): void;
  9369. onrightstickchanged(callback: (values: StickValues) => void): void;
  9370. leftStick: StickValues;
  9371. rightStick: StickValues;
  9372. update(): void;
  9373. dispose(): void;
  9374. }
  9375. class GenericPad extends Gamepad {
  9376. private _buttons;
  9377. private _onbuttondown;
  9378. private _onbuttonup;
  9379. onButtonDownObservable: Observable<number>;
  9380. onButtonUpObservable: Observable<number>;
  9381. onbuttondown(callback: (buttonPressed: number) => void): void;
  9382. onbuttonup(callback: (buttonReleased: number) => void): void;
  9383. constructor(id: string, index: number, browserGamepad: any);
  9384. private _setButtonValue(newValue, currentValue, buttonIndex);
  9385. update(): void;
  9386. dispose(): void;
  9387. }
  9388. }
  9389. declare module BABYLON {
  9390. class GamepadManager {
  9391. private _scene;
  9392. private _babylonGamepads;
  9393. private _oneGamepadConnected;
  9394. _isMonitoring: boolean;
  9395. private _gamepadEventSupported;
  9396. private _gamepadSupport;
  9397. onGamepadConnectedObservable: Observable<Gamepad>;
  9398. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9399. private _onGamepadConnectedEvent;
  9400. private _onGamepadDisconnectedEvent;
  9401. constructor(_scene?: Scene | undefined);
  9402. readonly gamepads: Gamepad[];
  9403. getGamepadByType(type?: number): Nullable<Gamepad>;
  9404. dispose(): void;
  9405. private _addNewGamepad(gamepad);
  9406. private _startMonitoringGamepads();
  9407. private _stopMonitoringGamepads();
  9408. _checkGamepadsStatus(): void;
  9409. private _updateGamepadObjects();
  9410. }
  9411. }
  9412. declare module BABYLON {
  9413. /**
  9414. * Defines supported buttons for XBox360 compatible gamepads
  9415. */
  9416. enum Xbox360Button {
  9417. /** A */
  9418. A = 0,
  9419. /** B */
  9420. B = 1,
  9421. /** X */
  9422. X = 2,
  9423. /** Y */
  9424. Y = 3,
  9425. /** Start */
  9426. Start = 4,
  9427. /** Back */
  9428. Back = 5,
  9429. /** Left button */
  9430. LB = 6,
  9431. /** Right button */
  9432. RB = 7,
  9433. /** Left stick */
  9434. LeftStick = 8,
  9435. /** Right stick */
  9436. RightStick = 9,
  9437. }
  9438. /** Defines values for XBox360 DPad */
  9439. enum Xbox360Dpad {
  9440. /** Up */
  9441. Up = 0,
  9442. /** Down */
  9443. Down = 1,
  9444. /** Left */
  9445. Left = 2,
  9446. /** Right */
  9447. Right = 3,
  9448. }
  9449. /**
  9450. * Defines a XBox360 gamepad
  9451. */
  9452. class Xbox360Pad extends Gamepad {
  9453. private _leftTrigger;
  9454. private _rightTrigger;
  9455. private _onlefttriggerchanged;
  9456. private _onrighttriggerchanged;
  9457. private _onbuttondown;
  9458. private _onbuttonup;
  9459. private _ondpaddown;
  9460. private _ondpadup;
  9461. /** Observable raised when a button is pressed */
  9462. onButtonDownObservable: Observable<Xbox360Button>;
  9463. /** Observable raised when a button is released */
  9464. onButtonUpObservable: Observable<Xbox360Button>;
  9465. /** Observable raised when a pad is pressed */
  9466. onPadDownObservable: Observable<Xbox360Dpad>;
  9467. /** Observable raised when a pad is released */
  9468. onPadUpObservable: Observable<Xbox360Dpad>;
  9469. private _buttonA;
  9470. private _buttonB;
  9471. private _buttonX;
  9472. private _buttonY;
  9473. private _buttonBack;
  9474. private _buttonStart;
  9475. private _buttonLB;
  9476. private _buttonRB;
  9477. private _buttonLeftStick;
  9478. private _buttonRightStick;
  9479. private _dPadUp;
  9480. private _dPadDown;
  9481. private _dPadLeft;
  9482. private _dPadRight;
  9483. private _isXboxOnePad;
  9484. /**
  9485. * Creates a new XBox360 gamepad object
  9486. * @param id defines the id of this gamepad
  9487. * @param index defines its index
  9488. * @param gamepad defines the internal HTML gamepad object
  9489. * @param xboxOne defines if it is a XBox One gamepad
  9490. */
  9491. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9492. /**
  9493. * Defines the callback to call when left trigger is pressed
  9494. * @param callback defines the callback to use
  9495. */
  9496. onlefttriggerchanged(callback: (value: number) => void): void;
  9497. /**
  9498. * Defines the callback to call when right trigger is pressed
  9499. * @param callback defines the callback to use
  9500. */
  9501. onrighttriggerchanged(callback: (value: number) => void): void;
  9502. /**
  9503. * Gets or sets left trigger value
  9504. */
  9505. leftTrigger: number;
  9506. /**
  9507. * Gets or sets right trigger value
  9508. */
  9509. rightTrigger: number;
  9510. /**
  9511. * Defines the callback to call when a button is pressed
  9512. * @param callback defines the callback to use
  9513. */
  9514. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9515. /**
  9516. * Defines the callback to call when a button is released
  9517. * @param callback defines the callback to use
  9518. */
  9519. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9520. /**
  9521. * Defines the callback to call when a pad is pressed
  9522. * @param callback defines the callback to use
  9523. */
  9524. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9525. /**
  9526. * Defines the callback to call when a pad is released
  9527. * @param callback defines the callback to use
  9528. */
  9529. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9530. private _setButtonValue(newValue, currentValue, buttonType);
  9531. private _setDPadValue(newValue, currentValue, buttonType);
  9532. /** Gets or sets value of A button */
  9533. buttonA: number;
  9534. /** Gets or sets value of B button */
  9535. buttonB: number;
  9536. /** Gets or sets value of X button */
  9537. buttonX: number;
  9538. /** Gets or sets value of Y button */
  9539. buttonY: number;
  9540. /** Gets or sets value of Start button */
  9541. buttonStart: number;
  9542. /** Gets or sets value of Back button */
  9543. buttonBack: number;
  9544. /** Gets or sets value of Left button */
  9545. buttonLB: number;
  9546. /** Gets or sets value of Right button */
  9547. buttonRB: number;
  9548. /** Gets or sets value of left stick */
  9549. buttonLeftStick: number;
  9550. /** Gets or sets value of right stick */
  9551. buttonRightStick: number;
  9552. /** Gets or sets value of DPad up */
  9553. dPadUp: number;
  9554. /** Gets or sets value of DPad down */
  9555. dPadDown: number;
  9556. /** Gets or sets value of DPad left */
  9557. dPadLeft: number;
  9558. /** Gets or sets value of DPad right */
  9559. dPadRight: number;
  9560. /**
  9561. * Force the gamepad to synchronize with device values
  9562. */
  9563. update(): void;
  9564. dispose(): void;
  9565. }
  9566. }
  9567. declare module BABYLON {
  9568. /**
  9569. * Represents the different options available during the creation of
  9570. * a Environment helper.
  9571. *
  9572. * This can control the default ground, skybox and image processing setup of your scene.
  9573. */
  9574. interface IEnvironmentHelperOptions {
  9575. /**
  9576. * Specifies wether or not to create a ground.
  9577. * True by default.
  9578. */
  9579. createGround: boolean;
  9580. /**
  9581. * Specifies the ground size.
  9582. * 15 by default.
  9583. */
  9584. groundSize: number;
  9585. /**
  9586. * The texture used on the ground for the main color.
  9587. * Comes from the BabylonJS CDN by default.
  9588. *
  9589. * Remarks: Can be either a texture or a url.
  9590. */
  9591. groundTexture: string | BaseTexture;
  9592. /**
  9593. * The color mixed in the ground texture by default.
  9594. * BabylonJS clearColor by default.
  9595. */
  9596. groundColor: Color3;
  9597. /**
  9598. * Specifies the ground opacity.
  9599. * 1 by default.
  9600. */
  9601. groundOpacity: number;
  9602. /**
  9603. * Enables the ground to receive shadows.
  9604. * True by default.
  9605. */
  9606. enableGroundShadow: boolean;
  9607. /**
  9608. * Helps preventing the shadow to be fully black on the ground.
  9609. * 0.5 by default.
  9610. */
  9611. groundShadowLevel: number;
  9612. /**
  9613. * Creates a mirror texture attach to the ground.
  9614. * false by default.
  9615. */
  9616. enableGroundMirror: boolean;
  9617. /**
  9618. * Specifies the ground mirror size ratio.
  9619. * 0.3 by default as the default kernel is 64.
  9620. */
  9621. groundMirrorSizeRatio: number;
  9622. /**
  9623. * Specifies the ground mirror blur kernel size.
  9624. * 64 by default.
  9625. */
  9626. groundMirrorBlurKernel: number;
  9627. /**
  9628. * Specifies the ground mirror visibility amount.
  9629. * 1 by default
  9630. */
  9631. groundMirrorAmount: number;
  9632. /**
  9633. * Specifies the ground mirror reflectance weight.
  9634. * This uses the standard weight of the background material to setup the fresnel effect
  9635. * of the mirror.
  9636. * 1 by default.
  9637. */
  9638. groundMirrorFresnelWeight: number;
  9639. /**
  9640. * Specifies the ground mirror Falloff distance.
  9641. * This can helps reducing the size of the reflection.
  9642. * 0 by Default.
  9643. */
  9644. groundMirrorFallOffDistance: number;
  9645. /**
  9646. * Specifies the ground mirror texture type.
  9647. * Unsigned Int by Default.
  9648. */
  9649. groundMirrorTextureType: number;
  9650. /**
  9651. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  9652. * the shown objects.
  9653. */
  9654. groundYBias: number;
  9655. /**
  9656. * Specifies wether or not to create a skybox.
  9657. * True by default.
  9658. */
  9659. createSkybox: boolean;
  9660. /**
  9661. * Specifies the skybox size.
  9662. * 20 by default.
  9663. */
  9664. skyboxSize: number;
  9665. /**
  9666. * The texture used on the skybox for the main color.
  9667. * Comes from the BabylonJS CDN by default.
  9668. *
  9669. * Remarks: Can be either a texture or a url.
  9670. */
  9671. skyboxTexture: string | BaseTexture;
  9672. /**
  9673. * The color mixed in the skybox texture by default.
  9674. * BabylonJS clearColor by default.
  9675. */
  9676. skyboxColor: Color3;
  9677. /**
  9678. * The background rotation around the Y axis of the scene.
  9679. * This helps aligning the key lights of your scene with the background.
  9680. * 0 by default.
  9681. */
  9682. backgroundYRotation: number;
  9683. /**
  9684. * Compute automatically the size of the elements to best fit with the scene.
  9685. */
  9686. sizeAuto: boolean;
  9687. /**
  9688. * Default position of the rootMesh if autoSize is not true.
  9689. */
  9690. rootPosition: Vector3;
  9691. /**
  9692. * Sets up the image processing in the scene.
  9693. * true by default.
  9694. */
  9695. setupImageProcessing: boolean;
  9696. /**
  9697. * The texture used as your environment texture in the scene.
  9698. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9699. *
  9700. * Remarks: Can be either a texture or a url.
  9701. */
  9702. environmentTexture: string | BaseTexture;
  9703. /**
  9704. * The value of the exposure to apply to the scene.
  9705. * 0.6 by default if setupImageProcessing is true.
  9706. */
  9707. cameraExposure: number;
  9708. /**
  9709. * The value of the contrast to apply to the scene.
  9710. * 1.6 by default if setupImageProcessing is true.
  9711. */
  9712. cameraContrast: number;
  9713. /**
  9714. * Specifies wether or not tonemapping should be enabled in the scene.
  9715. * true by default if setupImageProcessing is true.
  9716. */
  9717. toneMappingEnabled: boolean;
  9718. }
  9719. /**
  9720. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9721. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9722. * It also helps with the default setup of your imageProcessing configuration.
  9723. */
  9724. class EnvironmentHelper {
  9725. /**
  9726. * Default ground texture URL.
  9727. */
  9728. private static _groundTextureCDNUrl;
  9729. /**
  9730. * Default skybox texture URL.
  9731. */
  9732. private static _skyboxTextureCDNUrl;
  9733. /**
  9734. * Default environment texture URL.
  9735. */
  9736. private static _environmentTextureCDNUrl;
  9737. /**
  9738. * Creates the default options for the helper.
  9739. */
  9740. private static _getDefaultOptions();
  9741. private _rootMesh;
  9742. /**
  9743. * Gets the root mesh created by the helper.
  9744. */
  9745. readonly rootMesh: Mesh;
  9746. private _skybox;
  9747. /**
  9748. * Gets the skybox created by the helper.
  9749. */
  9750. readonly skybox: Nullable<Mesh>;
  9751. private _skyboxTexture;
  9752. /**
  9753. * Gets the skybox texture created by the helper.
  9754. */
  9755. readonly skyboxTexture: Nullable<BaseTexture>;
  9756. private _skyboxMaterial;
  9757. /**
  9758. * Gets the skybox material created by the helper.
  9759. */
  9760. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9761. private _ground;
  9762. /**
  9763. * Gets the ground mesh created by the helper.
  9764. */
  9765. readonly ground: Nullable<Mesh>;
  9766. private _groundTexture;
  9767. /**
  9768. * Gets the ground texture created by the helper.
  9769. */
  9770. readonly groundTexture: Nullable<BaseTexture>;
  9771. private _groundMirror;
  9772. /**
  9773. * Gets the ground mirror created by the helper.
  9774. */
  9775. readonly groundMirror: Nullable<MirrorTexture>;
  9776. /**
  9777. * Gets the ground mirror render list to helps pushing the meshes
  9778. * you wish in the ground reflection.
  9779. */
  9780. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9781. private _groundMaterial;
  9782. /**
  9783. * Gets the ground material created by the helper.
  9784. */
  9785. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9786. /**
  9787. * Stores the creation options.
  9788. */
  9789. private readonly _scene;
  9790. private _options;
  9791. /**
  9792. * This observable will be notified with any error during the creation of the environment,
  9793. * mainly texture creation errors.
  9794. */
  9795. onErrorObservable: Observable<{
  9796. message?: string;
  9797. exception?: any;
  9798. }>;
  9799. /**
  9800. * constructor
  9801. * @param options
  9802. * @param scene The scene to add the material to
  9803. */
  9804. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9805. /**
  9806. * Updates the background according to the new options
  9807. * @param options
  9808. */
  9809. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9810. /**
  9811. * Sets the primary color of all the available elements.
  9812. * @param color the main color to affect to the ground and the background
  9813. */
  9814. setMainColor(color: Color3): void;
  9815. /**
  9816. * Setup the image processing according to the specified options.
  9817. */
  9818. private _setupImageProcessing();
  9819. /**
  9820. * Setup the environment texture according to the specified options.
  9821. */
  9822. private _setupEnvironmentTexture();
  9823. /**
  9824. * Setup the background according to the specified options.
  9825. */
  9826. private _setupBackground();
  9827. /**
  9828. * Get the scene sizes according to the setup.
  9829. */
  9830. private _getSceneSize();
  9831. /**
  9832. * Setup the ground according to the specified options.
  9833. */
  9834. private _setupGround(sceneSize);
  9835. /**
  9836. * Setup the ground material according to the specified options.
  9837. */
  9838. private _setupGroundMaterial();
  9839. /**
  9840. * Setup the ground diffuse texture according to the specified options.
  9841. */
  9842. private _setupGroundDiffuseTexture();
  9843. /**
  9844. * Setup the ground mirror texture according to the specified options.
  9845. */
  9846. private _setupGroundMirrorTexture(sceneSize);
  9847. /**
  9848. * Setup the ground to receive the mirror texture.
  9849. */
  9850. private _setupMirrorInGroundMaterial();
  9851. /**
  9852. * Setup the skybox according to the specified options.
  9853. */
  9854. private _setupSkybox(sceneSize);
  9855. /**
  9856. * Setup the skybox material according to the specified options.
  9857. */
  9858. private _setupSkyboxMaterial();
  9859. /**
  9860. * Setup the skybox reflection texture according to the specified options.
  9861. */
  9862. private _setupSkyboxReflectionTexture();
  9863. private _errorHandler;
  9864. /**
  9865. * Dispose all the elements created by the Helper.
  9866. */
  9867. dispose(): void;
  9868. }
  9869. }
  9870. declare module BABYLON {
  9871. /**
  9872. * Represents all the data needed to create a ParticleSystem.
  9873. */
  9874. interface IParticleSystemData {
  9875. /**
  9876. * ParticleSystem type
  9877. */
  9878. type: string;
  9879. /**
  9880. * Shape of the emitter
  9881. */
  9882. emitterType: string;
  9883. /**
  9884. * Maximum number of particles in the system
  9885. */
  9886. capacity: number;
  9887. /**
  9888. * Link for the texture file
  9889. */
  9890. textureFile: string;
  9891. /**
  9892. * minEmitBox Vector3
  9893. */
  9894. minEmitBox?: {
  9895. x: number;
  9896. y: number;
  9897. z: number;
  9898. };
  9899. /**
  9900. * maxEmitBox Vector3
  9901. */
  9902. maxEmitBox?: {
  9903. x: number;
  9904. y: number;
  9905. z: number;
  9906. };
  9907. /**
  9908. * color1 Color4
  9909. */
  9910. color1: {
  9911. r: number;
  9912. g: number;
  9913. b: number;
  9914. a: number;
  9915. };
  9916. /**
  9917. * color2 Color4
  9918. */
  9919. color2: {
  9920. r: number;
  9921. g: number;
  9922. b: number;
  9923. a: number;
  9924. };
  9925. /**
  9926. * colorDead Color4
  9927. */
  9928. colorDead: {
  9929. r: number;
  9930. g: number;
  9931. b: number;
  9932. a: number;
  9933. };
  9934. /**
  9935. * Minimum size of each particle
  9936. */
  9937. minSize: number;
  9938. /**
  9939. * Maximum size of each particle
  9940. */
  9941. maxSize: number;
  9942. /**
  9943. * Minimum scale of each particle on X axis
  9944. */
  9945. minScaleX: number;
  9946. /**
  9947. * Maximum scale of each particle on X axis
  9948. */
  9949. maxScaleX: number;
  9950. /**
  9951. * Minimum scale of each particle on Y axis
  9952. */
  9953. minScaleY: number;
  9954. /**
  9955. * Maximum scale of each particle on Y axis
  9956. */
  9957. maxScaleY: number;
  9958. /**
  9959. * Minimum lifetime for each particle
  9960. */
  9961. minLifeTime: number;
  9962. /**
  9963. * Maximum lifetime for each particle
  9964. */
  9965. maxLifeTime: number;
  9966. /**
  9967. * Emit rate
  9968. */
  9969. emitRate: number;
  9970. /**
  9971. * Blend Mode
  9972. */
  9973. blendMode: number;
  9974. /**
  9975. * gravity Vector3
  9976. */
  9977. gravity: {
  9978. x: number;
  9979. y: number;
  9980. z: number;
  9981. };
  9982. /**
  9983. * direction1 Vector3
  9984. */
  9985. direction1?: {
  9986. x: number;
  9987. y: number;
  9988. z: number;
  9989. };
  9990. /**
  9991. * direction2 Vector3
  9992. */
  9993. direction2?: {
  9994. x: number;
  9995. y: number;
  9996. z: number;
  9997. };
  9998. /**
  9999. * Minimum Angular Speed
  10000. */
  10001. minAngularSpeed: number;
  10002. /**
  10003. * Maximum Angular Speed
  10004. */
  10005. maxAngularSpeed: number;
  10006. /**
  10007. * Minimum Emit Power
  10008. */
  10009. minEmitPower: number;
  10010. /**
  10011. * Maximum Emit Power
  10012. */
  10013. maxEmitPower: number;
  10014. /**
  10015. * Update Speed
  10016. */
  10017. updateSpeed: number;
  10018. /**
  10019. * Radius
  10020. */
  10021. radius?: number;
  10022. /**
  10023. * Angle
  10024. */
  10025. angle?: number;
  10026. }
  10027. /**
  10028. * This class is made for on one-liner static method to help creating particle systems.
  10029. */
  10030. class ParticleHelper {
  10031. /**
  10032. * Base Assets URL.
  10033. */
  10034. private static _baseAssetsUrl;
  10035. /**
  10036. * This is the main static method (one-liner) of this helper to create different particle systems.
  10037. * @param type This string represents the type to the particle system to create
  10038. * @param emitter The object where the particle system will start to emit from.
  10039. * @param scene The scene where the particle system should live.
  10040. * @param gpu If the system will use gpu.
  10041. * @returns the ParticleSystem created.
  10042. */
  10043. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  10044. /**
  10045. * Static function used to create a new particle system from a IParticleSystemData
  10046. * @param data defines the source data
  10047. * @param scene defines the hosting scene
  10048. * @param emitter defines the particle emitter
  10049. * @returns a new ParticleSystem based on referenced data
  10050. */
  10051. static CreateSystem(data: IParticleSystemData, scene: Scene, emitter: AbstractMesh): ParticleSystem;
  10052. /**
  10053. * Static function used to update a particle system from a IParticleSystemData
  10054. * @param system defines the particle system to update
  10055. * @param data defines the source data
  10056. * @param scene defines the hosting scene
  10057. */
  10058. static UpdateSystem(system: ParticleSystem, data: IParticleSystemData, scene: Scene): void;
  10059. /**
  10060. * Static function used to export a particle system to a IParticleSystemData variable.
  10061. * Please note that texture file name is not exported and must be added manually
  10062. * @param system defines the particle system to export
  10063. */
  10064. static ExportSystem(system: ParticleSystem): IParticleSystemData;
  10065. }
  10066. }
  10067. declare module BABYLON {
  10068. /**
  10069. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10070. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10071. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10072. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10073. */
  10074. class PhotoDome extends Node {
  10075. private _useDirectMapping;
  10076. /**
  10077. * The texture being displayed on the sphere
  10078. */
  10079. protected _photoTexture: Texture;
  10080. /**
  10081. * Gets or sets the texture being displayed on the sphere
  10082. */
  10083. photoTexture: Texture;
  10084. /**
  10085. * The skybox material
  10086. */
  10087. protected _material: BackgroundMaterial;
  10088. /**
  10089. * The surface used for the skybox
  10090. */
  10091. protected _mesh: Mesh;
  10092. /**
  10093. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10094. * Also see the options.resolution property.
  10095. */
  10096. fovMultiplier: number;
  10097. /**
  10098. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10099. * @param name Element's name, child elements will append suffixes for their own names.
  10100. * @param urlsOfPhoto define the url of the photo to display
  10101. * @param options An object containing optional or exposed sub element properties
  10102. */
  10103. constructor(name: string, urlOfPhoto: string, options: {
  10104. resolution?: number;
  10105. size?: number;
  10106. useDirectMapping?: boolean;
  10107. }, scene: Scene);
  10108. /**
  10109. * Releases resources associated with this node.
  10110. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10111. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10112. */
  10113. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10114. }
  10115. }
  10116. declare module BABYLON {
  10117. /**
  10118. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10119. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10120. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10121. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10122. */
  10123. class VideoDome extends Node {
  10124. private _useDirectMapping;
  10125. /**
  10126. * The video texture being displayed on the sphere
  10127. */
  10128. protected _videoTexture: VideoTexture;
  10129. /**
  10130. * Gets the video texture being displayed on the sphere
  10131. */
  10132. readonly videoTexture: VideoTexture;
  10133. /**
  10134. * The skybox material
  10135. */
  10136. protected _material: BackgroundMaterial;
  10137. /**
  10138. * The surface used for the skybox
  10139. */
  10140. protected _mesh: Mesh;
  10141. /**
  10142. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10143. * Also see the options.resolution property.
  10144. */
  10145. fovMultiplier: number;
  10146. /**
  10147. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10148. * @param name Element's name, child elements will append suffixes for their own names.
  10149. * @param urlsOrVideo defines the url(s) or the video element to use
  10150. * @param options An object containing optional or exposed sub element properties
  10151. */
  10152. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10153. resolution?: number;
  10154. clickToPlay?: boolean;
  10155. autoPlay?: boolean;
  10156. loop?: boolean;
  10157. size?: number;
  10158. poster?: string;
  10159. useDirectMapping?: boolean;
  10160. }, scene: Scene);
  10161. /**
  10162. * Releases resources associated with this node.
  10163. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10164. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10165. */
  10166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10167. }
  10168. }
  10169. declare module BABYLON {
  10170. /**
  10171. * Single axis drag gizmo
  10172. */
  10173. class AxisDragGizmo extends Gizmo {
  10174. private _dragBehavior;
  10175. private _pointerObserver;
  10176. /**
  10177. * Creates an AxisDragGizmo
  10178. * @param gizmoLayer The utility layer the gizmo will be added to
  10179. * @param dragAxis The axis which the gizmo will be able to drag on
  10180. * @param color The color of the gizmo
  10181. */
  10182. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  10183. protected _onInteractionsEnabledChanged(value: boolean): void;
  10184. /**
  10185. * Disposes of the gizmo
  10186. */
  10187. dispose(): void;
  10188. }
  10189. }
  10190. declare module BABYLON {
  10191. /**
  10192. * Single axis scale gizmo
  10193. */
  10194. class AxisScaleGizmo extends Gizmo {
  10195. private _dragBehavior;
  10196. private _pointerObserver;
  10197. /**
  10198. * Creates an AxisScaleGizmo
  10199. * @param gizmoLayer The utility layer the gizmo will be added to
  10200. * @param dragAxis The axis which the gizmo will be able to scale on
  10201. * @param color The color of the gizmo
  10202. */
  10203. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  10204. protected _onInteractionsEnabledChanged(value: boolean): void;
  10205. /**
  10206. * Disposes of the gizmo
  10207. */
  10208. dispose(): void;
  10209. }
  10210. }
  10211. declare module BABYLON {
  10212. /**
  10213. * Bounding box gizmo
  10214. */
  10215. class BoundingBoxGizmo extends Gizmo {
  10216. private _lineBoundingBox;
  10217. private _rotateSpheresParent;
  10218. private _scaleBoxesParent;
  10219. private _boundingDimensions;
  10220. private _renderObserver;
  10221. private _pointerObserver;
  10222. private _scaleDragSpeed;
  10223. private _tmpQuaternion;
  10224. private _tmpVector;
  10225. /**
  10226. * Creates an BoundingBoxGizmo
  10227. * @param gizmoLayer The utility layer the gizmo will be added to
  10228. * @param color The color of the gizmo
  10229. */
  10230. constructor(gizmoLayer: UtilityLayerRenderer, color: Color3);
  10231. private _selectNode(selectedMesh);
  10232. private _updateBoundingBox();
  10233. /**
  10234. * Disposes of the gizmo
  10235. */
  10236. dispose(): void;
  10237. }
  10238. }
  10239. declare module BABYLON {
  10240. /**
  10241. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10242. */
  10243. class Gizmo implements IDisposable {
  10244. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  10245. /**
  10246. * The root mesh of the gizmo
  10247. */
  10248. protected _rootMesh: Mesh;
  10249. /**
  10250. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10251. */
  10252. attachedMesh: Nullable<AbstractMesh>;
  10253. /**
  10254. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10255. */
  10256. updateGizmoRotationToMatchAttachedMesh: boolean;
  10257. /**
  10258. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10259. */
  10260. updateGizmoPositionToMatchAttachedMesh: boolean;
  10261. /**
  10262. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10263. */
  10264. protected _updateScale: boolean;
  10265. protected _interactionsEnabled: boolean;
  10266. protected _onInteractionsEnabledChanged(value: boolean): void;
  10267. /**
  10268. * If interactions are enabled with this gizmo. (eg. dragging/rotation)
  10269. */
  10270. interactionsEnabled: boolean;
  10271. private _beforeRenderObserver;
  10272. /**
  10273. * Creates a gizmo
  10274. * @param gizmoLayer The utility layer the gizmo will be added to
  10275. */
  10276. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  10277. /**
  10278. * Disposes of the gizmo
  10279. */
  10280. dispose(): void;
  10281. }
  10282. }
  10283. declare module BABYLON {
  10284. /**
  10285. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10286. */
  10287. class GizmoManager implements IDisposable {
  10288. private scene;
  10289. private _gizmoLayer;
  10290. private _gizmoSet;
  10291. private _pointerObserver;
  10292. /**
  10293. * Instatiates a gizmo manager
  10294. * @param scene the scene to overlay the gizmos on top of
  10295. * @param options If only a single gizmo should exist at one time
  10296. */
  10297. constructor(scene: Scene, options?: {
  10298. singleGizmo?: boolean;
  10299. });
  10300. /**
  10301. * Disposes of the gizmo manager
  10302. */
  10303. dispose(): void;
  10304. private _clearGizmos();
  10305. }
  10306. }
  10307. declare module BABYLON {
  10308. /**
  10309. * Single plane rotation gizmo
  10310. */
  10311. class PlaneRotationGizmo extends Gizmo {
  10312. private _dragBehavior;
  10313. private _pointerObserver;
  10314. /**
  10315. * Creates a PlaneRotationGizmo
  10316. * @param gizmoLayer The utility layer the gizmo will be added to
  10317. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10318. * @param color The color of the gizmo
  10319. */
  10320. constructor(gizmoLayer: UtilityLayerRenderer, planeNormal: Vector3, color: Color3);
  10321. protected _onInteractionsEnabledChanged(value: boolean): void;
  10322. /**
  10323. * Disposes of the gizmo
  10324. */
  10325. dispose(): void;
  10326. }
  10327. }
  10328. declare module BABYLON {
  10329. /**
  10330. * Gizmo that enables dragging a mesh along 3 axis
  10331. */
  10332. class PositionGizmo extends Gizmo {
  10333. private _xDrag;
  10334. private _yDrag;
  10335. private _zDrag;
  10336. attachedMesh: Nullable<AbstractMesh>;
  10337. /**
  10338. * Creates a PositionGizmo
  10339. * @param gizmoLayer The utility layer the gizmo will be added to
  10340. */
  10341. constructor(gizmoLayer: UtilityLayerRenderer);
  10342. protected _onInteractionsEnabledChanged(value: boolean): void;
  10343. updateGizmoRotationToMatchAttachedMesh: boolean;
  10344. /**
  10345. * Disposes of the gizmo
  10346. */
  10347. dispose(): void;
  10348. }
  10349. }
  10350. declare module BABYLON {
  10351. /**
  10352. * Gizmo that enables rotating a mesh along 3 axis
  10353. */
  10354. class RotationGizmo extends Gizmo {
  10355. private _xDrag;
  10356. private _yDrag;
  10357. private _zDrag;
  10358. attachedMesh: Nullable<AbstractMesh>;
  10359. /**
  10360. * Creates a RotationGizmo
  10361. * @param gizmoLayer The utility layer the gizmo will be added to
  10362. */
  10363. constructor(gizmoLayer: UtilityLayerRenderer);
  10364. protected _onInteractionsEnabledChanged(value: boolean): void;
  10365. updateGizmoRotationToMatchAttachedMesh: boolean;
  10366. /**
  10367. * Disposes of the gizmo
  10368. */
  10369. dispose(): void;
  10370. }
  10371. }
  10372. declare module BABYLON {
  10373. /**
  10374. * Gizmo that enables scaling a mesh along 3 axis
  10375. */
  10376. class ScaleGizmo extends Gizmo {
  10377. private _xDrag;
  10378. private _yDrag;
  10379. private _zDrag;
  10380. attachedMesh: Nullable<AbstractMesh>;
  10381. /**
  10382. * Creates a ScaleGizmo
  10383. * @param gizmoLayer The utility layer the gizmo will be added to
  10384. */
  10385. constructor(gizmoLayer: UtilityLayerRenderer);
  10386. protected _onInteractionsEnabledChanged(value: boolean): void;
  10387. updateGizmoRotationToMatchAttachedMesh: boolean;
  10388. /**
  10389. * Disposes of the gizmo
  10390. */
  10391. dispose(): void;
  10392. }
  10393. }
  10394. declare module BABYLON {
  10395. /**
  10396. * This class can be used to get instrumentation data from a Babylon engine
  10397. */
  10398. class EngineInstrumentation implements IDisposable {
  10399. engine: Engine;
  10400. private _captureGPUFrameTime;
  10401. private _gpuFrameTimeToken;
  10402. private _gpuFrameTime;
  10403. private _captureShaderCompilationTime;
  10404. private _shaderCompilationTime;
  10405. private _onBeginFrameObserver;
  10406. private _onEndFrameObserver;
  10407. private _onBeforeShaderCompilationObserver;
  10408. private _onAfterShaderCompilationObserver;
  10409. /**
  10410. * Gets the perf counter used for GPU frame time
  10411. */
  10412. readonly gpuFrameTimeCounter: PerfCounter;
  10413. /**
  10414. * Gets the GPU frame time capture status
  10415. */
  10416. /**
  10417. * Enable or disable the GPU frame time capture
  10418. */
  10419. captureGPUFrameTime: boolean;
  10420. /**
  10421. * Gets the perf counter used for shader compilation time
  10422. */
  10423. readonly shaderCompilationTimeCounter: PerfCounter;
  10424. /**
  10425. * Gets the shader compilation time capture status
  10426. */
  10427. /**
  10428. * Enable or disable the shader compilation time capture
  10429. */
  10430. captureShaderCompilationTime: boolean;
  10431. constructor(engine: Engine);
  10432. dispose(): void;
  10433. }
  10434. }
  10435. declare module BABYLON {
  10436. /**
  10437. * This class can be used to get instrumentation data from a Babylon engine
  10438. */
  10439. class SceneInstrumentation implements IDisposable {
  10440. scene: Scene;
  10441. private _captureActiveMeshesEvaluationTime;
  10442. private _activeMeshesEvaluationTime;
  10443. private _captureRenderTargetsRenderTime;
  10444. private _renderTargetsRenderTime;
  10445. private _captureFrameTime;
  10446. private _frameTime;
  10447. private _captureRenderTime;
  10448. private _renderTime;
  10449. private _captureInterFrameTime;
  10450. private _interFrameTime;
  10451. private _captureParticlesRenderTime;
  10452. private _particlesRenderTime;
  10453. private _captureSpritesRenderTime;
  10454. private _spritesRenderTime;
  10455. private _capturePhysicsTime;
  10456. private _physicsTime;
  10457. private _captureAnimationsTime;
  10458. private _animationsTime;
  10459. private _captureCameraRenderTime;
  10460. private _cameraRenderTime;
  10461. private _onBeforeActiveMeshesEvaluationObserver;
  10462. private _onAfterActiveMeshesEvaluationObserver;
  10463. private _onBeforeRenderTargetsRenderObserver;
  10464. private _onAfterRenderTargetsRenderObserver;
  10465. private _onAfterRenderObserver;
  10466. private _onBeforeDrawPhaseObserver;
  10467. private _onAfterDrawPhaseObserver;
  10468. private _onBeforeAnimationsObserver;
  10469. private _onBeforeParticlesRenderingObserver;
  10470. private _onAfterParticlesRenderingObserver;
  10471. private _onBeforeSpritesRenderingObserver;
  10472. private _onAfterSpritesRenderingObserver;
  10473. private _onBeforePhysicsObserver;
  10474. private _onAfterPhysicsObserver;
  10475. private _onAfterAnimationsObserver;
  10476. private _onBeforeCameraRenderObserver;
  10477. private _onAfterCameraRenderObserver;
  10478. /**
  10479. * Gets the perf counter used for active meshes evaluation time
  10480. */
  10481. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10482. /**
  10483. * Gets the active meshes evaluation time capture status
  10484. */
  10485. /**
  10486. * Enable or disable the active meshes evaluation time capture
  10487. */
  10488. captureActiveMeshesEvaluationTime: boolean;
  10489. /**
  10490. * Gets the perf counter used for render targets render time
  10491. */
  10492. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10493. /**
  10494. * Gets the render targets render time capture status
  10495. */
  10496. /**
  10497. * Enable or disable the render targets render time capture
  10498. */
  10499. captureRenderTargetsRenderTime: boolean;
  10500. /**
  10501. * Gets the perf counter used for particles render time
  10502. */
  10503. readonly particlesRenderTimeCounter: PerfCounter;
  10504. /**
  10505. * Gets the particles render time capture status
  10506. */
  10507. /**
  10508. * Enable or disable the particles render time capture
  10509. */
  10510. captureParticlesRenderTime: boolean;
  10511. /**
  10512. * Gets the perf counter used for sprites render time
  10513. */
  10514. readonly spritesRenderTimeCounter: PerfCounter;
  10515. /**
  10516. * Gets the sprites render time capture status
  10517. */
  10518. /**
  10519. * Enable or disable the sprites render time capture
  10520. */
  10521. captureSpritesRenderTime: boolean;
  10522. /**
  10523. * Gets the perf counter used for physics time
  10524. */
  10525. readonly physicsTimeCounter: PerfCounter;
  10526. /**
  10527. * Gets the physics time capture status
  10528. */
  10529. /**
  10530. * Enable or disable the physics time capture
  10531. */
  10532. capturePhysicsTime: boolean;
  10533. /**
  10534. * Gets the perf counter used for animations time
  10535. */
  10536. readonly animationsTimeCounter: PerfCounter;
  10537. /**
  10538. * Gets the animations time capture status
  10539. */
  10540. /**
  10541. * Enable or disable the animations time capture
  10542. */
  10543. captureAnimationsTime: boolean;
  10544. /**
  10545. * Gets the perf counter used for frame time capture
  10546. */
  10547. readonly frameTimeCounter: PerfCounter;
  10548. /**
  10549. * Gets the frame time capture status
  10550. */
  10551. /**
  10552. * Enable or disable the frame time capture
  10553. */
  10554. captureFrameTime: boolean;
  10555. /**
  10556. * Gets the perf counter used for inter-frames time capture
  10557. */
  10558. readonly interFrameTimeCounter: PerfCounter;
  10559. /**
  10560. * Gets the inter-frames time capture status
  10561. */
  10562. /**
  10563. * Enable or disable the inter-frames time capture
  10564. */
  10565. captureInterFrameTime: boolean;
  10566. /**
  10567. * Gets the perf counter used for render time capture
  10568. */
  10569. readonly renderTimeCounter: PerfCounter;
  10570. /**
  10571. * Gets the render time capture status
  10572. */
  10573. /**
  10574. * Enable or disable the render time capture
  10575. */
  10576. captureRenderTime: boolean;
  10577. /**
  10578. * Gets the perf counter used for camera render time capture
  10579. */
  10580. readonly cameraRenderTimeCounter: PerfCounter;
  10581. /**
  10582. * Gets the camera render time capture status
  10583. */
  10584. /**
  10585. * Enable or disable the camera render time capture
  10586. */
  10587. captureCameraRenderTime: boolean;
  10588. /**
  10589. * Gets the perf counter used for draw calls
  10590. */
  10591. readonly drawCallsCounter: PerfCounter;
  10592. /**
  10593. * Gets the perf counter used for texture collisions
  10594. */
  10595. readonly textureCollisionsCounter: PerfCounter;
  10596. constructor(scene: Scene);
  10597. dispose(): void;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * @hidden
  10603. **/
  10604. class _TimeToken {
  10605. _startTimeQuery: Nullable<WebGLQuery>;
  10606. _endTimeQuery: Nullable<WebGLQuery>;
  10607. _timeElapsedQuery: Nullable<WebGLQuery>;
  10608. _timeElapsedQueryEnded: boolean;
  10609. }
  10610. }
  10611. declare module BABYLON {
  10612. /**
  10613. * Effect layer options. This helps customizing the behaviour
  10614. * of the effect layer.
  10615. */
  10616. interface IEffectLayerOptions {
  10617. /**
  10618. * Multiplication factor apply to the canvas size to compute the render target size
  10619. * used to generated the objects (the smaller the faster).
  10620. */
  10621. mainTextureRatio: number;
  10622. /**
  10623. * Enforces a fixed size texture to ensure effect stability across devices.
  10624. */
  10625. mainTextureFixedSize?: number;
  10626. /**
  10627. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10628. */
  10629. alphaBlendingMode: number;
  10630. /**
  10631. * The camera attached to the layer.
  10632. */
  10633. camera: Nullable<Camera>;
  10634. }
  10635. /**
  10636. * The effect layer Helps adding post process effect blended with the main pass.
  10637. *
  10638. * This can be for instance use to generate glow or higlight effects on the scene.
  10639. *
  10640. * The effect layer class can not be used directly and is intented to inherited from to be
  10641. * customized per effects.
  10642. */
  10643. abstract class EffectLayer {
  10644. private _vertexBuffers;
  10645. private _indexBuffer;
  10646. private _cachedDefines;
  10647. private _effectLayerMapGenerationEffect;
  10648. private _effectLayerOptions;
  10649. private _mergeEffect;
  10650. protected _scene: Scene;
  10651. protected _engine: Engine;
  10652. protected _maxSize: number;
  10653. protected _mainTextureDesiredSize: ISize;
  10654. protected _mainTexture: RenderTargetTexture;
  10655. protected _shouldRender: boolean;
  10656. protected _postProcesses: PostProcess[];
  10657. protected _textures: BaseTexture[];
  10658. protected _emissiveTextureAndColor: {
  10659. texture: Nullable<BaseTexture>;
  10660. color: Color4;
  10661. };
  10662. /**
  10663. * The name of the layer
  10664. */
  10665. name: string;
  10666. /**
  10667. * The clear color of the texture used to generate the glow map.
  10668. */
  10669. neutralColor: Color4;
  10670. /**
  10671. * Specifies wether the highlight layer is enabled or not.
  10672. */
  10673. isEnabled: boolean;
  10674. /**
  10675. * Gets the camera attached to the layer.
  10676. */
  10677. readonly camera: Nullable<Camera>;
  10678. /**
  10679. * An event triggered when the effect layer has been disposed.
  10680. */
  10681. onDisposeObservable: Observable<EffectLayer>;
  10682. /**
  10683. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10684. */
  10685. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10686. /**
  10687. * An event triggered when the generated texture is being merged in the scene.
  10688. */
  10689. onBeforeComposeObservable: Observable<EffectLayer>;
  10690. /**
  10691. * An event triggered when the generated texture has been merged in the scene.
  10692. */
  10693. onAfterComposeObservable: Observable<EffectLayer>;
  10694. /**
  10695. * An event triggered when the efffect layer changes its size.
  10696. */
  10697. onSizeChangedObservable: Observable<EffectLayer>;
  10698. /**
  10699. * Instantiates a new effect Layer and references it in the scene.
  10700. * @param name The name of the layer
  10701. * @param scene The scene to use the layer in
  10702. */
  10703. constructor(
  10704. /** The Friendly of the effect in the scene */
  10705. name: string, scene: Scene);
  10706. /**
  10707. * Get the effect name of the layer.
  10708. * @return The effect name
  10709. */
  10710. abstract getEffectName(): string;
  10711. /**
  10712. * Checks for the readiness of the element composing the layer.
  10713. * @param subMesh the mesh to check for
  10714. * @param useInstances specify wether or not to use instances to render the mesh
  10715. * @return true if ready otherwise, false
  10716. */
  10717. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10718. /**
  10719. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10720. * @returns true if the effect requires stencil during the main canvas render pass.
  10721. */
  10722. abstract needStencil(): boolean;
  10723. /**
  10724. * Create the merge effect. This is the shader use to blit the information back
  10725. * to the main canvas at the end of the scene rendering.
  10726. * @returns The effect containing the shader used to merge the effect on the main canvas
  10727. */
  10728. protected abstract _createMergeEffect(): Effect;
  10729. /**
  10730. * Creates the render target textures and post processes used in the effect layer.
  10731. */
  10732. protected abstract _createTextureAndPostProcesses(): void;
  10733. /**
  10734. * Implementation specific of rendering the generating effect on the main canvas.
  10735. * @param effect The effect used to render through
  10736. */
  10737. protected abstract _internalRender(effect: Effect): void;
  10738. /**
  10739. * Sets the required values for both the emissive texture and and the main color.
  10740. */
  10741. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10742. /**
  10743. * Free any resources and references associated to a mesh.
  10744. * Internal use
  10745. * @param mesh The mesh to free.
  10746. */
  10747. abstract _disposeMesh(mesh: Mesh): void;
  10748. /**
  10749. * Serializes this layer (Glow or Highlight for example)
  10750. * @returns a serialized layer object
  10751. */
  10752. abstract serialize?(): any;
  10753. /**
  10754. * Initializes the effect layer with the required options.
  10755. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10756. */
  10757. protected _init(options: Partial<IEffectLayerOptions>): void;
  10758. /**
  10759. * Generates the index buffer of the full screen quad blending to the main canvas.
  10760. */
  10761. private _generateIndexBuffer();
  10762. /**
  10763. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10764. */
  10765. private _genrateVertexBuffer();
  10766. /**
  10767. * Sets the main texture desired size which is the closest power of two
  10768. * of the engine canvas size.
  10769. */
  10770. private _setMainTextureSize();
  10771. /**
  10772. * Creates the main texture for the effect layer.
  10773. */
  10774. protected _createMainTexture(): void;
  10775. /**
  10776. * Checks for the readiness of the element composing the layer.
  10777. * @param subMesh the mesh to check for
  10778. * @param useInstances specify wether or not to use instances to render the mesh
  10779. * @param emissiveTexture the associated emissive texture used to generate the glow
  10780. * @return true if ready otherwise, false
  10781. */
  10782. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10783. /**
  10784. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10785. */
  10786. render(): void;
  10787. /**
  10788. * Determine if a given mesh will be used in the current effect.
  10789. * @param mesh mesh to test
  10790. * @returns true if the mesh will be used
  10791. */
  10792. hasMesh(mesh: AbstractMesh): boolean;
  10793. /**
  10794. * Returns true if the layer contains information to display, otherwise false.
  10795. * @returns true if the glow layer should be rendered
  10796. */
  10797. shouldRender(): boolean;
  10798. /**
  10799. * Returns true if the mesh should render, otherwise false.
  10800. * @param mesh The mesh to render
  10801. * @returns true if it should render otherwise false
  10802. */
  10803. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10804. /**
  10805. * Returns true if the mesh should render, otherwise false.
  10806. * @param mesh The mesh to render
  10807. * @returns true if it should render otherwise false
  10808. */
  10809. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10810. /**
  10811. * Renders the submesh passed in parameter to the generation map.
  10812. */
  10813. protected _renderSubMesh(subMesh: SubMesh): void;
  10814. /**
  10815. * Rebuild the required buffers.
  10816. * @hidden Internal use only.
  10817. */
  10818. _rebuild(): void;
  10819. /**
  10820. * Dispose only the render target textures and post process.
  10821. */
  10822. private _disposeTextureAndPostProcesses();
  10823. /**
  10824. * Dispose the highlight layer and free resources.
  10825. */
  10826. dispose(): void;
  10827. /**
  10828. * Gets the class name of the effect layer
  10829. * @returns the string with the class name of the effect layer
  10830. */
  10831. getClassName(): string;
  10832. /**
  10833. * Creates an effect layer from parsed effect layer data
  10834. * @param parsedEffectLayer defines effect layer data
  10835. * @param scene defines the current scene
  10836. * @param rootUrl defines the root URL containing the effect layer information
  10837. * @returns a parsed effect Layer
  10838. */
  10839. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10840. }
  10841. }
  10842. declare module BABYLON {
  10843. /**
  10844. * Glow layer options. This helps customizing the behaviour
  10845. * of the glow layer.
  10846. */
  10847. interface IGlowLayerOptions {
  10848. /**
  10849. * Multiplication factor apply to the canvas size to compute the render target size
  10850. * used to generated the glowing objects (the smaller the faster).
  10851. */
  10852. mainTextureRatio: number;
  10853. /**
  10854. * Enforces a fixed size texture to ensure resize independant blur.
  10855. */
  10856. mainTextureFixedSize?: number;
  10857. /**
  10858. * How big is the kernel of the blur texture.
  10859. */
  10860. blurKernelSize: number;
  10861. /**
  10862. * The camera attached to the layer.
  10863. */
  10864. camera: Nullable<Camera>;
  10865. /**
  10866. * Enable MSAA by chosing the number of samples.
  10867. */
  10868. mainTextureSamples?: number;
  10869. }
  10870. /**
  10871. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10872. *
  10873. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10874. * glowy meshes to your scene.
  10875. *
  10876. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10877. */
  10878. class GlowLayer extends EffectLayer {
  10879. /**
  10880. * Effect Name of the layer.
  10881. */
  10882. static readonly EffectName: string;
  10883. /**
  10884. * The default blur kernel size used for the glow.
  10885. */
  10886. static DefaultBlurKernelSize: number;
  10887. /**
  10888. * The default texture size ratio used for the glow.
  10889. */
  10890. static DefaultTextureRatio: number;
  10891. /**
  10892. * Gets the kernel size of the blur.
  10893. */
  10894. /**
  10895. * Sets the kernel size of the blur.
  10896. */
  10897. blurKernelSize: number;
  10898. /**
  10899. * Gets the glow intensity.
  10900. */
  10901. /**
  10902. * Sets the glow intensity.
  10903. */
  10904. intensity: number;
  10905. private _options;
  10906. private _intensity;
  10907. private _horizontalBlurPostprocess1;
  10908. private _verticalBlurPostprocess1;
  10909. private _horizontalBlurPostprocess2;
  10910. private _verticalBlurPostprocess2;
  10911. private _blurTexture1;
  10912. private _blurTexture2;
  10913. private _postProcesses1;
  10914. private _postProcesses2;
  10915. private _includedOnlyMeshes;
  10916. private _excludedMeshes;
  10917. /**
  10918. * Callback used to let the user override the color selection on a per mesh basis
  10919. */
  10920. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10921. /**
  10922. * Callback used to let the user override the texture selection on a per mesh basis
  10923. */
  10924. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10925. /**
  10926. * Instantiates a new glow Layer and references it to the scene.
  10927. * @param name The name of the layer
  10928. * @param scene The scene to use the layer in
  10929. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10930. */
  10931. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10932. /**
  10933. * Get the effect name of the layer.
  10934. * @return The effect name
  10935. */
  10936. getEffectName(): string;
  10937. /**
  10938. * Create the merge effect. This is the shader use to blit the information back
  10939. * to the main canvas at the end of the scene rendering.
  10940. */
  10941. protected _createMergeEffect(): Effect;
  10942. /**
  10943. * Creates the render target textures and post processes used in the glow layer.
  10944. */
  10945. protected _createTextureAndPostProcesses(): void;
  10946. /**
  10947. * Checks for the readiness of the element composing the layer.
  10948. * @param subMesh the mesh to check for
  10949. * @param useInstances specify wether or not to use instances to render the mesh
  10950. * @param emissiveTexture the associated emissive texture used to generate the glow
  10951. * @return true if ready otherwise, false
  10952. */
  10953. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10954. /**
  10955. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10956. */
  10957. needStencil(): boolean;
  10958. /**
  10959. * Implementation specific of rendering the generating effect on the main canvas.
  10960. * @param effect The effect used to render through
  10961. */
  10962. protected _internalRender(effect: Effect): void;
  10963. /**
  10964. * Sets the required values for both the emissive texture and and the main color.
  10965. */
  10966. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10967. /**
  10968. * Returns true if the mesh should render, otherwise false.
  10969. * @param mesh The mesh to render
  10970. * @returns true if it should render otherwise false
  10971. */
  10972. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10973. /**
  10974. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10975. * @param mesh The mesh to exclude from the glow layer
  10976. */
  10977. addExcludedMesh(mesh: Mesh): void;
  10978. /**
  10979. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10980. * @param mesh The mesh to remove
  10981. */
  10982. removeExcludedMesh(mesh: Mesh): void;
  10983. /**
  10984. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10985. * @param mesh The mesh to include in the glow layer
  10986. */
  10987. addIncludedOnlyMesh(mesh: Mesh): void;
  10988. /**
  10989. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10990. * @param mesh The mesh to remove
  10991. */
  10992. removeIncludedOnlyMesh(mesh: Mesh): void;
  10993. /**
  10994. * Determine if a given mesh will be used in the glow layer
  10995. * @param mesh The mesh to test
  10996. * @returns true if the mesh will be highlighted by the current glow layer
  10997. */
  10998. hasMesh(mesh: AbstractMesh): boolean;
  10999. /**
  11000. * Free any resources and references associated to a mesh.
  11001. * Internal use
  11002. * @param mesh The mesh to free.
  11003. */
  11004. _disposeMesh(mesh: Mesh): void;
  11005. /**
  11006. * Gets the class name of the effect layer
  11007. * @returns the string with the class name of the effect layer
  11008. */
  11009. getClassName(): string;
  11010. /**
  11011. * Serializes this glow layer
  11012. * @returns a serialized glow layer object
  11013. */
  11014. serialize(): any;
  11015. /**
  11016. * Creates a Glow Layer from parsed glow layer data
  11017. * @param parsedGlowLayer defines glow layer data
  11018. * @param scene defines the current scene
  11019. * @param rootUrl defines the root URL containing the glow layer information
  11020. * @returns a parsed Glow Layer
  11021. */
  11022. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * Highlight layer options. This helps customizing the behaviour
  11028. * of the highlight layer.
  11029. */
  11030. interface IHighlightLayerOptions {
  11031. /**
  11032. * Multiplication factor apply to the canvas size to compute the render target size
  11033. * used to generated the glowing objects (the smaller the faster).
  11034. */
  11035. mainTextureRatio: number;
  11036. /**
  11037. * Enforces a fixed size texture to ensure resize independant blur.
  11038. */
  11039. mainTextureFixedSize?: number;
  11040. /**
  11041. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11042. * of the picture to blur (the smaller the faster).
  11043. */
  11044. blurTextureSizeRatio: number;
  11045. /**
  11046. * How big in texel of the blur texture is the vertical blur.
  11047. */
  11048. blurVerticalSize: number;
  11049. /**
  11050. * How big in texel of the blur texture is the horizontal blur.
  11051. */
  11052. blurHorizontalSize: number;
  11053. /**
  11054. * Alpha blending mode used to apply the blur. Default is combine.
  11055. */
  11056. alphaBlendingMode: number;
  11057. /**
  11058. * The camera attached to the layer.
  11059. */
  11060. camera: Nullable<Camera>;
  11061. /**
  11062. * Should we display highlight as a solid stroke?
  11063. */
  11064. isStroke?: boolean;
  11065. }
  11066. /**
  11067. * The highlight layer Helps adding a glow effect around a mesh.
  11068. *
  11069. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11070. * glowy meshes to your scene.
  11071. *
  11072. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11073. */
  11074. class HighlightLayer extends EffectLayer {
  11075. name: string;
  11076. /**
  11077. * Effect Name of the highlight layer.
  11078. */
  11079. static readonly EffectName: string;
  11080. /**
  11081. * The neutral color used during the preparation of the glow effect.
  11082. * This is black by default as the blend operation is a blend operation.
  11083. */
  11084. static NeutralColor: Color4;
  11085. /**
  11086. * Stencil value used for glowing meshes.
  11087. */
  11088. static GlowingMeshStencilReference: number;
  11089. /**
  11090. * Stencil value used for the other meshes in the scene.
  11091. */
  11092. static NormalMeshStencilReference: number;
  11093. /**
  11094. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11095. */
  11096. innerGlow: boolean;
  11097. /**
  11098. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11099. */
  11100. outerGlow: boolean;
  11101. /**
  11102. * Gets the horizontal size of the blur.
  11103. */
  11104. /**
  11105. * Specifies the horizontal size of the blur.
  11106. */
  11107. blurHorizontalSize: number;
  11108. /**
  11109. * Gets the vertical size of the blur.
  11110. */
  11111. /**
  11112. * Specifies the vertical size of the blur.
  11113. */
  11114. blurVerticalSize: number;
  11115. /**
  11116. * An event triggered when the highlight layer is being blurred.
  11117. */
  11118. onBeforeBlurObservable: Observable<HighlightLayer>;
  11119. /**
  11120. * An event triggered when the highlight layer has been blurred.
  11121. */
  11122. onAfterBlurObservable: Observable<HighlightLayer>;
  11123. private _instanceGlowingMeshStencilReference;
  11124. private _options;
  11125. private _downSamplePostprocess;
  11126. private _horizontalBlurPostprocess;
  11127. private _verticalBlurPostprocess;
  11128. private _blurTexture;
  11129. private _meshes;
  11130. private _excludedMeshes;
  11131. /**
  11132. * Instantiates a new highlight Layer and references it to the scene..
  11133. * @param name The name of the layer
  11134. * @param scene The scene to use the layer in
  11135. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11136. */
  11137. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11138. /**
  11139. * Get the effect name of the layer.
  11140. * @return The effect name
  11141. */
  11142. getEffectName(): string;
  11143. /**
  11144. * Create the merge effect. This is the shader use to blit the information back
  11145. * to the main canvas at the end of the scene rendering.
  11146. */
  11147. protected _createMergeEffect(): Effect;
  11148. /**
  11149. * Creates the render target textures and post processes used in the highlight layer.
  11150. */
  11151. protected _createTextureAndPostProcesses(): void;
  11152. /**
  11153. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11154. */
  11155. needStencil(): boolean;
  11156. /**
  11157. * Checks for the readiness of the element composing the layer.
  11158. * @param subMesh the mesh to check for
  11159. * @param useInstances specify wether or not to use instances to render the mesh
  11160. * @param emissiveTexture the associated emissive texture used to generate the glow
  11161. * @return true if ready otherwise, false
  11162. */
  11163. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11164. /**
  11165. * Implementation specific of rendering the generating effect on the main canvas.
  11166. * @param effect The effect used to render through
  11167. */
  11168. protected _internalRender(effect: Effect): void;
  11169. /**
  11170. * Returns true if the layer contains information to display, otherwise false.
  11171. */
  11172. shouldRender(): boolean;
  11173. /**
  11174. * Returns true if the mesh should render, otherwise false.
  11175. * @param mesh The mesh to render
  11176. * @returns true if it should render otherwise false
  11177. */
  11178. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11179. /**
  11180. * Sets the required values for both the emissive texture and and the main color.
  11181. */
  11182. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11183. /**
  11184. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11185. * @param mesh The mesh to exclude from the highlight layer
  11186. */
  11187. addExcludedMesh(mesh: Mesh): void;
  11188. /**
  11189. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11190. * @param mesh The mesh to highlight
  11191. */
  11192. removeExcludedMesh(mesh: Mesh): void;
  11193. /**
  11194. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11195. * @param mesh mesh to test
  11196. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11197. */
  11198. hasMesh(mesh: AbstractMesh): boolean;
  11199. /**
  11200. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11201. * @param mesh The mesh to highlight
  11202. * @param color The color of the highlight
  11203. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11204. */
  11205. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11206. /**
  11207. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11208. * @param mesh The mesh to highlight
  11209. */
  11210. removeMesh(mesh: Mesh): void;
  11211. /**
  11212. * Force the stencil to the normal expected value for none glowing parts
  11213. */
  11214. private _defaultStencilReference(mesh);
  11215. /**
  11216. * Free any resources and references associated to a mesh.
  11217. * Internal use
  11218. * @param mesh The mesh to free.
  11219. */
  11220. _disposeMesh(mesh: Mesh): void;
  11221. /**
  11222. * Dispose the highlight layer and free resources.
  11223. */
  11224. dispose(): void;
  11225. /**
  11226. * Gets the class name of the effect layer
  11227. * @returns the string with the class name of the effect layer
  11228. */
  11229. getClassName(): string;
  11230. /**
  11231. * Serializes this Highlight layer
  11232. * @returns a serialized Highlight layer object
  11233. */
  11234. serialize(): any;
  11235. /**
  11236. * Creates a Highlight layer from parsed Highlight layer data
  11237. * @param parsedHightlightLayer defines the Highlight layer data
  11238. * @param scene defines the current scene
  11239. * @param rootUrl defines the root URL containing the Highlight layer information
  11240. * @returns a parsed Highlight layer
  11241. */
  11242. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11243. }
  11244. }
  11245. declare module BABYLON {
  11246. class Layer {
  11247. name: string;
  11248. texture: Nullable<Texture>;
  11249. isBackground: boolean;
  11250. color: Color4;
  11251. scale: Vector2;
  11252. offset: Vector2;
  11253. alphaBlendingMode: number;
  11254. alphaTest: boolean;
  11255. layerMask: number;
  11256. private _scene;
  11257. private _vertexBuffers;
  11258. private _indexBuffer;
  11259. private _effect;
  11260. private _alphaTestEffect;
  11261. /**
  11262. * An event triggered when the layer is disposed.
  11263. */
  11264. onDisposeObservable: Observable<Layer>;
  11265. private _onDisposeObserver;
  11266. onDispose: () => void;
  11267. /**
  11268. * An event triggered before rendering the scene
  11269. */
  11270. onBeforeRenderObservable: Observable<Layer>;
  11271. private _onBeforeRenderObserver;
  11272. onBeforeRender: () => void;
  11273. /**
  11274. * An event triggered after rendering the scene
  11275. */
  11276. onAfterRenderObservable: Observable<Layer>;
  11277. private _onAfterRenderObserver;
  11278. onAfterRender: () => void;
  11279. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11280. private _createIndexBuffer();
  11281. _rebuild(): void;
  11282. render(): void;
  11283. dispose(): void;
  11284. }
  11285. }
  11286. declare module BABYLON {
  11287. class LensFlare {
  11288. size: number;
  11289. position: number;
  11290. color: Color3;
  11291. texture: Nullable<Texture>;
  11292. alphaMode: number;
  11293. private _system;
  11294. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11295. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11296. dispose(): void;
  11297. }
  11298. }
  11299. declare module BABYLON {
  11300. class LensFlareSystem {
  11301. name: string;
  11302. lensFlares: LensFlare[];
  11303. borderLimit: number;
  11304. viewportBorder: number;
  11305. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11306. layerMask: number;
  11307. id: string;
  11308. private _scene;
  11309. private _emitter;
  11310. private _vertexBuffers;
  11311. private _indexBuffer;
  11312. private _effect;
  11313. private _positionX;
  11314. private _positionY;
  11315. private _isEnabled;
  11316. constructor(name: string, emitter: any, scene: Scene);
  11317. isEnabled: boolean;
  11318. getScene(): Scene;
  11319. getEmitter(): any;
  11320. setEmitter(newEmitter: any): void;
  11321. getEmitterPosition(): Vector3;
  11322. computeEffectivePosition(globalViewport: Viewport): boolean;
  11323. _isVisible(): boolean;
  11324. render(): boolean;
  11325. dispose(): void;
  11326. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11327. serialize(): any;
  11328. }
  11329. }
  11330. declare module BABYLON {
  11331. /**
  11332. * A directional light is defined by a direction (what a surprise!).
  11333. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11334. * 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.
  11335. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11336. */
  11337. class DirectionalLight extends ShadowLight {
  11338. private _shadowFrustumSize;
  11339. /**
  11340. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11341. */
  11342. /**
  11343. * Specifies a fix frustum size for the shadow generation.
  11344. */
  11345. shadowFrustumSize: number;
  11346. private _shadowOrthoScale;
  11347. /**
  11348. * Gets the shadow projection scale against the optimal computed one.
  11349. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11350. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11351. */
  11352. /**
  11353. * Sets the shadow projection scale against the optimal computed one.
  11354. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11355. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11356. */
  11357. shadowOrthoScale: number;
  11358. /**
  11359. * Automatically compute the projection matrix to best fit (including all the casters)
  11360. * on each frame.
  11361. */
  11362. autoUpdateExtends: boolean;
  11363. private _orthoLeft;
  11364. private _orthoRight;
  11365. private _orthoTop;
  11366. private _orthoBottom;
  11367. /**
  11368. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11369. * The directional light is emitted from everywhere in the given direction.
  11370. * It can cast shawdows.
  11371. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11372. * @param name The friendly name of the light
  11373. * @param direction The direction of the light
  11374. * @param scene The scene the light belongs to
  11375. */
  11376. constructor(name: string, direction: Vector3, scene: Scene);
  11377. /**
  11378. * Returns the string "DirectionalLight".
  11379. * @return The class name
  11380. */
  11381. getClassName(): string;
  11382. /**
  11383. * Returns the integer 1.
  11384. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11385. */
  11386. getTypeID(): number;
  11387. /**
  11388. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11389. * Returns the DirectionalLight Shadow projection matrix.
  11390. */
  11391. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11392. /**
  11393. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11394. * Returns the DirectionalLight Shadow projection matrix.
  11395. */
  11396. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11397. /**
  11398. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11399. * Returns the DirectionalLight Shadow projection matrix.
  11400. */
  11401. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11402. protected _buildUniformLayout(): void;
  11403. /**
  11404. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11405. * @param effect The effect to update
  11406. * @param lightIndex The index of the light in the effect to update
  11407. * @returns The directional light
  11408. */
  11409. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11410. /**
  11411. * Gets the minZ used for shadow according to both the scene and the light.
  11412. *
  11413. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11414. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11415. * @param activeCamera The camera we are returning the min for
  11416. * @returns the depth min z
  11417. */
  11418. getDepthMinZ(activeCamera: Camera): number;
  11419. /**
  11420. * Gets the maxZ used for shadow according to both the scene and the light.
  11421. *
  11422. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11423. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11424. * @param activeCamera The camera we are returning the max for
  11425. * @returns the depth max z
  11426. */
  11427. getDepthMaxZ(activeCamera: Camera): number;
  11428. }
  11429. }
  11430. declare module BABYLON {
  11431. /**
  11432. * The HemisphericLight simulates the ambient environment light,
  11433. * so the passed direction is the light reflection direction, not the incoming direction.
  11434. */
  11435. class HemisphericLight extends Light {
  11436. /**
  11437. * The groundColor is the light in the opposite direction to the one specified during creation.
  11438. * 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.
  11439. */
  11440. groundColor: Color3;
  11441. /**
  11442. * The light reflection direction, not the incoming direction.
  11443. */
  11444. direction: Vector3;
  11445. private _worldMatrix;
  11446. /**
  11447. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11448. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11449. * The HemisphericLight can't cast shadows.
  11450. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11451. * @param name The friendly name of the light
  11452. * @param direction The direction of the light reflection
  11453. * @param scene The scene the light belongs to
  11454. */
  11455. constructor(name: string, direction: Vector3, scene: Scene);
  11456. protected _buildUniformLayout(): void;
  11457. /**
  11458. * Returns the string "HemisphericLight".
  11459. * @return The class name
  11460. */
  11461. getClassName(): string;
  11462. /**
  11463. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11464. * Returns the updated direction.
  11465. * @param target The target the direction should point to
  11466. * @return The computed direction
  11467. */
  11468. setDirectionToTarget(target: Vector3): Vector3;
  11469. /**
  11470. * Returns the shadow generator associated to the light.
  11471. * @returns Always null for hemispheric lights because it does not support shadows.
  11472. */
  11473. getShadowGenerator(): Nullable<ShadowGenerator>;
  11474. /**
  11475. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11476. * @param effect The effect to update
  11477. * @param lightIndex The index of the light in the effect to update
  11478. * @returns The hemispheric light
  11479. */
  11480. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11481. /**
  11482. * @hidden internal use only.
  11483. */
  11484. _getWorldMatrix(): Matrix;
  11485. /**
  11486. * Returns the integer 3.
  11487. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11488. */
  11489. getTypeID(): number;
  11490. }
  11491. }
  11492. declare module BABYLON {
  11493. /**
  11494. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11495. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11496. * 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.
  11497. */
  11498. abstract class Light extends Node {
  11499. private static _LIGHTMAP_DEFAULT;
  11500. private static _LIGHTMAP_SPECULAR;
  11501. private static _LIGHTMAP_SHADOWSONLY;
  11502. /**
  11503. * If every light affecting the material is in this lightmapMode,
  11504. * material.lightmapTexture adds or multiplies
  11505. * (depends on material.useLightmapAsShadowmap)
  11506. * after every other light calculations.
  11507. */
  11508. static readonly LIGHTMAP_DEFAULT: number;
  11509. /**
  11510. * material.lightmapTexture as only diffuse lighting from this light
  11511. * adds only specular lighting from this light
  11512. * adds dynamic shadows
  11513. */
  11514. static readonly LIGHTMAP_SPECULAR: number;
  11515. /**
  11516. * material.lightmapTexture as only lighting
  11517. * no light calculation from this light
  11518. * only adds dynamic shadows from this light
  11519. */
  11520. static readonly LIGHTMAP_SHADOWSONLY: number;
  11521. private static _INTENSITYMODE_AUTOMATIC;
  11522. private static _INTENSITYMODE_LUMINOUSPOWER;
  11523. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11524. private static _INTENSITYMODE_ILLUMINANCE;
  11525. private static _INTENSITYMODE_LUMINANCE;
  11526. /**
  11527. * Each light type uses the default quantity according to its type:
  11528. * point/spot lights use luminous intensity
  11529. * directional lights use illuminance
  11530. */
  11531. static readonly INTENSITYMODE_AUTOMATIC: number;
  11532. /**
  11533. * lumen (lm)
  11534. */
  11535. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11536. /**
  11537. * candela (lm/sr)
  11538. */
  11539. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11540. /**
  11541. * lux (lm/m^2)
  11542. */
  11543. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11544. /**
  11545. * nit (cd/m^2)
  11546. */
  11547. static readonly INTENSITYMODE_LUMINANCE: number;
  11548. private static _LIGHTTYPEID_POINTLIGHT;
  11549. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11550. private static _LIGHTTYPEID_SPOTLIGHT;
  11551. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11552. /**
  11553. * Light type const id of the point light.
  11554. */
  11555. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11556. /**
  11557. * Light type const id of the directional light.
  11558. */
  11559. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11560. /**
  11561. * Light type const id of the spot light.
  11562. */
  11563. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11564. /**
  11565. * Light type const id of the hemispheric light.
  11566. */
  11567. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11568. /**
  11569. * Diffuse gives the basic color to an object.
  11570. */
  11571. diffuse: Color3;
  11572. /**
  11573. * Specular produces a highlight color on an object.
  11574. * Note: This is note affecting PBR materials.
  11575. */
  11576. specular: Color3;
  11577. /**
  11578. * Strength of the light.
  11579. * Note: By default it is define in the framework own unit.
  11580. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11581. */
  11582. intensity: number;
  11583. /**
  11584. * Defines how far from the source the light is impacting in scene units.
  11585. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11586. */
  11587. range: number;
  11588. /**
  11589. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11590. * of light.
  11591. */
  11592. private _photometricScale;
  11593. private _intensityMode;
  11594. /**
  11595. * Gets the photometric scale used to interpret the intensity.
  11596. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11597. */
  11598. /**
  11599. * Sets the photometric scale used to interpret the intensity.
  11600. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11601. */
  11602. intensityMode: number;
  11603. private _radius;
  11604. /**
  11605. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11606. */
  11607. /**
  11608. * sets the light radius used by PBR Materials to simulate soft area lights.
  11609. */
  11610. radius: number;
  11611. private _renderPriority;
  11612. /**
  11613. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11614. * exceeding the number allowed of the materials.
  11615. */
  11616. renderPriority: number;
  11617. private _shadowEnabled;
  11618. /**
  11619. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11620. * the current shadow generator.
  11621. */
  11622. /**
  11623. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11624. * the current shadow generator.
  11625. */
  11626. shadowEnabled: boolean;
  11627. private _includedOnlyMeshes;
  11628. /**
  11629. * Gets the only meshes impacted by this light.
  11630. */
  11631. /**
  11632. * Sets the only meshes impacted by this light.
  11633. */
  11634. includedOnlyMeshes: AbstractMesh[];
  11635. private _excludedMeshes;
  11636. /**
  11637. * Gets the meshes not impacted by this light.
  11638. */
  11639. /**
  11640. * Sets the meshes not impacted by this light.
  11641. */
  11642. excludedMeshes: AbstractMesh[];
  11643. private _excludeWithLayerMask;
  11644. /**
  11645. * Gets the layer id use to find what meshes are not impacted by the light.
  11646. * Inactive if 0
  11647. */
  11648. /**
  11649. * Sets the layer id use to find what meshes are not impacted by the light.
  11650. * Inactive if 0
  11651. */
  11652. excludeWithLayerMask: number;
  11653. private _includeOnlyWithLayerMask;
  11654. /**
  11655. * Gets the layer id use to find what meshes are impacted by the light.
  11656. * Inactive if 0
  11657. */
  11658. /**
  11659. * Sets the layer id use to find what meshes are impacted by the light.
  11660. * Inactive if 0
  11661. */
  11662. includeOnlyWithLayerMask: number;
  11663. private _lightmapMode;
  11664. /**
  11665. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11666. */
  11667. /**
  11668. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11669. */
  11670. lightmapMode: number;
  11671. private _parentedWorldMatrix;
  11672. /**
  11673. * Shadow generator associted to the light.
  11674. * Internal use only.
  11675. */
  11676. _shadowGenerator: Nullable<IShadowGenerator>;
  11677. /**
  11678. * @hidden Internal use only.
  11679. */
  11680. _excludedMeshesIds: string[];
  11681. /**
  11682. * @hidden Internal use only.
  11683. */
  11684. _includedOnlyMeshesIds: string[];
  11685. /**
  11686. * The current light unifom buffer.
  11687. * @hidden Internal use only.
  11688. */
  11689. _uniformBuffer: UniformBuffer;
  11690. /**
  11691. * Creates a Light object in the scene.
  11692. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11693. * @param name The firendly name of the light
  11694. * @param scene The scene the light belongs too
  11695. */
  11696. constructor(name: string, scene: Scene);
  11697. protected abstract _buildUniformLayout(): void;
  11698. /**
  11699. * Sets the passed Effect "effect" with the Light information.
  11700. * @param effect The effect to update
  11701. * @param lightIndex The index of the light in the effect to update
  11702. * @returns The light
  11703. */
  11704. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11705. /**
  11706. * @hidden internal use only.
  11707. */
  11708. abstract _getWorldMatrix(): Matrix;
  11709. /**
  11710. * Returns the string "Light".
  11711. * @returns the class name
  11712. */
  11713. getClassName(): string;
  11714. /**
  11715. * Converts the light information to a readable string for debug purpose.
  11716. * @param fullDetails Supports for multiple levels of logging within scene loading
  11717. * @returns the human readable light info
  11718. */
  11719. toString(fullDetails?: boolean): string;
  11720. /**
  11721. * Set the enabled state of this node.
  11722. * @param value - the new enabled state
  11723. */
  11724. setEnabled(value: boolean): void;
  11725. /**
  11726. * Returns the Light associated shadow generator if any.
  11727. * @return the associated shadow generator.
  11728. */
  11729. getShadowGenerator(): Nullable<IShadowGenerator>;
  11730. /**
  11731. * Returns a Vector3, the absolute light position in the World.
  11732. * @returns the world space position of the light
  11733. */
  11734. getAbsolutePosition(): Vector3;
  11735. /**
  11736. * Specifies if the light will affect the passed mesh.
  11737. * @param mesh The mesh to test against the light
  11738. * @return true the mesh is affected otherwise, false.
  11739. */
  11740. canAffectMesh(mesh: AbstractMesh): boolean;
  11741. /**
  11742. * Computes and Returns the light World matrix.
  11743. * @returns the world matrix
  11744. */
  11745. getWorldMatrix(): Matrix;
  11746. /**
  11747. * Sort function to order lights for rendering.
  11748. * @param a First Light object to compare to second.
  11749. * @param b Second Light object to compare first.
  11750. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11751. */
  11752. static CompareLightsPriority(a: Light, b: Light): number;
  11753. /**
  11754. * Releases resources associated with this node.
  11755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11757. */
  11758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11759. /**
  11760. * Returns the light type ID (integer).
  11761. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11762. */
  11763. getTypeID(): number;
  11764. /**
  11765. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11766. * @returns the scaled intensity in intensity mode unit
  11767. */
  11768. getScaledIntensity(): number;
  11769. /**
  11770. * Returns a new Light object, named "name", from the current one.
  11771. * @param name The name of the cloned light
  11772. * @returns the new created light
  11773. */
  11774. clone(name: string): Nullable<Light>;
  11775. /**
  11776. * Serializes the current light into a Serialization object.
  11777. * @returns the serialized object.
  11778. */
  11779. serialize(): any;
  11780. /**
  11781. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11782. * This new light is named "name" and added to the passed scene.
  11783. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11784. * @param name The friendly name of the light
  11785. * @param scene The scene the new light will belong to
  11786. * @returns the constructor function
  11787. */
  11788. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11789. /**
  11790. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11791. * @param parsedLight The JSON representation of the light
  11792. * @param scene The scene to create the parsed light in
  11793. * @returns the created light after parsing
  11794. */
  11795. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11796. private _hookArrayForExcluded(array);
  11797. private _hookArrayForIncludedOnly(array);
  11798. private _resyncMeshes();
  11799. /**
  11800. * Forces the meshes to update their light related information in their rendering used effects
  11801. * @hidden Internal Use Only
  11802. */
  11803. _markMeshesAsLightDirty(): void;
  11804. /**
  11805. * Recomputes the cached photometric scale if needed.
  11806. */
  11807. private _computePhotometricScale();
  11808. /**
  11809. * Returns the Photometric Scale according to the light type and intensity mode.
  11810. */
  11811. private _getPhotometricScale();
  11812. /**
  11813. * Reorder the light in the scene according to their defined priority.
  11814. * @hidden Internal Use Only
  11815. */
  11816. _reorderLightsInScene(): void;
  11817. }
  11818. }
  11819. declare module BABYLON {
  11820. /**
  11821. * A point light is a light defined by an unique point in world space.
  11822. * The light is emitted in every direction from this point.
  11823. * A good example of a point light is a standard light bulb.
  11824. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11825. */
  11826. class PointLight extends ShadowLight {
  11827. private _shadowAngle;
  11828. /**
  11829. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11830. * This specifies what angle the shadow will use to be created.
  11831. *
  11832. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11833. */
  11834. /**
  11835. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11836. * This specifies what angle the shadow will use to be created.
  11837. *
  11838. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11839. */
  11840. shadowAngle: number;
  11841. /**
  11842. * Gets the direction if it has been set.
  11843. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11844. */
  11845. /**
  11846. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11847. */
  11848. direction: Vector3;
  11849. /**
  11850. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11851. * A PointLight emits the light in every direction.
  11852. * It can cast shadows.
  11853. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11854. * ```javascript
  11855. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11856. * ```
  11857. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11858. * @param name The light friendly name
  11859. * @param position The position of the point light in the scene
  11860. * @param scene The scene the lights belongs to
  11861. */
  11862. constructor(name: string, position: Vector3, scene: Scene);
  11863. /**
  11864. * Returns the string "PointLight"
  11865. * @returns the class name
  11866. */
  11867. getClassName(): string;
  11868. /**
  11869. * Returns the integer 0.
  11870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11871. */
  11872. getTypeID(): number;
  11873. /**
  11874. * Specifies wether or not the shadowmap should be a cube texture.
  11875. * @returns true if the shadowmap needs to be a cube texture.
  11876. */
  11877. needCube(): boolean;
  11878. /**
  11879. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11880. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11881. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11882. */
  11883. getShadowDirection(faceIndex?: number): Vector3;
  11884. /**
  11885. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11886. * - fov = PI / 2
  11887. * - aspect ratio : 1.0
  11888. * - z-near and far equal to the active camera minZ and maxZ.
  11889. * Returns the PointLight.
  11890. */
  11891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11892. protected _buildUniformLayout(): void;
  11893. /**
  11894. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11895. * @param effect The effect to update
  11896. * @param lightIndex The index of the light in the effect to update
  11897. * @returns The point light
  11898. */
  11899. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11900. }
  11901. }
  11902. declare module BABYLON {
  11903. /**
  11904. * Interface describing all the common properties and methods a shadow light needs to implement.
  11905. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11906. * as well as binding the different shadow properties to the effects.
  11907. */
  11908. interface IShadowLight extends Light {
  11909. /**
  11910. * The light id in the scene (used in scene.findLighById for instance)
  11911. */
  11912. id: string;
  11913. /**
  11914. * The position the shdow will be casted from.
  11915. */
  11916. position: Vector3;
  11917. /**
  11918. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11919. */
  11920. direction: Vector3;
  11921. /**
  11922. * The transformed position. Position of the light in world space taking parenting in account.
  11923. */
  11924. transformedPosition: Vector3;
  11925. /**
  11926. * The transformed direction. Direction of the light in world space taking parenting in account.
  11927. */
  11928. transformedDirection: Vector3;
  11929. /**
  11930. * The friendly name of the light in the scene.
  11931. */
  11932. name: string;
  11933. /**
  11934. * Defines the shadow projection clipping minimum z value.
  11935. */
  11936. shadowMinZ: number;
  11937. /**
  11938. * Defines the shadow projection clipping maximum z value.
  11939. */
  11940. shadowMaxZ: number;
  11941. /**
  11942. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11943. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11944. */
  11945. computeTransformedInformation(): boolean;
  11946. /**
  11947. * Gets the scene the light belongs to.
  11948. * @returns The scene
  11949. */
  11950. getScene(): Scene;
  11951. /**
  11952. * Callback defining a custom Projection Matrix Builder.
  11953. * This can be used to override the default projection matrix computation.
  11954. */
  11955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11956. /**
  11957. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11958. * @param matrix The materix to updated with the projection information
  11959. * @param viewMatrix The transform matrix of the light
  11960. * @param renderList The list of mesh to render in the map
  11961. * @returns The current light
  11962. */
  11963. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11964. /**
  11965. * Gets the current depth scale used in ESM.
  11966. * @returns The scale
  11967. */
  11968. getDepthScale(): number;
  11969. /**
  11970. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11971. * @returns true if a cube texture needs to be use
  11972. */
  11973. needCube(): boolean;
  11974. /**
  11975. * Detects if the projection matrix requires to be recomputed this frame.
  11976. * @returns true if it requires to be recomputed otherwise, false.
  11977. */
  11978. needProjectionMatrixCompute(): boolean;
  11979. /**
  11980. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11981. */
  11982. forceProjectionMatrixCompute(): void;
  11983. /**
  11984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11987. */
  11988. getShadowDirection(faceIndex?: number): Vector3;
  11989. /**
  11990. * Gets the minZ used for shadow according to both the scene and the light.
  11991. * @param activeCamera The camera we are returning the min for
  11992. * @returns the depth min z
  11993. */
  11994. getDepthMinZ(activeCamera: Camera): number;
  11995. /**
  11996. * Gets the maxZ used for shadow according to both the scene and the light.
  11997. * @param activeCamera The camera we are returning the max for
  11998. * @returns the depth max z
  11999. */
  12000. getDepthMaxZ(activeCamera: Camera): number;
  12001. }
  12002. /**
  12003. * Base implementation IShadowLight
  12004. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12005. */
  12006. abstract class ShadowLight extends Light implements IShadowLight {
  12007. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12008. protected _position: Vector3;
  12009. protected _setPosition(value: Vector3): void;
  12010. /**
  12011. * Sets the position the shadow will be casted from. Also use as the light position for both
  12012. * point and spot lights.
  12013. */
  12014. /**
  12015. * Sets the position the shadow will be casted from. Also use as the light position for both
  12016. * point and spot lights.
  12017. */
  12018. position: Vector3;
  12019. protected _direction: Vector3;
  12020. protected _setDirection(value: Vector3): void;
  12021. /**
  12022. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12023. * Also use as the light direction on spot and directional lights.
  12024. */
  12025. /**
  12026. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12027. * Also use as the light direction on spot and directional lights.
  12028. */
  12029. direction: Vector3;
  12030. private _shadowMinZ;
  12031. /**
  12032. * Gets the shadow projection clipping minimum z value.
  12033. */
  12034. /**
  12035. * Sets the shadow projection clipping minimum z value.
  12036. */
  12037. shadowMinZ: number;
  12038. private _shadowMaxZ;
  12039. /**
  12040. * Sets the shadow projection clipping maximum z value.
  12041. */
  12042. /**
  12043. * Gets the shadow projection clipping maximum z value.
  12044. */
  12045. shadowMaxZ: number;
  12046. /**
  12047. * Callback defining a custom Projection Matrix Builder.
  12048. * This can be used to override the default projection matrix computation.
  12049. */
  12050. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12051. /**
  12052. * The transformed position. Position of the light in world space taking parenting in account.
  12053. */
  12054. transformedPosition: Vector3;
  12055. /**
  12056. * The transformed direction. Direction of the light in world space taking parenting in account.
  12057. */
  12058. transformedDirection: Vector3;
  12059. private _worldMatrix;
  12060. private _needProjectionMatrixCompute;
  12061. /**
  12062. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12063. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12064. */
  12065. computeTransformedInformation(): boolean;
  12066. /**
  12067. * Return the depth scale used for the shadow map.
  12068. * @returns the depth scale.
  12069. */
  12070. getDepthScale(): number;
  12071. /**
  12072. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12073. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12074. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12075. */
  12076. getShadowDirection(faceIndex?: number): Vector3;
  12077. /**
  12078. * Returns the ShadowLight absolute position in the World.
  12079. * @returns the position vector in world space
  12080. */
  12081. getAbsolutePosition(): Vector3;
  12082. /**
  12083. * Sets the ShadowLight direction toward the passed target.
  12084. * @param target The point tot target in local space
  12085. * @returns the updated ShadowLight direction
  12086. */
  12087. setDirectionToTarget(target: Vector3): Vector3;
  12088. /**
  12089. * Returns the light rotation in euler definition.
  12090. * @returns the x y z rotation in local space.
  12091. */
  12092. getRotation(): Vector3;
  12093. /**
  12094. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12095. * @returns true if a cube texture needs to be use
  12096. */
  12097. needCube(): boolean;
  12098. /**
  12099. * Detects if the projection matrix requires to be recomputed this frame.
  12100. * @returns true if it requires to be recomputed otherwise, false.
  12101. */
  12102. needProjectionMatrixCompute(): boolean;
  12103. /**
  12104. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12105. */
  12106. forceProjectionMatrixCompute(): void;
  12107. /**
  12108. * Get the world matrix of the sahdow lights.
  12109. * @hidden Internal Use Only
  12110. */
  12111. _getWorldMatrix(): Matrix;
  12112. /**
  12113. * Gets the minZ used for shadow according to both the scene and the light.
  12114. * @param activeCamera The camera we are returning the min for
  12115. * @returns the depth min z
  12116. */
  12117. getDepthMinZ(activeCamera: Camera): number;
  12118. /**
  12119. * Gets the maxZ used for shadow according to both the scene and the light.
  12120. * @param activeCamera The camera we are returning the max for
  12121. * @returns the depth max z
  12122. */
  12123. getDepthMaxZ(activeCamera: Camera): number;
  12124. /**
  12125. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12126. * @param matrix The materix to updated with the projection information
  12127. * @param viewMatrix The transform matrix of the light
  12128. * @param renderList The list of mesh to render in the map
  12129. * @returns The current light
  12130. */
  12131. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12132. }
  12133. }
  12134. declare module BABYLON {
  12135. /**
  12136. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12137. * These values define a cone of light starting from the position, emitting toward the direction.
  12138. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12139. * and the exponent defines the speed of the decay of the light with distance (reach).
  12140. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12141. */
  12142. class SpotLight extends ShadowLight {
  12143. private _angle;
  12144. /**
  12145. * Gets the cone angle of the spot light in Radians.
  12146. */
  12147. /**
  12148. * Sets the cone angle of the spot light in Radians.
  12149. */
  12150. angle: number;
  12151. private _shadowAngleScale;
  12152. /**
  12153. * Allows scaling the angle of the light for shadow generation only.
  12154. */
  12155. /**
  12156. * Allows scaling the angle of the light for shadow generation only.
  12157. */
  12158. shadowAngleScale: number;
  12159. /**
  12160. * The light decay speed with the distance from the emission spot.
  12161. */
  12162. exponent: number;
  12163. private _projectionTextureMatrix;
  12164. /**
  12165. * Allows reading the projecton texture
  12166. */
  12167. readonly projectionTextureMatrix: Matrix;
  12168. protected _projectionTextureLightNear: number;
  12169. /**
  12170. * Gets the near clip of the Spotlight for texture projection.
  12171. */
  12172. /**
  12173. * Sets the near clip of the Spotlight for texture projection.
  12174. */
  12175. projectionTextureLightNear: number;
  12176. protected _projectionTextureLightFar: number;
  12177. /**
  12178. * Gets the far clip of the Spotlight for texture projection.
  12179. */
  12180. /**
  12181. * Sets the far clip of the Spotlight for texture projection.
  12182. */
  12183. projectionTextureLightFar: number;
  12184. protected _projectionTextureUpDirection: Vector3;
  12185. /**
  12186. * Gets the Up vector of the Spotlight for texture projection.
  12187. */
  12188. /**
  12189. * Sets the Up vector of the Spotlight for texture projection.
  12190. */
  12191. projectionTextureUpDirection: Vector3;
  12192. private _projectionTexture;
  12193. /**
  12194. * Gets the projection texture of the light.
  12195. */
  12196. /**
  12197. * Sets the projection texture of the light.
  12198. */
  12199. projectionTexture: Nullable<BaseTexture>;
  12200. private _projectionTextureViewLightDirty;
  12201. private _projectionTextureProjectionLightDirty;
  12202. private _projectionTextureDirty;
  12203. private _projectionTextureViewTargetVector;
  12204. private _projectionTextureViewLightMatrix;
  12205. private _projectionTextureProjectionLightMatrix;
  12206. private _projectionTextureScalingMatrix;
  12207. /**
  12208. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12209. * It can cast shadows.
  12210. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12211. * @param name The light friendly name
  12212. * @param position The position of the spot light in the scene
  12213. * @param direction The direction of the light in the scene
  12214. * @param angle The cone angle of the light in Radians
  12215. * @param exponent The light decay speed with the distance from the emission spot
  12216. * @param scene The scene the lights belongs to
  12217. */
  12218. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12219. /**
  12220. * Returns the string "SpotLight".
  12221. * @returns the class name
  12222. */
  12223. getClassName(): string;
  12224. /**
  12225. * Returns the integer 2.
  12226. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12227. */
  12228. getTypeID(): number;
  12229. /**
  12230. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12231. */
  12232. protected _setDirection(value: Vector3): void;
  12233. /**
  12234. * Overrides the position setter to recompute the projection texture view light Matrix.
  12235. */
  12236. protected _setPosition(value: Vector3): void;
  12237. /**
  12238. * 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.
  12239. * Returns the SpotLight.
  12240. */
  12241. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12242. protected _computeProjectionTextureViewLightMatrix(): void;
  12243. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12244. /**
  12245. * Main function for light texture projection matrix computing.
  12246. */
  12247. protected _computeProjectionTextureMatrix(): void;
  12248. protected _buildUniformLayout(): void;
  12249. /**
  12250. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12251. * @param effect The effect to update
  12252. * @param lightIndex The index of the light in the effect to update
  12253. * @returns The spot light
  12254. */
  12255. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12256. /**
  12257. * Disposes the light and the associated resources.
  12258. */
  12259. dispose(): void;
  12260. }
  12261. }
  12262. declare module BABYLON {
  12263. interface ILoadingScreen {
  12264. displayLoadingUI: () => void;
  12265. hideLoadingUI: () => void;
  12266. loadingUIBackgroundColor: string;
  12267. loadingUIText: string;
  12268. }
  12269. class DefaultLoadingScreen implements ILoadingScreen {
  12270. private _renderingCanvas;
  12271. private _loadingText;
  12272. private _loadingDivBackgroundColor;
  12273. private _loadingDiv;
  12274. private _loadingTextDiv;
  12275. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12276. displayLoadingUI(): void;
  12277. hideLoadingUI(): void;
  12278. loadingUIText: string;
  12279. loadingUIBackgroundColor: string;
  12280. private _resizeLoadingUI;
  12281. }
  12282. }
  12283. declare module BABYLON {
  12284. class SceneLoaderProgressEvent {
  12285. readonly lengthComputable: boolean;
  12286. readonly loaded: number;
  12287. readonly total: number;
  12288. constructor(lengthComputable: boolean, loaded: number, total: number);
  12289. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12290. }
  12291. interface ISceneLoaderPluginExtensions {
  12292. [extension: string]: {
  12293. isBinary: boolean;
  12294. };
  12295. }
  12296. interface ISceneLoaderPluginFactory {
  12297. name: string;
  12298. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12299. canDirectLoad?: (data: string) => boolean;
  12300. }
  12301. interface ISceneLoaderPlugin {
  12302. /**
  12303. * The friendly name of this plugin.
  12304. */
  12305. name: string;
  12306. /**
  12307. * The file extensions supported by this plugin.
  12308. */
  12309. extensions: string | ISceneLoaderPluginExtensions;
  12310. /**
  12311. * Import meshes into a scene.
  12312. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12313. * @param scene The scene to import into
  12314. * @param data The data to import
  12315. * @param rootUrl The root url for scene and resources
  12316. * @param meshes The meshes array to import into
  12317. * @param particleSystems The particle systems array to import into
  12318. * @param skeletons The skeletons array to import into
  12319. * @param onError The callback when import fails
  12320. * @returns True if successful or false otherwise
  12321. */
  12322. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12323. /**
  12324. * Load into a scene.
  12325. * @param scene The scene to load into
  12326. * @param data The data to import
  12327. * @param rootUrl The root url for scene and resources
  12328. * @param onError The callback when import fails
  12329. * @returns true if successful or false otherwise
  12330. */
  12331. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12332. /**
  12333. * The callback that returns true if the data can be directly loaded.
  12334. */
  12335. canDirectLoad?: (data: string) => boolean;
  12336. /**
  12337. * The callback that allows custom handling of the root url based on the response url.
  12338. */
  12339. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12340. /**
  12341. * Load into an asset container.
  12342. * @param scene The scene to load into
  12343. * @param data The data to import
  12344. * @param rootUrl The root url for scene and resources
  12345. * @param onError The callback when import fails
  12346. * @returns The loaded asset container
  12347. */
  12348. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12349. }
  12350. interface ISceneLoaderPluginAsync {
  12351. /**
  12352. * The friendly name of this plugin.
  12353. */
  12354. name: string;
  12355. /**
  12356. * The file extensions supported by this plugin.
  12357. */
  12358. extensions: string | ISceneLoaderPluginExtensions;
  12359. /**
  12360. * Import meshes into a scene.
  12361. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12362. * @param scene The scene to import into
  12363. * @param data The data to import
  12364. * @param rootUrl The root url for scene and resources
  12365. * @param onProgress The callback when the load progresses
  12366. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12367. */
  12368. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12369. meshes: AbstractMesh[];
  12370. particleSystems: ParticleSystem[];
  12371. skeletons: Skeleton[];
  12372. animationGroups: AnimationGroup[];
  12373. }>;
  12374. /**
  12375. * Load into a scene.
  12376. * @param scene The scene to load into
  12377. * @param data The data to import
  12378. * @param rootUrl The root url for scene and resources
  12379. * @param onProgress The callback when the load progresses
  12380. * @returns Nothing
  12381. */
  12382. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12383. /**
  12384. * The callback that returns true if the data can be directly loaded.
  12385. */
  12386. canDirectLoad?: (data: string) => boolean;
  12387. /**
  12388. * The callback that allows custom handling of the root url based on the response url.
  12389. */
  12390. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12391. /**
  12392. * Load into an asset container.
  12393. * @param scene The scene to load into
  12394. * @param data The data to import
  12395. * @param rootUrl The root url for scene and resources
  12396. * @param onProgress The callback when the load progresses
  12397. * @returns The loaded asset container
  12398. */
  12399. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12400. }
  12401. class SceneLoader {
  12402. private static _ForceFullSceneLoadingForIncremental;
  12403. private static _ShowLoadingScreen;
  12404. private static _CleanBoneMatrixWeights;
  12405. static readonly NO_LOGGING: number;
  12406. static readonly MINIMAL_LOGGING: number;
  12407. static readonly SUMMARY_LOGGING: number;
  12408. static readonly DETAILED_LOGGING: number;
  12409. private static _loggingLevel;
  12410. static ForceFullSceneLoadingForIncremental: boolean;
  12411. static ShowLoadingScreen: boolean;
  12412. static loggingLevel: number;
  12413. static CleanBoneMatrixWeights: boolean;
  12414. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12415. private static _registeredPlugins;
  12416. private static _getDefaultPlugin();
  12417. private static _getPluginForExtension(extension);
  12418. private static _getPluginForDirectLoad(data);
  12419. private static _getPluginForFilename(sceneFilename);
  12420. private static _getDirectLoad(sceneFilename);
  12421. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12422. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12423. static IsPluginForExtensionAvailable(extension: string): boolean;
  12424. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12425. /**
  12426. * Import meshes into a scene
  12427. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12428. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12429. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12430. * @param scene the instance of BABYLON.Scene to append to
  12431. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12432. * @param onProgress a callback with a progress event for each file being loaded
  12433. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12434. * @param pluginExtension the extension used to determine the plugin
  12435. * @returns The loaded plugin
  12436. */
  12437. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<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>;
  12438. /**
  12439. * Import meshes into a scene
  12440. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12441. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12442. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12443. * @param scene the instance of BABYLON.Scene to append to
  12444. * @param onProgress a callback with a progress event for each file being loaded
  12445. * @param pluginExtension the extension used to determine the plugin
  12446. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12447. */
  12448. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12449. meshes: AbstractMesh[];
  12450. particleSystems: ParticleSystem[];
  12451. skeletons: Skeleton[];
  12452. animationGroups: AnimationGroup[];
  12453. }>;
  12454. /**
  12455. * Load a scene
  12456. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12457. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12458. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12459. * @param onSuccess a callback with the scene when import succeeds
  12460. * @param onProgress a callback with a progress event for each file being loaded
  12461. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12462. * @param pluginExtension the extension used to determine the plugin
  12463. * @returns The loaded plugin
  12464. */
  12465. 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>;
  12466. /**
  12467. * Load a scene
  12468. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12469. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12470. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12471. * @param onProgress a callback with a progress event for each file being loaded
  12472. * @param pluginExtension the extension used to determine the plugin
  12473. * @returns The loaded scene
  12474. */
  12475. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12476. /**
  12477. * Append a scene
  12478. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12479. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12480. * @param scene is the instance of BABYLON.Scene to append to
  12481. * @param onSuccess a callback with the scene when import succeeds
  12482. * @param onProgress a callback with a progress event for each file being loaded
  12483. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12484. * @param pluginExtension the extension used to determine the plugin
  12485. * @returns The loaded plugin
  12486. */
  12487. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12488. /**
  12489. * Append a scene
  12490. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12491. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12492. * @param scene is the instance of BABYLON.Scene to append to
  12493. * @param onProgress a callback with a progress event for each file being loaded
  12494. * @param pluginExtension the extension used to determine the plugin
  12495. * @returns The given scene
  12496. */
  12497. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12498. /**
  12499. * Load a scene into an asset container
  12500. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12501. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12502. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12503. * @param onSuccess a callback with the scene when import succeeds
  12504. * @param onProgress a callback with a progress event for each file being loaded
  12505. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12506. * @param pluginExtension the extension used to determine the plugin
  12507. * @returns The loaded plugin
  12508. */
  12509. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12510. /**
  12511. * Load a scene into an asset container
  12512. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12513. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12514. * @param scene is the instance of BABYLON.Scene to append to
  12515. * @param onProgress a callback with a progress event for each file being loaded
  12516. * @param pluginExtension the extension used to determine the plugin
  12517. * @returns The loaded asset container
  12518. */
  12519. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12520. }
  12521. }
  12522. declare module BABYLON {
  12523. /**
  12524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12526. * 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;
  12527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12528. */
  12529. class ColorCurves {
  12530. private _dirty;
  12531. private _tempColor;
  12532. private _globalCurve;
  12533. private _highlightsCurve;
  12534. private _midtonesCurve;
  12535. private _shadowsCurve;
  12536. private _positiveCurve;
  12537. private _negativeCurve;
  12538. private _globalHue;
  12539. private _globalDensity;
  12540. private _globalSaturation;
  12541. private _globalExposure;
  12542. /**
  12543. * Gets the global Hue value.
  12544. * 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).
  12545. */
  12546. /**
  12547. * Sets the global Hue value.
  12548. * 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).
  12549. */
  12550. globalHue: number;
  12551. /**
  12552. * Gets the global Density value.
  12553. * 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.
  12554. * Values less than zero provide a filter of opposite hue.
  12555. */
  12556. /**
  12557. * Sets the global Density value.
  12558. * 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.
  12559. * Values less than zero provide a filter of opposite hue.
  12560. */
  12561. globalDensity: number;
  12562. /**
  12563. * Gets the global Saturation value.
  12564. * 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.
  12565. */
  12566. /**
  12567. * Sets the global Saturation value.
  12568. * 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.
  12569. */
  12570. globalSaturation: number;
  12571. /**
  12572. * Gets the global Exposure value.
  12573. * 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.
  12574. */
  12575. /**
  12576. * Sets the global Exposure value.
  12577. * 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.
  12578. */
  12579. globalExposure: number;
  12580. private _highlightsHue;
  12581. private _highlightsDensity;
  12582. private _highlightsSaturation;
  12583. private _highlightsExposure;
  12584. /**
  12585. * Gets the highlights Hue value.
  12586. * 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).
  12587. */
  12588. /**
  12589. * Sets the highlights Hue value.
  12590. * 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).
  12591. */
  12592. highlightsHue: number;
  12593. /**
  12594. * Gets the highlights Density value.
  12595. * 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.
  12596. * Values less than zero provide a filter of opposite hue.
  12597. */
  12598. /**
  12599. * Sets the highlights Density value.
  12600. * 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.
  12601. * Values less than zero provide a filter of opposite hue.
  12602. */
  12603. highlightsDensity: number;
  12604. /**
  12605. * Gets the highlights Saturation value.
  12606. * 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.
  12607. */
  12608. /**
  12609. * Sets the highlights Saturation value.
  12610. * 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.
  12611. */
  12612. highlightsSaturation: number;
  12613. /**
  12614. * Gets the highlights Exposure value.
  12615. * 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.
  12616. */
  12617. /**
  12618. * Sets the highlights Exposure value.
  12619. * 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.
  12620. */
  12621. highlightsExposure: number;
  12622. private _midtonesHue;
  12623. private _midtonesDensity;
  12624. private _midtonesSaturation;
  12625. private _midtonesExposure;
  12626. /**
  12627. * Gets the midtones Hue value.
  12628. * 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).
  12629. */
  12630. /**
  12631. * Sets the midtones Hue value.
  12632. * 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).
  12633. */
  12634. midtonesHue: number;
  12635. /**
  12636. * Gets the midtones Density value.
  12637. * 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.
  12638. * Values less than zero provide a filter of opposite hue.
  12639. */
  12640. /**
  12641. * Sets the midtones Density value.
  12642. * 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.
  12643. * Values less than zero provide a filter of opposite hue.
  12644. */
  12645. midtonesDensity: number;
  12646. /**
  12647. * Gets the midtones Saturation value.
  12648. * 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.
  12649. */
  12650. /**
  12651. * Sets the midtones Saturation value.
  12652. * 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.
  12653. */
  12654. midtonesSaturation: number;
  12655. /**
  12656. * Gets the midtones Exposure value.
  12657. * 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.
  12658. */
  12659. /**
  12660. * Sets the midtones Exposure value.
  12661. * 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.
  12662. */
  12663. midtonesExposure: number;
  12664. private _shadowsHue;
  12665. private _shadowsDensity;
  12666. private _shadowsSaturation;
  12667. private _shadowsExposure;
  12668. /**
  12669. * Gets the shadows Hue value.
  12670. * 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).
  12671. */
  12672. /**
  12673. * Sets the shadows Hue value.
  12674. * 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).
  12675. */
  12676. shadowsHue: number;
  12677. /**
  12678. * Gets the shadows Density value.
  12679. * 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.
  12680. * Values less than zero provide a filter of opposite hue.
  12681. */
  12682. /**
  12683. * Sets the shadows Density value.
  12684. * 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.
  12685. * Values less than zero provide a filter of opposite hue.
  12686. */
  12687. shadowsDensity: number;
  12688. /**
  12689. * Gets the shadows Saturation value.
  12690. * 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.
  12691. */
  12692. /**
  12693. * Sets the shadows Saturation value.
  12694. * 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.
  12695. */
  12696. shadowsSaturation: number;
  12697. /**
  12698. * Gets the shadows Exposure value.
  12699. * 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.
  12700. */
  12701. /**
  12702. * Sets the shadows Exposure value.
  12703. * 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.
  12704. */
  12705. shadowsExposure: number;
  12706. getClassName(): string;
  12707. /**
  12708. * Binds the color curves to the shader.
  12709. * @param colorCurves The color curve to bind
  12710. * @param effect The effect to bind to
  12711. */
  12712. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12713. /**
  12714. * Prepare the list of uniforms associated with the ColorCurves effects.
  12715. * @param uniformsList The list of uniforms used in the effect
  12716. */
  12717. static PrepareUniforms(uniformsList: string[]): void;
  12718. /**
  12719. * Returns color grading data based on a hue, density, saturation and exposure value.
  12720. * @param filterHue The hue of the color filter.
  12721. * @param filterDensity The density of the color filter.
  12722. * @param saturation The saturation.
  12723. * @param exposure The exposure.
  12724. * @param result The result data container.
  12725. */
  12726. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12727. /**
  12728. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12729. * @param value The input slider value in range [-100,100].
  12730. * @returns Adjusted value.
  12731. */
  12732. private static applyColorGradingSliderNonlinear(value);
  12733. /**
  12734. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12735. * @param hue The hue (H) input.
  12736. * @param saturation The saturation (S) input.
  12737. * @param brightness The brightness (B) input.
  12738. * @result An RGBA color represented as Vector4.
  12739. */
  12740. private static fromHSBToRef(hue, saturation, brightness, result);
  12741. /**
  12742. * Returns a value clamped between min and max
  12743. * @param value The value to clamp
  12744. * @param min The minimum of value
  12745. * @param max The maximum of value
  12746. * @returns The clamped value.
  12747. */
  12748. private static clamp(value, min, max);
  12749. /**
  12750. * Clones the current color curve instance.
  12751. * @return The cloned curves
  12752. */
  12753. clone(): ColorCurves;
  12754. /**
  12755. * Serializes the current color curve instance to a json representation.
  12756. * @return a JSON representation
  12757. */
  12758. serialize(): any;
  12759. /**
  12760. * Parses the color curve from a json representation.
  12761. * @param source the JSON source to parse
  12762. * @return The parsed curves
  12763. */
  12764. static Parse(source: any): ColorCurves;
  12765. }
  12766. }
  12767. declare module BABYLON {
  12768. /**
  12769. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12770. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12771. */
  12772. class EffectFallbacks {
  12773. private _defines;
  12774. private _currentRank;
  12775. private _maxRank;
  12776. private _mesh;
  12777. /**
  12778. * Removes the fallback from the bound mesh.
  12779. */
  12780. unBindMesh(): void;
  12781. /**
  12782. * Adds a fallback on the specified property.
  12783. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12784. * @param define The name of the define in the shader
  12785. */
  12786. addFallback(rank: number, define: string): void;
  12787. /**
  12788. * Sets the mesh to use CPU skinning when needing to fallback.
  12789. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12790. * @param mesh The mesh to use the fallbacks.
  12791. */
  12792. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12793. /**
  12794. * Checks to see if more fallbacks are still availible.
  12795. */
  12796. readonly isMoreFallbacks: boolean;
  12797. /**
  12798. * Removes the defines that shoould be removed when falling back.
  12799. * @param currentDefines defines the current define statements for the shader.
  12800. * @param effect defines the current effect we try to compile
  12801. * @returns The resulting defines with defines of the current rank removed.
  12802. */
  12803. reduce(currentDefines: string, effect: Effect): string;
  12804. }
  12805. /**
  12806. * Options to be used when creating an effect.
  12807. */
  12808. class EffectCreationOptions {
  12809. /**
  12810. * Atrributes that will be used in the shader.
  12811. */
  12812. attributes: string[];
  12813. /**
  12814. * Uniform varible names that will be set in the shader.
  12815. */
  12816. uniformsNames: string[];
  12817. /**
  12818. * Uniform buffer varible names that will be set in the shader.
  12819. */
  12820. uniformBuffersNames: string[];
  12821. /**
  12822. * Sampler texture variable names that will be set in the shader.
  12823. */
  12824. samplers: string[];
  12825. /**
  12826. * Define statements that will be set in the shader.
  12827. */
  12828. defines: any;
  12829. /**
  12830. * Possible fallbacks for this effect to improve performance when needed.
  12831. */
  12832. fallbacks: Nullable<EffectFallbacks>;
  12833. /**
  12834. * Callback that will be called when the shader is compiled.
  12835. */
  12836. onCompiled: Nullable<(effect: Effect) => void>;
  12837. /**
  12838. * Callback that will be called if an error occurs during shader compilation.
  12839. */
  12840. onError: Nullable<(effect: Effect, errors: string) => void>;
  12841. /**
  12842. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12843. */
  12844. indexParameters: any;
  12845. /**
  12846. * Max number of lights that can be used in the shader.
  12847. */
  12848. maxSimultaneousLights: number;
  12849. /**
  12850. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12851. */
  12852. transformFeedbackVaryings: Nullable<string[]>;
  12853. }
  12854. /**
  12855. * Effect containing vertex and fragment shader that can be executed on an object.
  12856. */
  12857. class Effect {
  12858. /**
  12859. * Name of the effect.
  12860. */
  12861. name: any;
  12862. /**
  12863. * String container all the define statements that should be set on the shader.
  12864. */
  12865. defines: string;
  12866. /**
  12867. * Callback that will be called when the shader is compiled.
  12868. */
  12869. onCompiled: Nullable<(effect: Effect) => void>;
  12870. /**
  12871. * Callback that will be called if an error occurs during shader compilation.
  12872. */
  12873. onError: Nullable<(effect: Effect, errors: string) => void>;
  12874. /**
  12875. * Callback that will be called when effect is bound.
  12876. */
  12877. onBind: Nullable<(effect: Effect) => void>;
  12878. /**
  12879. * Unique ID of the effect.
  12880. */
  12881. uniqueId: number;
  12882. /**
  12883. * Observable that will be called when the shader is compiled.
  12884. */
  12885. onCompileObservable: Observable<Effect>;
  12886. /**
  12887. * Observable that will be called if an error occurs during shader compilation.
  12888. */
  12889. onErrorObservable: Observable<Effect>;
  12890. /**
  12891. * Observable that will be called when effect is bound.
  12892. */
  12893. onBindObservable: Observable<Effect>;
  12894. /** @hidden */
  12895. _bonesComputationForcedToCPU: boolean;
  12896. private static _uniqueIdSeed;
  12897. private _engine;
  12898. private _uniformBuffersNames;
  12899. private _uniformsNames;
  12900. private _samplers;
  12901. private _isReady;
  12902. private _compilationError;
  12903. private _attributesNames;
  12904. private _attributes;
  12905. private _uniforms;
  12906. /**
  12907. * Key for the effect.
  12908. */
  12909. _key: string;
  12910. private _indexParameters;
  12911. private _fallbacks;
  12912. private _vertexSourceCode;
  12913. private _fragmentSourceCode;
  12914. private _vertexSourceCodeOverride;
  12915. private _fragmentSourceCodeOverride;
  12916. private _transformFeedbackVaryings;
  12917. /**
  12918. * Compiled shader to webGL program.
  12919. */
  12920. _program: WebGLProgram;
  12921. private _valueCache;
  12922. private static _baseCache;
  12923. /**
  12924. * Instantiates an effect.
  12925. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12926. * @param baseName Name of the effect.
  12927. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12928. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12929. * @param samplers List of sampler variables that will be passed to the shader.
  12930. * @param engine Engine to be used to render the effect
  12931. * @param defines Define statements to be added to the shader.
  12932. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12933. * @param onCompiled Callback that will be called when the shader is compiled.
  12934. * @param onError Callback that will be called if an error occurs during shader compilation.
  12935. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12936. */
  12937. 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);
  12938. /**
  12939. * Unique key for this effect
  12940. */
  12941. readonly key: string;
  12942. /**
  12943. * If the effect has been compiled and prepared.
  12944. * @returns if the effect is compiled and prepared.
  12945. */
  12946. isReady(): boolean;
  12947. /**
  12948. * The engine the effect was initialized with.
  12949. * @returns the engine.
  12950. */
  12951. getEngine(): Engine;
  12952. /**
  12953. * The compiled webGL program for the effect
  12954. * @returns the webGL program.
  12955. */
  12956. getProgram(): WebGLProgram;
  12957. /**
  12958. * The set of names of attribute variables for the shader.
  12959. * @returns An array of attribute names.
  12960. */
  12961. getAttributesNames(): string[];
  12962. /**
  12963. * Returns the attribute at the given index.
  12964. * @param index The index of the attribute.
  12965. * @returns The location of the attribute.
  12966. */
  12967. getAttributeLocation(index: number): number;
  12968. /**
  12969. * Returns the attribute based on the name of the variable.
  12970. * @param name of the attribute to look up.
  12971. * @returns the attribute location.
  12972. */
  12973. getAttributeLocationByName(name: string): number;
  12974. /**
  12975. * The number of attributes.
  12976. * @returns the numnber of attributes.
  12977. */
  12978. getAttributesCount(): number;
  12979. /**
  12980. * Gets the index of a uniform variable.
  12981. * @param uniformName of the uniform to look up.
  12982. * @returns the index.
  12983. */
  12984. getUniformIndex(uniformName: string): number;
  12985. /**
  12986. * Returns the attribute based on the name of the variable.
  12987. * @param uniformName of the uniform to look up.
  12988. * @returns the location of the uniform.
  12989. */
  12990. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12991. /**
  12992. * Returns an array of sampler variable names
  12993. * @returns The array of sampler variable neames.
  12994. */
  12995. getSamplers(): string[];
  12996. /**
  12997. * The error from the last compilation.
  12998. * @returns the error string.
  12999. */
  13000. getCompilationError(): string;
  13001. /**
  13002. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13003. * @param func The callback to be used.
  13004. */
  13005. executeWhenCompiled(func: (effect: Effect) => void): void;
  13006. /** @hidden */
  13007. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13008. /** @hidden */
  13009. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13010. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  13011. private _processShaderConversion(sourceCode, isFragment, callback);
  13012. private _processIncludes(sourceCode, callback);
  13013. private _processPrecision(source);
  13014. /**
  13015. * Recompiles the webGL program
  13016. * @param vertexSourceCode The source code for the vertex shader.
  13017. * @param fragmentSourceCode The source code for the fragment shader.
  13018. * @param onCompiled Callback called when completed.
  13019. * @param onError Callback called on error.
  13020. */
  13021. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13022. /**
  13023. * Gets the uniform locations of the the specified variable names
  13024. * @param names THe names of the variables to lookup.
  13025. * @returns Array of locations in the same order as variable names.
  13026. */
  13027. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13028. /**
  13029. * Prepares the effect
  13030. */
  13031. _prepareEffect(): void;
  13032. /**
  13033. * Checks if the effect is supported. (Must be called after compilation)
  13034. */
  13035. readonly isSupported: boolean;
  13036. /**
  13037. * Binds a texture to the engine to be used as output of the shader.
  13038. * @param channel Name of the output variable.
  13039. * @param texture Texture to bind.
  13040. */
  13041. _bindTexture(channel: string, texture: InternalTexture): void;
  13042. /**
  13043. * Sets a texture on the engine to be used in the shader.
  13044. * @param channel Name of the sampler variable.
  13045. * @param texture Texture to set.
  13046. */
  13047. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13048. /**
  13049. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13050. * @param channel Name of the sampler variable.
  13051. * @param texture Texture to set.
  13052. */
  13053. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13054. /**
  13055. * Sets an array of textures on the engine to be used in the shader.
  13056. * @param channel Name of the variable.
  13057. * @param textures Textures to set.
  13058. */
  13059. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13060. /**
  13061. * 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)
  13062. * @param channel Name of the sampler variable.
  13063. * @param postProcess Post process to get the input texture from.
  13064. */
  13065. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13066. /**
  13067. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13068. * 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)
  13069. * @param channel Name of the sampler variable.
  13070. * @param postProcess Post process to get the output texture from.
  13071. */
  13072. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13073. /** @hidden */
  13074. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13075. /** @hidden */
  13076. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13077. /** @hidden */
  13078. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13079. /** @hidden */
  13080. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13081. /**
  13082. * Binds a buffer to a uniform.
  13083. * @param buffer Buffer to bind.
  13084. * @param name Name of the uniform variable to bind to.
  13085. */
  13086. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13087. /**
  13088. * Binds block to a uniform.
  13089. * @param blockName Name of the block to bind.
  13090. * @param index Index to bind.
  13091. */
  13092. bindUniformBlock(blockName: string, index: number): void;
  13093. /**
  13094. * Sets an interger value on a uniform variable.
  13095. * @param uniformName Name of the variable.
  13096. * @param value Value to be set.
  13097. * @returns this effect.
  13098. */
  13099. setInt(uniformName: string, value: number): Effect;
  13100. /**
  13101. * Sets an int array on a uniform variable.
  13102. * @param uniformName Name of the variable.
  13103. * @param array array to be set.
  13104. * @returns this effect.
  13105. */
  13106. setIntArray(uniformName: string, array: Int32Array): Effect;
  13107. /**
  13108. * 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)
  13109. * @param uniformName Name of the variable.
  13110. * @param array array to be set.
  13111. * @returns this effect.
  13112. */
  13113. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13114. /**
  13115. * 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)
  13116. * @param uniformName Name of the variable.
  13117. * @param array array to be set.
  13118. * @returns this effect.
  13119. */
  13120. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13121. /**
  13122. * 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)
  13123. * @param uniformName Name of the variable.
  13124. * @param array array to be set.
  13125. * @returns this effect.
  13126. */
  13127. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13128. /**
  13129. * Sets an float array on a uniform variable.
  13130. * @param uniformName Name of the variable.
  13131. * @param array array to be set.
  13132. * @returns this effect.
  13133. */
  13134. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13135. /**
  13136. * 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)
  13137. * @param uniformName Name of the variable.
  13138. * @param array array to be set.
  13139. * @returns this effect.
  13140. */
  13141. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13142. /**
  13143. * 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)
  13144. * @param uniformName Name of the variable.
  13145. * @param array array to be set.
  13146. * @returns this effect.
  13147. */
  13148. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13149. /**
  13150. * 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)
  13151. * @param uniformName Name of the variable.
  13152. * @param array array to be set.
  13153. * @returns this effect.
  13154. */
  13155. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13156. /**
  13157. * Sets an array on a uniform variable.
  13158. * @param uniformName Name of the variable.
  13159. * @param array array to be set.
  13160. * @returns this effect.
  13161. */
  13162. setArray(uniformName: string, array: number[]): Effect;
  13163. /**
  13164. * 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)
  13165. * @param uniformName Name of the variable.
  13166. * @param array array to be set.
  13167. * @returns this effect.
  13168. */
  13169. setArray2(uniformName: string, array: number[]): Effect;
  13170. /**
  13171. * 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)
  13172. * @param uniformName Name of the variable.
  13173. * @param array array to be set.
  13174. * @returns this effect.
  13175. */
  13176. setArray3(uniformName: string, array: number[]): Effect;
  13177. /**
  13178. * 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)
  13179. * @param uniformName Name of the variable.
  13180. * @param array array to be set.
  13181. * @returns this effect.
  13182. */
  13183. setArray4(uniformName: string, array: number[]): Effect;
  13184. /**
  13185. * Sets matrices on a uniform variable.
  13186. * @param uniformName Name of the variable.
  13187. * @param matrices matrices to be set.
  13188. * @returns this effect.
  13189. */
  13190. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13191. /**
  13192. * Sets matrix on a uniform variable.
  13193. * @param uniformName Name of the variable.
  13194. * @param matrix matrix to be set.
  13195. * @returns this effect.
  13196. */
  13197. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13198. /**
  13199. * 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)
  13200. * @param uniformName Name of the variable.
  13201. * @param matrix matrix to be set.
  13202. * @returns this effect.
  13203. */
  13204. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13205. /**
  13206. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13207. * @param uniformName Name of the variable.
  13208. * @param matrix matrix to be set.
  13209. * @returns this effect.
  13210. */
  13211. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13212. /**
  13213. * Sets a float on a uniform variable.
  13214. * @param uniformName Name of the variable.
  13215. * @param value value to be set.
  13216. * @returns this effect.
  13217. */
  13218. setFloat(uniformName: string, value: number): Effect;
  13219. /**
  13220. * Sets a boolean on a uniform variable.
  13221. * @param uniformName Name of the variable.
  13222. * @param bool value to be set.
  13223. * @returns this effect.
  13224. */
  13225. setBool(uniformName: string, bool: boolean): Effect;
  13226. /**
  13227. * Sets a Vector2 on a uniform variable.
  13228. * @param uniformName Name of the variable.
  13229. * @param vector2 vector2 to be set.
  13230. * @returns this effect.
  13231. */
  13232. setVector2(uniformName: string, vector2: Vector2): Effect;
  13233. /**
  13234. * Sets a float2 on a uniform variable.
  13235. * @param uniformName Name of the variable.
  13236. * @param x First float in float2.
  13237. * @param y Second float in float2.
  13238. * @returns this effect.
  13239. */
  13240. setFloat2(uniformName: string, x: number, y: number): Effect;
  13241. /**
  13242. * Sets a Vector3 on a uniform variable.
  13243. * @param uniformName Name of the variable.
  13244. * @param vector3 Value to be set.
  13245. * @returns this effect.
  13246. */
  13247. setVector3(uniformName: string, vector3: Vector3): Effect;
  13248. /**
  13249. * Sets a float3 on a uniform variable.
  13250. * @param uniformName Name of the variable.
  13251. * @param x First float in float3.
  13252. * @param y Second float in float3.
  13253. * @param z Third float in float3.
  13254. * @returns this effect.
  13255. */
  13256. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13257. /**
  13258. * Sets a Vector4 on a uniform variable.
  13259. * @param uniformName Name of the variable.
  13260. * @param vector4 Value to be set.
  13261. * @returns this effect.
  13262. */
  13263. setVector4(uniformName: string, vector4: Vector4): Effect;
  13264. /**
  13265. * Sets a float4 on a uniform variable.
  13266. * @param uniformName Name of the variable.
  13267. * @param x First float in float4.
  13268. * @param y Second float in float4.
  13269. * @param z Third float in float4.
  13270. * @param w Fourth float in float4.
  13271. * @returns this effect.
  13272. */
  13273. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13274. /**
  13275. * Sets a Color3 on a uniform variable.
  13276. * @param uniformName Name of the variable.
  13277. * @param color3 Value to be set.
  13278. * @returns this effect.
  13279. */
  13280. setColor3(uniformName: string, color3: Color3): Effect;
  13281. /**
  13282. * Sets a Color4 on a uniform variable.
  13283. * @param uniformName Name of the variable.
  13284. * @param color3 Value to be set.
  13285. * @param alpha Alpha value to be set.
  13286. * @returns this effect.
  13287. */
  13288. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13289. /**
  13290. * Sets a Color4 on a uniform variable
  13291. * @param uniformName defines the name of the variable
  13292. * @param color4 defines the value to be set
  13293. * @returns this effect.
  13294. */
  13295. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13296. /**
  13297. * Store of each shader (The can be looked up using effect.key)
  13298. */
  13299. static ShadersStore: {
  13300. [key: string]: string;
  13301. };
  13302. /**
  13303. * Store of each included file for a shader (The can be looked up using effect.key)
  13304. */
  13305. static IncludesShadersStore: {
  13306. [key: string]: string;
  13307. };
  13308. /**
  13309. * Resets the cache of effects.
  13310. */
  13311. static ResetCache(): void;
  13312. }
  13313. }
  13314. declare module BABYLON {
  13315. class FresnelParameters {
  13316. private _isEnabled;
  13317. isEnabled: boolean;
  13318. leftColor: Color3;
  13319. rightColor: Color3;
  13320. bias: number;
  13321. power: number;
  13322. clone(): FresnelParameters;
  13323. serialize(): any;
  13324. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. /**
  13329. * Interface to follow in your material defines to integrate easily the
  13330. * Image proccessing functions.
  13331. * @hidden
  13332. */
  13333. interface IImageProcessingConfigurationDefines {
  13334. IMAGEPROCESSING: boolean;
  13335. VIGNETTE: boolean;
  13336. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13337. VIGNETTEBLENDMODEOPAQUE: boolean;
  13338. TONEMAPPING: boolean;
  13339. CONTRAST: boolean;
  13340. EXPOSURE: boolean;
  13341. COLORCURVES: boolean;
  13342. COLORGRADING: boolean;
  13343. COLORGRADING3D: boolean;
  13344. SAMPLER3DGREENDEPTH: boolean;
  13345. SAMPLER3DBGRMAP: boolean;
  13346. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13347. }
  13348. /**
  13349. * This groups together the common properties used for image processing either in direct forward pass
  13350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13351. * or not.
  13352. */
  13353. class ImageProcessingConfiguration {
  13354. /**
  13355. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13356. */
  13357. colorCurves: Nullable<ColorCurves>;
  13358. private _colorCurvesEnabled;
  13359. /**
  13360. * Gets wether the color curves effect is enabled.
  13361. */
  13362. /**
  13363. * Sets wether the color curves effect is enabled.
  13364. */
  13365. colorCurvesEnabled: boolean;
  13366. /**
  13367. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13368. */
  13369. colorGradingTexture: Nullable<BaseTexture>;
  13370. private _colorGradingEnabled;
  13371. /**
  13372. * Gets wether the color grading effect is enabled.
  13373. */
  13374. /**
  13375. * Sets wether the color grading effect is enabled.
  13376. */
  13377. colorGradingEnabled: boolean;
  13378. private _colorGradingWithGreenDepth;
  13379. /**
  13380. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13381. */
  13382. /**
  13383. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13384. */
  13385. colorGradingWithGreenDepth: boolean;
  13386. private _colorGradingBGR;
  13387. /**
  13388. * Gets wether the color grading texture contains BGR values.
  13389. */
  13390. /**
  13391. * Sets wether the color grading texture contains BGR values.
  13392. */
  13393. colorGradingBGR: boolean;
  13394. _exposure: number;
  13395. /**
  13396. * Gets the Exposure used in the effect.
  13397. */
  13398. /**
  13399. * Sets the Exposure used in the effect.
  13400. */
  13401. exposure: number;
  13402. private _toneMappingEnabled;
  13403. /**
  13404. * Gets wether the tone mapping effect is enabled.
  13405. */
  13406. /**
  13407. * Sets wether the tone mapping effect is enabled.
  13408. */
  13409. toneMappingEnabled: boolean;
  13410. protected _contrast: number;
  13411. /**
  13412. * Gets the contrast used in the effect.
  13413. */
  13414. /**
  13415. * Sets the contrast used in the effect.
  13416. */
  13417. contrast: number;
  13418. /**
  13419. * Vignette stretch size.
  13420. */
  13421. vignetteStretch: number;
  13422. /**
  13423. * Vignette centre X Offset.
  13424. */
  13425. vignetteCentreX: number;
  13426. /**
  13427. * Vignette centre Y Offset.
  13428. */
  13429. vignetteCentreY: number;
  13430. /**
  13431. * Vignette weight or intensity of the vignette effect.
  13432. */
  13433. vignetteWeight: number;
  13434. /**
  13435. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13436. * if vignetteEnabled is set to true.
  13437. */
  13438. vignetteColor: Color4;
  13439. /**
  13440. * Camera field of view used by the Vignette effect.
  13441. */
  13442. vignetteCameraFov: number;
  13443. private _vignetteBlendMode;
  13444. /**
  13445. * Gets the vignette blend mode allowing different kind of effect.
  13446. */
  13447. /**
  13448. * Sets the vignette blend mode allowing different kind of effect.
  13449. */
  13450. vignetteBlendMode: number;
  13451. private _vignetteEnabled;
  13452. /**
  13453. * Gets wether the vignette effect is enabled.
  13454. */
  13455. /**
  13456. * Sets wether the vignette effect is enabled.
  13457. */
  13458. vignetteEnabled: boolean;
  13459. private _applyByPostProcess;
  13460. /**
  13461. * Gets wether the image processing is applied through a post process or not.
  13462. */
  13463. /**
  13464. * Sets wether the image processing is applied through a post process or not.
  13465. */
  13466. applyByPostProcess: boolean;
  13467. private _isEnabled;
  13468. /**
  13469. * Gets wether the image processing is enabled or not.
  13470. */
  13471. /**
  13472. * Sets wether the image processing is enabled or not.
  13473. */
  13474. isEnabled: boolean;
  13475. /**
  13476. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13477. */
  13478. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13479. /**
  13480. * Method called each time the image processing information changes requires to recompile the effect.
  13481. */
  13482. protected _updateParameters(): void;
  13483. getClassName(): string;
  13484. /**
  13485. * Prepare the list of uniforms associated with the Image Processing effects.
  13486. * @param uniformsList The list of uniforms used in the effect
  13487. * @param defines the list of defines currently in use
  13488. */
  13489. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13490. /**
  13491. * Prepare the list of samplers associated with the Image Processing effects.
  13492. * @param uniformsList The list of uniforms used in the effect
  13493. * @param defines the list of defines currently in use
  13494. */
  13495. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13496. /**
  13497. * Prepare the list of defines associated to the shader.
  13498. * @param defines the list of defines to complete
  13499. */
  13500. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13501. /**
  13502. * Returns true if all the image processing information are ready.
  13503. */
  13504. isReady(): boolean;
  13505. /**
  13506. * Binds the image processing to the shader.
  13507. * @param effect The effect to bind to
  13508. */
  13509. bind(effect: Effect, aspectRatio?: number): void;
  13510. /**
  13511. * Clones the current image processing instance.
  13512. * @return The cloned image processing
  13513. */
  13514. clone(): ImageProcessingConfiguration;
  13515. /**
  13516. * Serializes the current image processing instance to a json representation.
  13517. * @return a JSON representation
  13518. */
  13519. serialize(): any;
  13520. /**
  13521. * Parses the image processing from a json representation.
  13522. * @param source the JSON source to parse
  13523. * @return The parsed image processing
  13524. */
  13525. static Parse(source: any): ImageProcessingConfiguration;
  13526. private static _VIGNETTEMODE_MULTIPLY;
  13527. private static _VIGNETTEMODE_OPAQUE;
  13528. /**
  13529. * Used to apply the vignette as a mix with the pixel color.
  13530. */
  13531. static readonly VIGNETTEMODE_MULTIPLY: number;
  13532. /**
  13533. * Used to apply the vignette as a replacement of the pixel color.
  13534. */
  13535. static readonly VIGNETTEMODE_OPAQUE: number;
  13536. }
  13537. }
  13538. declare module BABYLON {
  13539. /**
  13540. * Manages the defines for the Material
  13541. */
  13542. class MaterialDefines {
  13543. private _keys;
  13544. private _isDirty;
  13545. /** @hidden */
  13546. _renderId: number;
  13547. /** @hidden */
  13548. _areLightsDirty: boolean;
  13549. /** @hidden */
  13550. _areAttributesDirty: boolean;
  13551. /** @hidden */
  13552. _areTexturesDirty: boolean;
  13553. /** @hidden */
  13554. _areFresnelDirty: boolean;
  13555. /** @hidden */
  13556. _areMiscDirty: boolean;
  13557. /** @hidden */
  13558. _areImageProcessingDirty: boolean;
  13559. /** @hidden */
  13560. _normals: boolean;
  13561. /** @hidden */
  13562. _uvs: boolean;
  13563. /** @hidden */
  13564. _needNormals: boolean;
  13565. /** @hidden */
  13566. _needUVs: boolean;
  13567. /**
  13568. * Specifies if the material needs to be re-calculated
  13569. */
  13570. readonly isDirty: boolean;
  13571. /**
  13572. * Marks the material to indicate that it has been re-calculated
  13573. */
  13574. markAsProcessed(): void;
  13575. /**
  13576. * Marks the material to indicate that it needs to be re-calculated
  13577. */
  13578. markAsUnprocessed(): void;
  13579. /**
  13580. * Marks the material to indicate all of its defines need to be re-calculated
  13581. */
  13582. markAllAsDirty(): void;
  13583. /**
  13584. * Marks the material to indicate that image processing needs to be re-calculated
  13585. */
  13586. markAsImageProcessingDirty(): void;
  13587. /**
  13588. * Marks the material to indicate the lights need to be re-calculated
  13589. */
  13590. markAsLightDirty(): void;
  13591. /**
  13592. * Marks the attribute state as changed
  13593. */
  13594. markAsAttributesDirty(): void;
  13595. /**
  13596. * Marks the texture state as changed
  13597. */
  13598. markAsTexturesDirty(): void;
  13599. /**
  13600. * Marks the fresnel state as changed
  13601. */
  13602. markAsFresnelDirty(): void;
  13603. /**
  13604. * Marks the misc state as changed
  13605. */
  13606. markAsMiscDirty(): void;
  13607. /**
  13608. * Rebuilds the material defines
  13609. */
  13610. rebuild(): void;
  13611. /**
  13612. * Specifies if two material defines are equal
  13613. * @param other - A material define instance to compare to
  13614. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13615. */
  13616. isEqual(other: MaterialDefines): boolean;
  13617. /**
  13618. * Clones this instance's defines to another instance
  13619. * @param other - material defines to clone values to
  13620. */
  13621. cloneTo(other: MaterialDefines): void;
  13622. /**
  13623. * Resets the material define values
  13624. */
  13625. reset(): void;
  13626. /**
  13627. * Converts the material define values to a string
  13628. * @returns - String of material define information
  13629. */
  13630. toString(): string;
  13631. }
  13632. /**
  13633. * Base class for the main features of a material in Babylon.js
  13634. */
  13635. class Material implements IAnimatable {
  13636. private static _TriangleFillMode;
  13637. private static _WireFrameFillMode;
  13638. private static _PointFillMode;
  13639. private static _PointListDrawMode;
  13640. private static _LineListDrawMode;
  13641. private static _LineLoopDrawMode;
  13642. private static _LineStripDrawMode;
  13643. private static _TriangleStripDrawMode;
  13644. private static _TriangleFanDrawMode;
  13645. /**
  13646. * Returns the triangle fill mode
  13647. */
  13648. static readonly TriangleFillMode: number;
  13649. /**
  13650. * Returns the wireframe mode
  13651. */
  13652. static readonly WireFrameFillMode: number;
  13653. /**
  13654. * Returns the point fill mode
  13655. */
  13656. static readonly PointFillMode: number;
  13657. /**
  13658. * Returns the point list draw mode
  13659. */
  13660. static readonly PointListDrawMode: number;
  13661. /**
  13662. * Returns the line list draw mode
  13663. */
  13664. static readonly LineListDrawMode: number;
  13665. /**
  13666. * Returns the line loop draw mode
  13667. */
  13668. static readonly LineLoopDrawMode: number;
  13669. /**
  13670. * Returns the line strip draw mode
  13671. */
  13672. static readonly LineStripDrawMode: number;
  13673. /**
  13674. * Returns the triangle strip draw mode
  13675. */
  13676. static readonly TriangleStripDrawMode: number;
  13677. /**
  13678. * Returns the triangle fan draw mode
  13679. */
  13680. static readonly TriangleFanDrawMode: number;
  13681. /**
  13682. * Stores the clock-wise side orientation
  13683. */
  13684. private static _ClockWiseSideOrientation;
  13685. /**
  13686. * Stores the counter clock-wise side orientation
  13687. */
  13688. private static _CounterClockWiseSideOrientation;
  13689. /**
  13690. * Returns the clock-wise side orientation
  13691. */
  13692. static readonly ClockWiseSideOrientation: number;
  13693. /**
  13694. * Returns the counter clock-wise side orientation
  13695. */
  13696. static readonly CounterClockWiseSideOrientation: number;
  13697. /**
  13698. * The dirty texture flag value
  13699. */
  13700. private static _TextureDirtyFlag;
  13701. /**
  13702. * The dirty light flag value
  13703. */
  13704. private static _LightDirtyFlag;
  13705. /**
  13706. * The dirty fresnel flag value
  13707. */
  13708. private static _FresnelDirtyFlag;
  13709. /**
  13710. * The dirty attribute flag value
  13711. */
  13712. private static _AttributesDirtyFlag;
  13713. /**
  13714. * The dirty misc flag value
  13715. */
  13716. private static _MiscDirtyFlag;
  13717. /**
  13718. * Returns the dirty texture flag value
  13719. */
  13720. static readonly TextureDirtyFlag: number;
  13721. /**
  13722. * Returns the dirty light flag value
  13723. */
  13724. static readonly LightDirtyFlag: number;
  13725. /**
  13726. * Returns the dirty fresnel flag value
  13727. */
  13728. static readonly FresnelDirtyFlag: number;
  13729. /**
  13730. * Returns the dirty attributes flag value
  13731. */
  13732. static readonly AttributesDirtyFlag: number;
  13733. /**
  13734. * Returns the dirty misc flag value
  13735. */
  13736. static readonly MiscDirtyFlag: number;
  13737. /**
  13738. * The ID of the material
  13739. */
  13740. id: string;
  13741. /**
  13742. * Gets or sets the unique id of the material
  13743. */
  13744. uniqueId: number;
  13745. /**
  13746. * The name of the material
  13747. */
  13748. name: string;
  13749. /**
  13750. * Specifies if the ready state should be checked on each call
  13751. */
  13752. checkReadyOnEveryCall: boolean;
  13753. /**
  13754. * Specifies if the ready state should be checked once
  13755. */
  13756. checkReadyOnlyOnce: boolean;
  13757. /**
  13758. * The state of the material
  13759. */
  13760. state: string;
  13761. /**
  13762. * The alpha value of the material
  13763. */
  13764. protected _alpha: number;
  13765. /**
  13766. * Gets the alpha value of the material
  13767. */
  13768. /**
  13769. * Sets the alpha value of the material
  13770. */
  13771. alpha: number;
  13772. /**
  13773. * Specifies if back face culling is enabled
  13774. */
  13775. protected _backFaceCulling: boolean;
  13776. /**
  13777. * Gets the back-face culling state
  13778. */
  13779. /**
  13780. * Sets the back-face culling state
  13781. */
  13782. backFaceCulling: boolean;
  13783. /**
  13784. * Stores the value for side orientation
  13785. */
  13786. sideOrientation: number;
  13787. /**
  13788. * Callback triggered when the material is compiled
  13789. */
  13790. onCompiled: (effect: Effect) => void;
  13791. /**
  13792. * Callback triggered when an error occurs
  13793. */
  13794. onError: (effect: Effect, errors: string) => void;
  13795. /**
  13796. * Callback triggered to get the render target textures
  13797. */
  13798. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13799. /**
  13800. * Specifies if the material should be serialized
  13801. */
  13802. doNotSerialize: boolean;
  13803. /**
  13804. * Specifies if the effect should be stored on sub meshes
  13805. */
  13806. storeEffectOnSubMeshes: boolean;
  13807. /**
  13808. * Stores the animations for the material
  13809. */
  13810. animations: Array<Animation>;
  13811. /**
  13812. * An event triggered when the material is disposed
  13813. */
  13814. onDisposeObservable: Observable<Material>;
  13815. /**
  13816. * An observer which watches for dispose events
  13817. */
  13818. private _onDisposeObserver;
  13819. /**
  13820. * Called during a dispose event
  13821. */
  13822. onDispose: () => void;
  13823. /**
  13824. * An event triggered when the material is bound
  13825. */
  13826. onBindObservable: Observable<AbstractMesh>;
  13827. /**
  13828. * An observer which watches for bind events
  13829. */
  13830. private _onBindObserver;
  13831. /**
  13832. * Called during a bind event
  13833. */
  13834. onBind: (Mesh: AbstractMesh) => void;
  13835. /**
  13836. * An event triggered when the material is unbound
  13837. */
  13838. onUnBindObservable: Observable<Material>;
  13839. /**
  13840. * Stores the value of the alpha mode
  13841. */
  13842. private _alphaMode;
  13843. /**
  13844. * Gets the value of the alpha mode
  13845. */
  13846. /**
  13847. * Sets the value of the alpha mode.
  13848. *
  13849. * | Value | Type | Description |
  13850. * | --- | --- | --- |
  13851. * | 0 | ALPHA_DISABLE | |
  13852. * | 1 | ALPHA_ADD | |
  13853. * | 2 | ALPHA_COMBINE | |
  13854. * | 3 | ALPHA_SUBTRACT | |
  13855. * | 4 | ALPHA_MULTIPLY | |
  13856. * | 5 | ALPHA_MAXIMIZED | |
  13857. * | 6 | ALPHA_ONEONE | |
  13858. * | 7 | ALPHA_PREMULTIPLIED | |
  13859. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13860. * | 9 | ALPHA_INTERPOLATE | |
  13861. * | 10 | ALPHA_SCREENMODE | |
  13862. *
  13863. */
  13864. alphaMode: number;
  13865. /**
  13866. * Stores the state of the need depth pre-pass value
  13867. */
  13868. private _needDepthPrePass;
  13869. /**
  13870. * Gets the depth pre-pass value
  13871. */
  13872. /**
  13873. * Sets the need depth pre-pass value
  13874. */
  13875. needDepthPrePass: boolean;
  13876. /**
  13877. * Specifies if depth writing should be disabled
  13878. */
  13879. disableDepthWrite: boolean;
  13880. /**
  13881. * Specifies if depth writing should be forced
  13882. */
  13883. forceDepthWrite: boolean;
  13884. /**
  13885. * Specifies if there should be a separate pass for culling
  13886. */
  13887. separateCullingPass: boolean;
  13888. /**
  13889. * Stores the state specifing if fog should be enabled
  13890. */
  13891. private _fogEnabled;
  13892. /**
  13893. * Gets the value of the fog enabled state
  13894. */
  13895. /**
  13896. * Sets the state for enabling fog
  13897. */
  13898. fogEnabled: boolean;
  13899. /**
  13900. * Stores the size of points
  13901. */
  13902. pointSize: number;
  13903. /**
  13904. * Stores the z offset value
  13905. */
  13906. zOffset: number;
  13907. /**
  13908. * Gets a value specifying if wireframe mode is enabled
  13909. */
  13910. /**
  13911. * Sets the state of wireframe mode
  13912. */
  13913. wireframe: boolean;
  13914. /**
  13915. * Gets the value specifying if point clouds are enabled
  13916. */
  13917. /**
  13918. * Sets the state of point cloud mode
  13919. */
  13920. pointsCloud: boolean;
  13921. /**
  13922. * Gets the material fill mode
  13923. */
  13924. /**
  13925. * Sets the material fill mode
  13926. */
  13927. fillMode: number;
  13928. /**
  13929. * Stores the effects for the material
  13930. */
  13931. _effect: Nullable<Effect>;
  13932. /**
  13933. * Specifies if the material was previously ready
  13934. */
  13935. _wasPreviouslyReady: boolean;
  13936. /**
  13937. * Specifies if uniform buffers should be used
  13938. */
  13939. private _useUBO;
  13940. /**
  13941. * Stores a reference to the scene
  13942. */
  13943. private _scene;
  13944. /**
  13945. * Stores the fill mode state
  13946. */
  13947. private _fillMode;
  13948. /**
  13949. * Specifies if the depth write state should be cached
  13950. */
  13951. private _cachedDepthWriteState;
  13952. /**
  13953. * Stores the uniform buffer
  13954. */
  13955. protected _uniformBuffer: UniformBuffer;
  13956. /**
  13957. * Creates a material instance
  13958. * @param name defines the name of the material
  13959. * @param scene defines the scene to reference
  13960. * @param doNotAdd specifies if the material should be added to the scene
  13961. */
  13962. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13963. /**
  13964. * Returns a string representation of the current material
  13965. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13966. * @returns a string with material information
  13967. */
  13968. toString(fullDetails?: boolean): string;
  13969. /**
  13970. * Gets the class name of the material
  13971. * @returns a string with the class name of the material
  13972. */
  13973. getClassName(): string;
  13974. /**
  13975. * Specifies if updates for the material been locked
  13976. */
  13977. readonly isFrozen: boolean;
  13978. /**
  13979. * Locks updates for the material
  13980. */
  13981. freeze(): void;
  13982. /**
  13983. * Unlocks updates for the material
  13984. */
  13985. unfreeze(): void;
  13986. /**
  13987. * Specifies if the material is ready to be used
  13988. * @param mesh defines the mesh to check
  13989. * @param useInstances specifies if instances should be used
  13990. * @returns a boolean indicating if the material is ready to be used
  13991. */
  13992. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13993. /**
  13994. * Specifies that the submesh is ready to be used
  13995. * @param mesh defines the mesh to check
  13996. * @param subMesh defines which submesh to check
  13997. * @param useInstances specifies that instances should be used
  13998. * @returns a boolean indicating that the submesh is ready or not
  13999. */
  14000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14001. /**
  14002. * Returns the material effect
  14003. * @returns the effect associated with the material
  14004. */
  14005. getEffect(): Nullable<Effect>;
  14006. /**
  14007. * Returns the current scene
  14008. * @returns a Scene
  14009. */
  14010. getScene(): Scene;
  14011. /**
  14012. * Specifies if the material will require alpha blending
  14013. * @returns a boolean specifying if alpha blending is needed
  14014. */
  14015. needAlphaBlending(): boolean;
  14016. /**
  14017. * Specifies if the mesh will require alpha blending
  14018. * @param mesh defines the mesh to check
  14019. * @returns a boolean specifying if alpha blending is needed for the mesh
  14020. */
  14021. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14022. /**
  14023. * Specifies if this material should be rendered in alpha test mode
  14024. * @returns a boolean specifying if an alpha test is needed.
  14025. */
  14026. needAlphaTesting(): boolean;
  14027. /**
  14028. * Gets the texture used for the alpha test
  14029. * @returns the texture to use for alpha testing
  14030. */
  14031. getAlphaTestTexture(): Nullable<BaseTexture>;
  14032. /**
  14033. * Marks the material to indicate that it needs to be re-calculated
  14034. */
  14035. markDirty(): void;
  14036. /** @hidden */
  14037. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14038. /**
  14039. * Binds the material to the mesh
  14040. * @param world defines the world transformation matrix
  14041. * @param mesh defines the mesh to bind the material to
  14042. */
  14043. bind(world: Matrix, mesh?: Mesh): void;
  14044. /**
  14045. * Binds the submesh to the material
  14046. * @param world defines the world transformation matrix
  14047. * @param mesh defines the mesh containing the submesh
  14048. * @param subMesh defines the submesh to bind the material to
  14049. */
  14050. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14051. /**
  14052. * Binds the world matrix to the material
  14053. * @param world defines the world transformation matrix
  14054. */
  14055. bindOnlyWorldMatrix(world: Matrix): void;
  14056. /**
  14057. * Binds the scene's uniform buffer to the effect.
  14058. * @param effect defines the effect to bind to the scene uniform buffer
  14059. * @param sceneUbo defines the uniform buffer storing scene data
  14060. */
  14061. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14062. /**
  14063. * Binds the view matrix to the effect
  14064. * @param effect defines the effect to bind the view matrix to
  14065. */
  14066. bindView(effect: Effect): void;
  14067. /**
  14068. * Binds the view projection matrix to the effect
  14069. * @param effect defines the effect to bind the view projection matrix to
  14070. */
  14071. bindViewProjection(effect: Effect): void;
  14072. /**
  14073. * Specifies if material alpha testing should be turned on for the mesh
  14074. * @param mesh defines the mesh to check
  14075. */
  14076. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14077. /**
  14078. * Processes to execute after binding the material to a mesh
  14079. * @param mesh defines the rendered mesh
  14080. */
  14081. protected _afterBind(mesh?: Mesh): void;
  14082. /**
  14083. * Unbinds the material from the mesh
  14084. */
  14085. unbind(): void;
  14086. /**
  14087. * Gets the active textures from the material
  14088. * @returns an array of textures
  14089. */
  14090. getActiveTextures(): BaseTexture[];
  14091. /**
  14092. * Specifies if the material uses a texture
  14093. * @param texture defines the texture to check against the material
  14094. * @returns a boolean specifying if the material uses the texture
  14095. */
  14096. hasTexture(texture: BaseTexture): boolean;
  14097. /**
  14098. * Makes a duplicate of the material, and gives it a new name
  14099. * @param name defines the new name for the duplicated material
  14100. * @returns the cloned material
  14101. */
  14102. clone(name: string): Nullable<Material>;
  14103. /**
  14104. * Gets the meshes bound to the material
  14105. * @returns an array of meshes bound to the material
  14106. */
  14107. getBindedMeshes(): AbstractMesh[];
  14108. /**
  14109. * Force shader compilation
  14110. * @param mesh defines the mesh associated with this material
  14111. * @param onCompiled defines a function to execute once the material is compiled
  14112. * @param options defines the options to configure the compilation
  14113. */
  14114. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14115. clipPlane: boolean;
  14116. }>): void;
  14117. /**
  14118. * Force shader compilation
  14119. * @param mesh defines the mesh that will use this material
  14120. * @param options defines additional options for compiling the shaders
  14121. * @returns a promise that resolves when the compilation completes
  14122. */
  14123. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14124. clipPlane: boolean;
  14125. }>): Promise<void>;
  14126. /**
  14127. * Marks a define in the material to indicate that it needs to be re-computed
  14128. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14129. */
  14130. markAsDirty(flag: number): void;
  14131. /**
  14132. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14133. * @param func defines a function which checks material defines against the submeshes
  14134. */
  14135. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14136. /**
  14137. * Indicates that image processing needs to be re-calculated for all submeshes
  14138. */
  14139. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14140. /**
  14141. * Indicates that textures need to be re-calculated for all submeshes
  14142. */
  14143. protected _markAllSubMeshesAsTexturesDirty(): void;
  14144. /**
  14145. * Indicates that fresnel needs to be re-calculated for all submeshes
  14146. */
  14147. protected _markAllSubMeshesAsFresnelDirty(): void;
  14148. /**
  14149. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14150. */
  14151. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14152. /**
  14153. * Indicates that lights need to be re-calculated for all submeshes
  14154. */
  14155. protected _markAllSubMeshesAsLightsDirty(): void;
  14156. /**
  14157. * Indicates that attributes need to be re-calculated for all submeshes
  14158. */
  14159. protected _markAllSubMeshesAsAttributesDirty(): void;
  14160. /**
  14161. * Indicates that misc needs to be re-calculated for all submeshes
  14162. */
  14163. protected _markAllSubMeshesAsMiscDirty(): void;
  14164. /**
  14165. * Indicates that textures and misc need to be re-calculated for all submeshes
  14166. */
  14167. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14168. /**
  14169. * Disposes the material
  14170. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14171. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14172. */
  14173. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14174. /**
  14175. * Serializes this material
  14176. * @returns the serialized material object
  14177. */
  14178. serialize(): any;
  14179. /**
  14180. * Creates a MultiMaterial from parsed MultiMaterial data.
  14181. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14182. * @param scene defines the hosting scene
  14183. * @returns a new MultiMaterial
  14184. */
  14185. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14186. /**
  14187. * Creates a material from parsed material data
  14188. * @param parsedMaterial defines parsed material data
  14189. * @param scene defines the hosting scene
  14190. * @param rootUrl defines the root URL to use to load textures
  14191. * @returns a new material
  14192. */
  14193. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14194. }
  14195. }
  14196. declare module BABYLON {
  14197. /**
  14198. * "Static Class" containing the most commonly used helper while dealing with material for
  14199. * rendering purpose.
  14200. *
  14201. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14202. *
  14203. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14204. */
  14205. class MaterialHelper {
  14206. /**
  14207. * Bind the current view position to an effect.
  14208. * @param effect The effect to be bound
  14209. * @param scene The scene the eyes position is used from
  14210. */
  14211. static BindEyePosition(effect: Effect, scene: Scene): void;
  14212. /**
  14213. * Helps preparing the defines values about the UVs in used in the effect.
  14214. * UVs are shared as much as we can accross chanels in the shaders.
  14215. * @param texture The texture we are preparing the UVs for
  14216. * @param defines The defines to update
  14217. * @param key The chanel key "diffuse", "specular"... used in the shader
  14218. */
  14219. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14220. /**
  14221. * Binds a texture matrix value to its corrsponding uniform
  14222. * @param texture The texture to bind the matrix for
  14223. * @param uniformBuffer The uniform buffer receivin the data
  14224. * @param key The chanel key "diffuse", "specular"... used in the shader
  14225. */
  14226. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14227. /**
  14228. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14229. * @param mesh defines the current mesh
  14230. * @param scene defines the current scene
  14231. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14232. * @param pointsCloud defines if point cloud rendering has to be turned on
  14233. * @param fogEnabled defines if fog has to be turned on
  14234. * @param alphaTest defines if alpha testing has to be turned on
  14235. * @param defines defines the current list of defines
  14236. */
  14237. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14238. /**
  14239. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14240. * @param scene defines the current scene
  14241. * @param engine defines the current engine
  14242. * @param defines specifies the list of active defines
  14243. * @param useInstances defines if instances have to be turned on
  14244. * @param useClipPlane defines if clip plane have to be turned on
  14245. */
  14246. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14247. /**
  14248. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14249. * @param mesh The mesh containing the geometry data we will draw
  14250. * @param defines The defines to update
  14251. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14252. * @param useBones Precise whether bones should be used or not (override mesh info)
  14253. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14254. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14255. * @returns false if defines are considered not dirty and have not been checked
  14256. */
  14257. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14258. /**
  14259. * Prepares the defines related to the light information passed in parameter
  14260. * @param scene The scene we are intending to draw
  14261. * @param mesh The mesh the effect is compiling for
  14262. * @param defines The defines to update
  14263. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14264. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14265. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14266. * @returns true if normals will be required for the rest of the effect
  14267. */
  14268. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14269. /**
  14270. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14271. * that won t be acctive due to defines being turned off.
  14272. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14273. * @param samplersList The samplers list
  14274. * @param defines The defines helping in the list generation
  14275. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14276. */
  14277. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14278. /**
  14279. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14280. * @param defines The defines to update while falling back
  14281. * @param fallbacks The authorized effect fallbacks
  14282. * @param maxSimultaneousLights The maximum number of lights allowed
  14283. * @param rank the current rank of the Effect
  14284. * @returns The newly affected rank
  14285. */
  14286. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14287. /**
  14288. * Prepares the list of attributes required for morph targets according to the effect defines.
  14289. * @param attribs The current list of supported attribs
  14290. * @param mesh The mesh to prepare the morph targets attributes for
  14291. * @param defines The current Defines of the effect
  14292. */
  14293. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14294. /**
  14295. * Prepares the list of attributes required for bones according to the effect defines.
  14296. * @param attribs The current list of supported attribs
  14297. * @param mesh The mesh to prepare the bones attributes for
  14298. * @param defines The current Defines of the effect
  14299. * @param fallbacks The current efffect fallback strategy
  14300. */
  14301. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14302. /**
  14303. * Prepares the list of attributes required for instances according to the effect defines.
  14304. * @param attribs The current list of supported attribs
  14305. * @param defines The current Defines of the effect
  14306. */
  14307. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14308. /**
  14309. * Binds the light shadow information to the effect for the given mesh.
  14310. * @param light The light containing the generator
  14311. * @param scene The scene the lights belongs to
  14312. * @param mesh The mesh we are binding the information to render
  14313. * @param lightIndex The light index in the effect used to render the mesh
  14314. * @param effect The effect we are binding the data to
  14315. */
  14316. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14317. /**
  14318. * Binds the light information to the effect.
  14319. * @param light The light containing the generator
  14320. * @param effect The effect we are binding the data to
  14321. * @param lightIndex The light index in the effect used to render
  14322. */
  14323. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14324. /**
  14325. * Binds the lights information from the scene to the effect for the given mesh.
  14326. * @param scene The scene the lights belongs to
  14327. * @param mesh The mesh we are binding the information to render
  14328. * @param effect The effect we are binding the data to
  14329. * @param defines The generated defines for the effect
  14330. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14331. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14332. */
  14333. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14334. /**
  14335. * Binds the fog information from the scene to the effect for the given mesh.
  14336. * @param scene The scene the lights belongs to
  14337. * @param mesh The mesh we are binding the information to render
  14338. * @param effect The effect we are binding the data to
  14339. */
  14340. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14341. /**
  14342. * Binds the bones information from the mesh to the effect.
  14343. * @param mesh The mesh we are binding the information to render
  14344. * @param effect The effect we are binding the data to
  14345. */
  14346. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14347. /**
  14348. * Binds the morph targets information from the mesh to the effect.
  14349. * @param abstractMesh The mesh we are binding the information to render
  14350. * @param effect The effect we are binding the data to
  14351. */
  14352. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14353. /**
  14354. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14355. * @param defines The generated defines used in the effect
  14356. * @param effect The effect we are binding the data to
  14357. * @param scene The scene we are willing to render with logarithmic scale for
  14358. */
  14359. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14360. /**
  14361. * Binds the clip plane information from the scene to the effect.
  14362. * @param scene The scene the clip plane information are extracted from
  14363. * @param effect The effect we are binding the data to
  14364. */
  14365. static BindClipPlane(effect: Effect, scene: Scene): void;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. class MultiMaterial extends Material {
  14370. private _subMaterials;
  14371. subMaterials: Nullable<Material>[];
  14372. constructor(name: string, scene: Scene);
  14373. private _hookArray(array);
  14374. getSubMaterial(index: number): Nullable<Material>;
  14375. getActiveTextures(): BaseTexture[];
  14376. getClassName(): string;
  14377. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14378. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14379. serialize(): any;
  14380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14381. }
  14382. }
  14383. declare module BABYLON {
  14384. class PushMaterial extends Material {
  14385. protected _activeEffect: Effect;
  14386. protected _normalMatrix: Matrix;
  14387. constructor(name: string, scene: Scene);
  14388. getEffect(): Effect;
  14389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14390. /**
  14391. * Binds the given world matrix to the active effect
  14392. *
  14393. * @param world the matrix to bind
  14394. */
  14395. bindOnlyWorldMatrix(world: Matrix): void;
  14396. /**
  14397. * Binds the given normal matrix to the active effect
  14398. *
  14399. * @param normalMatrix the matrix to bind
  14400. */
  14401. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14402. bind(world: Matrix, mesh?: Mesh): void;
  14403. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14404. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14405. }
  14406. }
  14407. declare module BABYLON {
  14408. class ShaderMaterial extends Material {
  14409. private _shaderPath;
  14410. private _options;
  14411. private _textures;
  14412. private _textureArrays;
  14413. private _floats;
  14414. private _ints;
  14415. private _floatsArrays;
  14416. private _colors3;
  14417. private _colors3Arrays;
  14418. private _colors4;
  14419. private _vectors2;
  14420. private _vectors3;
  14421. private _vectors4;
  14422. private _matrices;
  14423. private _matrices3x3;
  14424. private _matrices2x2;
  14425. private _vectors2Arrays;
  14426. private _vectors3Arrays;
  14427. private _cachedWorldViewMatrix;
  14428. private _renderId;
  14429. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14430. getClassName(): string;
  14431. needAlphaBlending(): boolean;
  14432. needAlphaTesting(): boolean;
  14433. private _checkUniform(uniformName);
  14434. setTexture(name: string, texture: Texture): ShaderMaterial;
  14435. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14436. setFloat(name: string, value: number): ShaderMaterial;
  14437. setInt(name: string, value: number): ShaderMaterial;
  14438. setFloats(name: string, value: number[]): ShaderMaterial;
  14439. setColor3(name: string, value: Color3): ShaderMaterial;
  14440. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14441. setColor4(name: string, value: Color4): ShaderMaterial;
  14442. setVector2(name: string, value: Vector2): ShaderMaterial;
  14443. setVector3(name: string, value: Vector3): ShaderMaterial;
  14444. setVector4(name: string, value: Vector4): ShaderMaterial;
  14445. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14446. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14447. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14448. setArray2(name: string, value: number[]): ShaderMaterial;
  14449. setArray3(name: string, value: number[]): ShaderMaterial;
  14450. private _checkCache(scene, mesh?, useInstances?);
  14451. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14452. bindOnlyWorldMatrix(world: Matrix): void;
  14453. bind(world: Matrix, mesh?: Mesh): void;
  14454. getActiveTextures(): BaseTexture[];
  14455. hasTexture(texture: BaseTexture): boolean;
  14456. clone(name: string): ShaderMaterial;
  14457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14458. serialize(): any;
  14459. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14460. }
  14461. }
  14462. declare module BABYLON {
  14463. /** @hidden */
  14464. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14465. MAINUV1: boolean;
  14466. MAINUV2: boolean;
  14467. DIFFUSE: boolean;
  14468. DIFFUSEDIRECTUV: number;
  14469. AMBIENT: boolean;
  14470. AMBIENTDIRECTUV: number;
  14471. OPACITY: boolean;
  14472. OPACITYDIRECTUV: number;
  14473. OPACITYRGB: boolean;
  14474. REFLECTION: boolean;
  14475. EMISSIVE: boolean;
  14476. EMISSIVEDIRECTUV: number;
  14477. SPECULAR: boolean;
  14478. SPECULARDIRECTUV: number;
  14479. BUMP: boolean;
  14480. BUMPDIRECTUV: number;
  14481. PARALLAX: boolean;
  14482. PARALLAXOCCLUSION: boolean;
  14483. SPECULAROVERALPHA: boolean;
  14484. CLIPPLANE: boolean;
  14485. ALPHATEST: boolean;
  14486. DEPTHPREPASS: boolean;
  14487. ALPHAFROMDIFFUSE: boolean;
  14488. POINTSIZE: boolean;
  14489. FOG: boolean;
  14490. SPECULARTERM: boolean;
  14491. DIFFUSEFRESNEL: boolean;
  14492. OPACITYFRESNEL: boolean;
  14493. REFLECTIONFRESNEL: boolean;
  14494. REFRACTIONFRESNEL: boolean;
  14495. EMISSIVEFRESNEL: boolean;
  14496. FRESNEL: boolean;
  14497. NORMAL: boolean;
  14498. UV1: boolean;
  14499. UV2: boolean;
  14500. VERTEXCOLOR: boolean;
  14501. VERTEXALPHA: boolean;
  14502. NUM_BONE_INFLUENCERS: number;
  14503. BonesPerMesh: number;
  14504. INSTANCES: boolean;
  14505. GLOSSINESS: boolean;
  14506. ROUGHNESS: boolean;
  14507. EMISSIVEASILLUMINATION: boolean;
  14508. LINKEMISSIVEWITHDIFFUSE: boolean;
  14509. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14510. LIGHTMAP: boolean;
  14511. LIGHTMAPDIRECTUV: number;
  14512. OBJECTSPACE_NORMALMAP: boolean;
  14513. USELIGHTMAPASSHADOWMAP: boolean;
  14514. REFLECTIONMAP_3D: boolean;
  14515. REFLECTIONMAP_SPHERICAL: boolean;
  14516. REFLECTIONMAP_PLANAR: boolean;
  14517. REFLECTIONMAP_CUBIC: boolean;
  14518. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14519. REFLECTIONMAP_PROJECTION: boolean;
  14520. REFLECTIONMAP_SKYBOX: boolean;
  14521. REFLECTIONMAP_EXPLICIT: boolean;
  14522. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14523. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14524. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14525. INVERTCUBICMAP: boolean;
  14526. LOGARITHMICDEPTH: boolean;
  14527. REFRACTION: boolean;
  14528. REFRACTIONMAP_3D: boolean;
  14529. REFLECTIONOVERALPHA: boolean;
  14530. TWOSIDEDLIGHTING: boolean;
  14531. SHADOWFLOAT: boolean;
  14532. MORPHTARGETS: boolean;
  14533. MORPHTARGETS_NORMAL: boolean;
  14534. MORPHTARGETS_TANGENT: boolean;
  14535. NUM_MORPH_INFLUENCERS: number;
  14536. NONUNIFORMSCALING: boolean;
  14537. PREMULTIPLYALPHA: boolean;
  14538. IMAGEPROCESSING: boolean;
  14539. VIGNETTE: boolean;
  14540. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14541. VIGNETTEBLENDMODEOPAQUE: boolean;
  14542. TONEMAPPING: boolean;
  14543. CONTRAST: boolean;
  14544. COLORCURVES: boolean;
  14545. COLORGRADING: boolean;
  14546. COLORGRADING3D: boolean;
  14547. SAMPLER3DGREENDEPTH: boolean;
  14548. SAMPLER3DBGRMAP: boolean;
  14549. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14550. /**
  14551. * If the reflection texture on this material is in linear color space
  14552. * @hidden
  14553. */
  14554. IS_REFLECTION_LINEAR: boolean;
  14555. /**
  14556. * If the refraction texture on this material is in linear color space
  14557. * @hidden
  14558. */
  14559. IS_REFRACTION_LINEAR: boolean;
  14560. EXPOSURE: boolean;
  14561. constructor();
  14562. setReflectionMode(modeToEnable: string): void;
  14563. }
  14564. class StandardMaterial extends PushMaterial {
  14565. private _diffuseTexture;
  14566. diffuseTexture: Nullable<BaseTexture>;
  14567. private _ambientTexture;
  14568. ambientTexture: Nullable<BaseTexture>;
  14569. private _opacityTexture;
  14570. opacityTexture: Nullable<BaseTexture>;
  14571. private _reflectionTexture;
  14572. reflectionTexture: Nullable<BaseTexture>;
  14573. private _emissiveTexture;
  14574. emissiveTexture: Nullable<BaseTexture>;
  14575. private _specularTexture;
  14576. specularTexture: Nullable<BaseTexture>;
  14577. private _bumpTexture;
  14578. bumpTexture: Nullable<BaseTexture>;
  14579. private _lightmapTexture;
  14580. lightmapTexture: Nullable<BaseTexture>;
  14581. private _refractionTexture;
  14582. refractionTexture: Nullable<BaseTexture>;
  14583. ambientColor: Color3;
  14584. diffuseColor: Color3;
  14585. specularColor: Color3;
  14586. emissiveColor: Color3;
  14587. specularPower: number;
  14588. private _useAlphaFromDiffuseTexture;
  14589. useAlphaFromDiffuseTexture: boolean;
  14590. private _useEmissiveAsIllumination;
  14591. useEmissiveAsIllumination: boolean;
  14592. private _linkEmissiveWithDiffuse;
  14593. linkEmissiveWithDiffuse: boolean;
  14594. private _useSpecularOverAlpha;
  14595. useSpecularOverAlpha: boolean;
  14596. private _useReflectionOverAlpha;
  14597. useReflectionOverAlpha: boolean;
  14598. private _disableLighting;
  14599. disableLighting: boolean;
  14600. private _useObjectSpaceNormalMap;
  14601. /**
  14602. * Allows using an object space normal map (instead of tangent space).
  14603. */
  14604. useObjectSpaceNormalMap: boolean;
  14605. private _useParallax;
  14606. useParallax: boolean;
  14607. private _useParallaxOcclusion;
  14608. useParallaxOcclusion: boolean;
  14609. parallaxScaleBias: number;
  14610. private _roughness;
  14611. roughness: number;
  14612. indexOfRefraction: number;
  14613. invertRefractionY: boolean;
  14614. /**
  14615. * Defines the alpha limits in alpha test mode
  14616. */
  14617. alphaCutOff: number;
  14618. private _useLightmapAsShadowmap;
  14619. useLightmapAsShadowmap: boolean;
  14620. private _diffuseFresnelParameters;
  14621. diffuseFresnelParameters: FresnelParameters;
  14622. private _opacityFresnelParameters;
  14623. opacityFresnelParameters: FresnelParameters;
  14624. private _reflectionFresnelParameters;
  14625. reflectionFresnelParameters: FresnelParameters;
  14626. private _refractionFresnelParameters;
  14627. refractionFresnelParameters: FresnelParameters;
  14628. private _emissiveFresnelParameters;
  14629. emissiveFresnelParameters: FresnelParameters;
  14630. private _useReflectionFresnelFromSpecular;
  14631. useReflectionFresnelFromSpecular: boolean;
  14632. private _useGlossinessFromSpecularMapAlpha;
  14633. useGlossinessFromSpecularMapAlpha: boolean;
  14634. private _maxSimultaneousLights;
  14635. maxSimultaneousLights: number;
  14636. /**
  14637. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14638. */
  14639. private _invertNormalMapX;
  14640. invertNormalMapX: boolean;
  14641. /**
  14642. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14643. */
  14644. private _invertNormalMapY;
  14645. invertNormalMapY: boolean;
  14646. /**
  14647. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14648. */
  14649. private _twoSidedLighting;
  14650. twoSidedLighting: boolean;
  14651. /**
  14652. * Default configuration related to image processing available in the standard Material.
  14653. */
  14654. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14655. /**
  14656. * Gets the image processing configuration used either in this material.
  14657. */
  14658. /**
  14659. * Sets the Default image processing configuration used either in the this material.
  14660. *
  14661. * If sets to null, the scene one is in use.
  14662. */
  14663. imageProcessingConfiguration: ImageProcessingConfiguration;
  14664. /**
  14665. * Keep track of the image processing observer to allow dispose and replace.
  14666. */
  14667. private _imageProcessingObserver;
  14668. /**
  14669. * Attaches a new image processing configuration to the Standard Material.
  14670. * @param configuration
  14671. */
  14672. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14673. /**
  14674. * Gets wether the color curves effect is enabled.
  14675. */
  14676. /**
  14677. * Sets wether the color curves effect is enabled.
  14678. */
  14679. cameraColorCurvesEnabled: boolean;
  14680. /**
  14681. * Gets wether the color grading effect is enabled.
  14682. */
  14683. /**
  14684. * Gets wether the color grading effect is enabled.
  14685. */
  14686. cameraColorGradingEnabled: boolean;
  14687. /**
  14688. * Gets wether tonemapping is enabled or not.
  14689. */
  14690. /**
  14691. * Sets wether tonemapping is enabled or not
  14692. */
  14693. cameraToneMappingEnabled: boolean;
  14694. /**
  14695. * The camera exposure used on this material.
  14696. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14697. * This corresponds to a photographic exposure.
  14698. */
  14699. /**
  14700. * The camera exposure used on this material.
  14701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14702. * This corresponds to a photographic exposure.
  14703. */
  14704. cameraExposure: number;
  14705. /**
  14706. * Gets The camera contrast used on this material.
  14707. */
  14708. /**
  14709. * Sets The camera contrast used on this material.
  14710. */
  14711. cameraContrast: number;
  14712. /**
  14713. * Gets the Color Grading 2D Lookup Texture.
  14714. */
  14715. /**
  14716. * Sets the Color Grading 2D Lookup Texture.
  14717. */
  14718. cameraColorGradingTexture: Nullable<BaseTexture>;
  14719. /**
  14720. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14721. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14722. * 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;
  14723. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14724. */
  14725. /**
  14726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14728. * 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;
  14729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14730. */
  14731. cameraColorCurves: Nullable<ColorCurves>;
  14732. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14733. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14734. protected _worldViewProjectionMatrix: Matrix;
  14735. protected _globalAmbientColor: Color3;
  14736. protected _useLogarithmicDepth: boolean;
  14737. constructor(name: string, scene: Scene);
  14738. getClassName(): string;
  14739. useLogarithmicDepth: boolean;
  14740. needAlphaBlending(): boolean;
  14741. needAlphaTesting(): boolean;
  14742. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14743. getAlphaTestTexture(): Nullable<BaseTexture>;
  14744. /**
  14745. * Child classes can use it to update shaders
  14746. */
  14747. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14748. buildUniformLayout(): void;
  14749. unbind(): void;
  14750. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14751. getAnimatables(): IAnimatable[];
  14752. getActiveTextures(): BaseTexture[];
  14753. hasTexture(texture: BaseTexture): boolean;
  14754. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14755. clone(name: string): StandardMaterial;
  14756. serialize(): any;
  14757. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14758. static _DiffuseTextureEnabled: boolean;
  14759. static DiffuseTextureEnabled: boolean;
  14760. static _AmbientTextureEnabled: boolean;
  14761. static AmbientTextureEnabled: boolean;
  14762. static _OpacityTextureEnabled: boolean;
  14763. static OpacityTextureEnabled: boolean;
  14764. static _ReflectionTextureEnabled: boolean;
  14765. static ReflectionTextureEnabled: boolean;
  14766. static _EmissiveTextureEnabled: boolean;
  14767. static EmissiveTextureEnabled: boolean;
  14768. static _SpecularTextureEnabled: boolean;
  14769. static SpecularTextureEnabled: boolean;
  14770. static _BumpTextureEnabled: boolean;
  14771. static BumpTextureEnabled: boolean;
  14772. static _LightmapTextureEnabled: boolean;
  14773. static LightmapTextureEnabled: boolean;
  14774. static _RefractionTextureEnabled: boolean;
  14775. static RefractionTextureEnabled: boolean;
  14776. static _ColorGradingTextureEnabled: boolean;
  14777. static ColorGradingTextureEnabled: boolean;
  14778. static _FresnelEnabled: boolean;
  14779. static FresnelEnabled: boolean;
  14780. }
  14781. }
  14782. declare module BABYLON {
  14783. class UniformBuffer {
  14784. private _engine;
  14785. private _buffer;
  14786. private _data;
  14787. private _bufferData;
  14788. private _dynamic?;
  14789. private _uniformLocations;
  14790. private _uniformSizes;
  14791. private _uniformLocationPointer;
  14792. private _needSync;
  14793. private _noUBO;
  14794. private _currentEffect;
  14795. private static _MAX_UNIFORM_SIZE;
  14796. private static _tempBuffer;
  14797. /**
  14798. * Wrapper for updateUniform.
  14799. * @method updateMatrix3x3
  14800. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14801. * @param {Float32Array} matrix
  14802. */
  14803. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14804. /**
  14805. * Wrapper for updateUniform.
  14806. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14807. * @param {Float32Array} matrix
  14808. */
  14809. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14810. /**
  14811. * Wrapper for updateUniform.
  14812. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14813. * @param {number} x
  14814. */
  14815. updateFloat: (name: string, x: number) => void;
  14816. /**
  14817. * Wrapper for updateUniform.
  14818. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14819. * @param {number} x
  14820. * @param {number} y
  14821. * @param {string} [suffix] Suffix to add to the uniform name.
  14822. */
  14823. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14824. /**
  14825. * Wrapper for updateUniform.
  14826. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14827. * @param {number} x
  14828. * @param {number} y
  14829. * @param {number} z
  14830. * @param {string} [suffix] Suffix to add to the uniform name.
  14831. */
  14832. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14833. /**
  14834. * Wrapper for updateUniform.
  14835. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14836. * @param {number} x
  14837. * @param {number} y
  14838. * @param {number} z
  14839. * @param {number} w
  14840. * @param {string} [suffix] Suffix to add to the uniform name.
  14841. */
  14842. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14843. /**
  14844. * Wrapper for updateUniform.
  14845. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14846. * @param {Matrix} A 4x4 matrix.
  14847. */
  14848. updateMatrix: (name: string, mat: Matrix) => void;
  14849. /**
  14850. * Wrapper for updateUniform.
  14851. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14852. * @param {Vector3} vector
  14853. */
  14854. updateVector3: (name: string, vector: Vector3) => void;
  14855. /**
  14856. * Wrapper for updateUniform.
  14857. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14858. * @param {Vector4} vector
  14859. */
  14860. updateVector4: (name: string, vector: Vector4) => void;
  14861. /**
  14862. * Wrapper for updateUniform.
  14863. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14864. * @param {Color3} color
  14865. * @param {string} [suffix] Suffix to add to the uniform name.
  14866. */
  14867. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14868. /**
  14869. * Wrapper for updateUniform.
  14870. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14871. * @param {Color3} color
  14872. * @param {number} alpha
  14873. * @param {string} [suffix] Suffix to add to the uniform name.
  14874. */
  14875. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14876. /**
  14877. * Uniform buffer objects.
  14878. *
  14879. * Handles blocks of uniform on the GPU.
  14880. *
  14881. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14882. *
  14883. * For more information, please refer to :
  14884. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14885. */
  14886. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14887. /**
  14888. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14889. * or just falling back on setUniformXXX calls.
  14890. */
  14891. readonly useUbo: boolean;
  14892. /**
  14893. * Indicates if the WebGL underlying uniform buffer is in sync
  14894. * with the javascript cache data.
  14895. */
  14896. readonly isSync: boolean;
  14897. /**
  14898. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14899. * Also, a dynamic UniformBuffer will disable cache verification and always
  14900. * update the underlying WebGL uniform buffer to the GPU.
  14901. */
  14902. isDynamic(): boolean;
  14903. /**
  14904. * The data cache on JS side.
  14905. */
  14906. getData(): Float32Array;
  14907. /**
  14908. * The underlying WebGL Uniform buffer.
  14909. */
  14910. getBuffer(): Nullable<WebGLBuffer>;
  14911. /**
  14912. * std140 layout specifies how to align data within an UBO structure.
  14913. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14914. * for specs.
  14915. */
  14916. private _fillAlignment(size);
  14917. /**
  14918. * Adds an uniform in the buffer.
  14919. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14920. * for the layout to be correct !
  14921. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14922. * @param {number|number[]} size Data size, or data directly.
  14923. */
  14924. addUniform(name: string, size: number | number[]): void;
  14925. /**
  14926. * Wrapper for addUniform.
  14927. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14928. * @param {Matrix} mat A 4x4 matrix.
  14929. */
  14930. addMatrix(name: string, mat: Matrix): void;
  14931. /**
  14932. * Wrapper for addUniform.
  14933. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14934. * @param {number} x
  14935. * @param {number} y
  14936. */
  14937. addFloat2(name: string, x: number, y: number): void;
  14938. /**
  14939. * Wrapper for addUniform.
  14940. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14941. * @param {number} x
  14942. * @param {number} y
  14943. * @param {number} z
  14944. */
  14945. addFloat3(name: string, x: number, y: number, z: number): void;
  14946. /**
  14947. * Wrapper for addUniform.
  14948. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14949. * @param {Color3} color
  14950. */
  14951. addColor3(name: string, color: Color3): void;
  14952. /**
  14953. * Wrapper for addUniform.
  14954. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14955. * @param {Color3} color
  14956. * @param {number} alpha
  14957. */
  14958. addColor4(name: string, color: Color3, alpha: number): void;
  14959. /**
  14960. * Wrapper for addUniform.
  14961. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14962. * @param {Vector3} vector
  14963. */
  14964. addVector3(name: string, vector: Vector3): void;
  14965. /**
  14966. * Wrapper for addUniform.
  14967. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14968. */
  14969. addMatrix3x3(name: string): void;
  14970. /**
  14971. * Wrapper for addUniform.
  14972. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14973. */
  14974. addMatrix2x2(name: string): void;
  14975. /**
  14976. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14977. */
  14978. create(): void;
  14979. _rebuild(): void;
  14980. /**
  14981. * Updates the WebGL Uniform Buffer on the GPU.
  14982. * If the `dynamic` flag is set to true, no cache comparison is done.
  14983. * Otherwise, the buffer will be updated only if the cache differs.
  14984. */
  14985. update(): void;
  14986. /**
  14987. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14988. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14989. * @param {number[]|Float32Array} data Flattened data
  14990. * @param {number} size Size of the data.
  14991. */
  14992. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14993. private _updateMatrix3x3ForUniform(name, matrix);
  14994. private _updateMatrix3x3ForEffect(name, matrix);
  14995. private _updateMatrix2x2ForEffect(name, matrix);
  14996. private _updateMatrix2x2ForUniform(name, matrix);
  14997. private _updateFloatForEffect(name, x);
  14998. private _updateFloatForUniform(name, x);
  14999. private _updateFloat2ForEffect(name, x, y, suffix?);
  15000. private _updateFloat2ForUniform(name, x, y, suffix?);
  15001. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  15002. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  15003. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  15004. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  15005. private _updateMatrixForEffect(name, mat);
  15006. private _updateMatrixForUniform(name, mat);
  15007. private _updateVector3ForEffect(name, vector);
  15008. private _updateVector3ForUniform(name, vector);
  15009. private _updateVector4ForEffect(name, vector);
  15010. private _updateVector4ForUniform(name, vector);
  15011. private _updateColor3ForEffect(name, color, suffix?);
  15012. private _updateColor3ForUniform(name, color, suffix?);
  15013. private _updateColor4ForEffect(name, color, alpha, suffix?);
  15014. private _updateColor4ForUniform(name, color, alpha, suffix?);
  15015. /**
  15016. * Sets a sampler uniform on the effect.
  15017. * @param {string} name Name of the sampler.
  15018. * @param {Texture} texture
  15019. */
  15020. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15021. /**
  15022. * Directly updates the value of the uniform in the cache AND on the GPU.
  15023. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15024. * @param {number[]|Float32Array} data Flattened data
  15025. */
  15026. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15027. /**
  15028. * Binds this uniform buffer to an effect.
  15029. * @param {Effect} effect
  15030. * @param {string} name Name of the uniform block in the shader.
  15031. */
  15032. bindToEffect(effect: Effect, name: string): void;
  15033. /**
  15034. * Disposes the uniform buffer.
  15035. */
  15036. dispose(): void;
  15037. }
  15038. }
  15039. declare module BABYLON {
  15040. class Scalar {
  15041. /**
  15042. * Two pi constants convenient for computation.
  15043. */
  15044. static TwoPi: number;
  15045. /**
  15046. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15047. */
  15048. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15049. /**
  15050. * Returns a string : the upper case translation of the number i to hexadecimal.
  15051. */
  15052. static ToHex(i: number): string;
  15053. /**
  15054. * Returns -1 if value is negative and +1 is value is positive.
  15055. * Returns the value itself if it's equal to zero.
  15056. */
  15057. static Sign(value: number): number;
  15058. /**
  15059. * Returns the value itself if it's between min and max.
  15060. * Returns min if the value is lower than min.
  15061. * Returns max if the value is greater than max.
  15062. */
  15063. static Clamp(value: number, min?: number, max?: number): number;
  15064. /**
  15065. * Returns the log2 of value.
  15066. */
  15067. static Log2(value: number): number;
  15068. /**
  15069. * Loops the value, so that it is never larger than length and never smaller than 0.
  15070. *
  15071. * This is similar to the modulo operator but it works with floating point numbers.
  15072. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15073. * With t = 5 and length = 2.5, the result would be 0.0.
  15074. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15075. */
  15076. static Repeat(value: number, length: number): number;
  15077. /**
  15078. * Normalize the value between 0.0 and 1.0 using min and max values
  15079. */
  15080. static Normalize(value: number, min: number, max: number): number;
  15081. /**
  15082. * Denormalize the value from 0.0 and 1.0 using min and max values
  15083. */
  15084. static Denormalize(normalized: number, min: number, max: number): number;
  15085. /**
  15086. * Calculates the shortest difference between two given angles given in degrees.
  15087. */
  15088. static DeltaAngle(current: number, target: number): number;
  15089. /**
  15090. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15091. *
  15092. * The returned value will move back and forth between 0 and length
  15093. */
  15094. static PingPong(tx: number, length: number): number;
  15095. /**
  15096. * Interpolates between min and max with smoothing at the limits.
  15097. *
  15098. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15099. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15100. */
  15101. static SmoothStep(from: number, to: number, tx: number): number;
  15102. /**
  15103. * Moves a value current towards target.
  15104. *
  15105. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15106. * Negative values of maxDelta pushes the value away from target.
  15107. */
  15108. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15109. /**
  15110. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15111. *
  15112. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15113. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15114. */
  15115. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15116. /**
  15117. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15118. */
  15119. static Lerp(start: number, end: number, amount: number): number;
  15120. /**
  15121. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15122. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15123. */
  15124. static LerpAngle(start: number, end: number, amount: number): number;
  15125. /**
  15126. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15127. */
  15128. static InverseLerp(a: number, b: number, value: number): number;
  15129. /**
  15130. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15131. */
  15132. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15133. /**
  15134. * Returns a random float number between and min and max values
  15135. */
  15136. static RandomRange(min: number, max: number): number;
  15137. /**
  15138. * This function returns percentage of a number in a given range.
  15139. *
  15140. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15141. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15142. */
  15143. static RangeToPercent(number: number, min: number, max: number): number;
  15144. /**
  15145. * This function returns number that corresponds to the percentage in a given range.
  15146. *
  15147. * PercentToRange(0.34,0,100) will return 34.
  15148. */
  15149. static PercentToRange(percent: number, min: number, max: number): number;
  15150. /**
  15151. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15152. * @param angle The angle to normalize in radian.
  15153. * @return The converted angle.
  15154. */
  15155. static NormalizeRadians(angle: number): number;
  15156. }
  15157. }
  15158. declare module BABYLON {
  15159. const ToGammaSpace: number;
  15160. const ToLinearSpace = 2.2;
  15161. const Epsilon = 0.001;
  15162. /**
  15163. * Class used to hold a RBG color
  15164. */
  15165. class Color3 {
  15166. /**
  15167. * Defines the red component (between 0 and 1, default is 0)
  15168. */
  15169. r: number;
  15170. /**
  15171. * Defines the green component (between 0 and 1, default is 0)
  15172. */
  15173. g: number;
  15174. /**
  15175. * Defines the blue component (between 0 and 1, default is 0)
  15176. */
  15177. b: number;
  15178. /**
  15179. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15180. * @param r defines the red component (between 0 and 1, default is 0)
  15181. * @param g defines the green component (between 0 and 1, default is 0)
  15182. * @param b defines the blue component (between 0 and 1, default is 0)
  15183. */
  15184. constructor(
  15185. /**
  15186. * Defines the red component (between 0 and 1, default is 0)
  15187. */
  15188. r?: number,
  15189. /**
  15190. * Defines the green component (between 0 and 1, default is 0)
  15191. */
  15192. g?: number,
  15193. /**
  15194. * Defines the blue component (between 0 and 1, default is 0)
  15195. */
  15196. b?: number);
  15197. /**
  15198. * Creates a string with the Color3 current values
  15199. * @returns the string representation of the Color3 object
  15200. */
  15201. toString(): string;
  15202. /**
  15203. * Returns the string "Color3"
  15204. * @returns "Color3"
  15205. */
  15206. getClassName(): string;
  15207. /**
  15208. * Compute the Color3 hash code
  15209. * @returns an unique number that can be used to hash Color3 objects
  15210. */
  15211. getHashCode(): number;
  15212. /**
  15213. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15214. * @param array defines the array where to store the r,g,b components
  15215. * @param index defines an optional index in the target array to define where to start storing values
  15216. * @returns the current Color3 object
  15217. */
  15218. toArray(array: FloatArray, index?: number): Color3;
  15219. /**
  15220. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15221. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15222. * @returns a new {BABYLON.Color4} object
  15223. */
  15224. toColor4(alpha?: number): Color4;
  15225. /**
  15226. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15227. * @returns the new array
  15228. */
  15229. asArray(): number[];
  15230. /**
  15231. * Returns the luminance value
  15232. * @returns a float value
  15233. */
  15234. toLuminance(): number;
  15235. /**
  15236. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15237. * @param otherColor defines the second operand
  15238. * @returns the new Color3 object
  15239. */
  15240. multiply(otherColor: Color3): Color3;
  15241. /**
  15242. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15243. * @param otherColor defines the second operand
  15244. * @param result defines the Color3 object where to store the result
  15245. * @returns the current Color3
  15246. */
  15247. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15248. /**
  15249. * Determines equality between Color3 objects
  15250. * @param otherColor defines the second operand
  15251. * @returns true if the rgb values are equal to the given ones
  15252. */
  15253. equals(otherColor: Color3): boolean;
  15254. /**
  15255. * Determines equality between the current Color3 object and a set of r,b,g values
  15256. * @param r defines the red component to check
  15257. * @param g defines the green component to check
  15258. * @param b defines the blue component to check
  15259. * @returns true if the rgb values are equal to the given ones
  15260. */
  15261. equalsFloats(r: number, g: number, b: number): boolean;
  15262. /**
  15263. * Multiplies in place each rgb value by scale
  15264. * @param scale defines the scaling factor
  15265. * @returns the updated Color3
  15266. */
  15267. scale(scale: number): Color3;
  15268. /**
  15269. * Multiplies the rgb values by scale and stores the result into "result"
  15270. * @param scale defines the scaling factor
  15271. * @param result defines the Color3 object where to store the result
  15272. * @returns the unmodified current Color3
  15273. */
  15274. scaleToRef(scale: number, result: Color3): Color3;
  15275. /**
  15276. * Scale the current Color3 values by a factor and add the result to a given Color3
  15277. * @param scale defines the scale factor
  15278. * @param result defines color to store the result into
  15279. * @returns the unmodified current Color3
  15280. */
  15281. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15282. /**
  15283. * Clamps the rgb values by the min and max values and stores the result into "result"
  15284. * @param min defines minimum clamping value (default is 0)
  15285. * @param max defines maximum clamping value (default is 1)
  15286. * @param result defines color to store the result into
  15287. * @returns the original Color3
  15288. */
  15289. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15290. /**
  15291. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15292. * @param otherColor defines the second operand
  15293. * @returns the new Color3
  15294. */
  15295. add(otherColor: Color3): Color3;
  15296. /**
  15297. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15298. * @param otherColor defines the second operand
  15299. * @param result defines Color3 object to store the result into
  15300. * @returns the unmodified current Color3
  15301. */
  15302. addToRef(otherColor: Color3, result: Color3): Color3;
  15303. /**
  15304. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15305. * @param otherColor defines the second operand
  15306. * @returns the new Color3
  15307. */
  15308. subtract(otherColor: Color3): Color3;
  15309. /**
  15310. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15311. * @param otherColor defines the second operand
  15312. * @param result defines Color3 object to store the result into
  15313. * @returns the unmodified current Color3
  15314. */
  15315. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15316. /**
  15317. * Copy the current object
  15318. * @returns a new Color3 copied the current one
  15319. */
  15320. clone(): Color3;
  15321. /**
  15322. * Copies the rgb values from the source in the current Color3
  15323. * @param source defines the source Color3 object
  15324. * @returns the updated Color3 object
  15325. */
  15326. copyFrom(source: Color3): Color3;
  15327. /**
  15328. * Updates the Color3 rgb values from the given floats
  15329. * @param r defines the red component to read from
  15330. * @param g defines the green component to read from
  15331. * @param b defines the blue component to read from
  15332. * @returns the current Color3 object
  15333. */
  15334. copyFromFloats(r: number, g: number, b: number): Color3;
  15335. /**
  15336. * Updates the Color3 rgb values from the given floats
  15337. * @param r defines the red component to read from
  15338. * @param g defines the green component to read from
  15339. * @param b defines the blue component to read from
  15340. * @returns the current Color3 object
  15341. */
  15342. set(r: number, g: number, b: number): Color3;
  15343. /**
  15344. * Compute the Color3 hexadecimal code as a string
  15345. * @returns a string containing the hexadecimal representation of the Color3 object
  15346. */
  15347. toHexString(): string;
  15348. /**
  15349. * Computes a new Color3 converted from the current one to linear space
  15350. * @returns a new Color3 object
  15351. */
  15352. toLinearSpace(): Color3;
  15353. /**
  15354. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15355. * @param convertedColor defines the Color3 object where to store the linear space version
  15356. * @returns the unmodified Color3
  15357. */
  15358. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15359. /**
  15360. * Computes a new Color3 converted from the current one to gamma space
  15361. * @returns a new Color3 object
  15362. */
  15363. toGammaSpace(): Color3;
  15364. /**
  15365. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15366. * @param convertedColor defines the Color3 object where to store the gamma space version
  15367. * @returns the unmodified Color3
  15368. */
  15369. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15370. /**
  15371. * Creates a new Color3 from the string containing valid hexadecimal values
  15372. * @param hex defines a string containing valid hexadecimal values
  15373. * @returns a new Color3 object
  15374. */
  15375. static FromHexString(hex: string): Color3;
  15376. /**
  15377. * Creates a new Vector3 from the starting index of the given array
  15378. * @param array defines the source array
  15379. * @param offset defines an offset in the source array
  15380. * @returns a new Color3 object
  15381. */
  15382. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15383. /**
  15384. * Creates a new Color3 from integer values (< 256)
  15385. * @param r defines the red component to read from (value between 0 and 255)
  15386. * @param g defines the green component to read from (value between 0 and 255)
  15387. * @param b defines the blue component to read from (value between 0 and 255)
  15388. * @returns a new Color3 object
  15389. */
  15390. static FromInts(r: number, g: number, b: number): Color3;
  15391. /**
  15392. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15393. * @param start defines the start Color3 value
  15394. * @param end defines the end Color3 value
  15395. * @param amount defines the gradient value between start and end
  15396. * @returns a new Color3 object
  15397. */
  15398. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15399. /**
  15400. * Returns a Color3 value containing a red color
  15401. * @returns a new Color3 object
  15402. */
  15403. static Red(): Color3;
  15404. /**
  15405. * Returns a Color3 value containing a green color
  15406. * @returns a new Color3 object
  15407. */
  15408. static Green(): Color3;
  15409. /**
  15410. * Returns a Color3 value containing a blue color
  15411. * @returns a new Color3 object
  15412. */
  15413. static Blue(): Color3;
  15414. /**
  15415. * Returns a Color3 value containing a black color
  15416. * @returns a new Color3 object
  15417. */
  15418. static Black(): Color3;
  15419. /**
  15420. * Returns a Color3 value containing a white color
  15421. * @returns a new Color3 object
  15422. */
  15423. static White(): Color3;
  15424. /**
  15425. * Returns a Color3 value containing a purple color
  15426. * @returns a new Color3 object
  15427. */
  15428. static Purple(): Color3;
  15429. /**
  15430. * Returns a Color3 value containing a magenta color
  15431. * @returns a new Color3 object
  15432. */
  15433. static Magenta(): Color3;
  15434. /**
  15435. * Returns a Color3 value containing a yellow color
  15436. * @returns a new Color3 object
  15437. */
  15438. static Yellow(): Color3;
  15439. /**
  15440. * Returns a Color3 value containing a gray color
  15441. * @returns a new Color3 object
  15442. */
  15443. static Gray(): Color3;
  15444. /**
  15445. * Returns a Color3 value containing a teal color
  15446. * @returns a new Color3 object
  15447. */
  15448. static Teal(): Color3;
  15449. /**
  15450. * Returns a Color3 value containing a random color
  15451. * @returns a new Color3 object
  15452. */
  15453. static Random(): Color3;
  15454. }
  15455. /**
  15456. * Class used to hold a RBGA color
  15457. */
  15458. class Color4 {
  15459. /**
  15460. * Defines the red component (between 0 and 1, default is 0)
  15461. */
  15462. r: number;
  15463. /**
  15464. * Defines the green component (between 0 and 1, default is 0)
  15465. */
  15466. g: number;
  15467. /**
  15468. * Defines the blue component (between 0 and 1, default is 0)
  15469. */
  15470. b: number;
  15471. /**
  15472. * Defines the alpha component (between 0 and 1, default is 1)
  15473. */
  15474. a: number;
  15475. /**
  15476. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15477. * @param r defines the red component (between 0 and 1, default is 0)
  15478. * @param g defines the green component (between 0 and 1, default is 0)
  15479. * @param b defines the blue component (between 0 and 1, default is 0)
  15480. * @param a defines the alpha component (between 0 and 1, default is 1)
  15481. */
  15482. constructor(
  15483. /**
  15484. * Defines the red component (between 0 and 1, default is 0)
  15485. */
  15486. r?: number,
  15487. /**
  15488. * Defines the green component (between 0 and 1, default is 0)
  15489. */
  15490. g?: number,
  15491. /**
  15492. * Defines the blue component (between 0 and 1, default is 0)
  15493. */
  15494. b?: number,
  15495. /**
  15496. * Defines the alpha component (between 0 and 1, default is 1)
  15497. */
  15498. a?: number);
  15499. /**
  15500. * Adds in place the given Color4 values to the current Color4 object
  15501. * @param right defines the second operand
  15502. * @returns the current updated Color4 object
  15503. */
  15504. addInPlace(right: Color4): Color4;
  15505. /**
  15506. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15507. * @returns the new array
  15508. */
  15509. asArray(): number[];
  15510. /**
  15511. * Stores from the starting index in the given array the Color4 successive values
  15512. * @param array defines the array where to store the r,g,b components
  15513. * @param index defines an optional index in the target array to define where to start storing values
  15514. * @returns the current Color4 object
  15515. */
  15516. toArray(array: number[], index?: number): Color4;
  15517. /**
  15518. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15519. * @param right defines the second operand
  15520. * @returns a new Color4 object
  15521. */
  15522. add(right: Color4): Color4;
  15523. /**
  15524. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15525. * @param right defines the second operand
  15526. * @returns a new Color4 object
  15527. */
  15528. subtract(right: Color4): Color4;
  15529. /**
  15530. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15531. * @param right defines the second operand
  15532. * @param result defines the Color4 object where to store the result
  15533. * @returns the current Color4 object
  15534. */
  15535. subtractToRef(right: Color4, result: Color4): Color4;
  15536. /**
  15537. * Creates a new Color4 with the current Color4 values multiplied by scale
  15538. * @param scale defines the scaling factor to apply
  15539. * @returns a new Color4 object
  15540. */
  15541. scale(scale: number): Color4;
  15542. /**
  15543. * Multiplies the current Color4 values by scale and stores the result in "result"
  15544. * @param scale defines the scaling factor to apply
  15545. * @param result defines the Color4 object where to store the result
  15546. * @returns the current unmodified Color4
  15547. */
  15548. scaleToRef(scale: number, result: Color4): Color4;
  15549. /**
  15550. * Scale the current Color4 values by a factor and add the result to a given Color4
  15551. * @param scale defines the scale factor
  15552. * @param result defines the Color4 object where to store the result
  15553. * @returns the unmodified current Color4
  15554. */
  15555. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15556. /**
  15557. * Clamps the rgb values by the min and max values and stores the result into "result"
  15558. * @param min defines minimum clamping value (default is 0)
  15559. * @param max defines maximum clamping value (default is 1)
  15560. * @param result defines color to store the result into.
  15561. * @returns the cuurent Color4
  15562. */
  15563. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15564. /**
  15565. * Multipy an Color4 value by another and return a new Color4 object
  15566. * @param color defines the Color4 value to multiply by
  15567. * @returns a new Color4 object
  15568. */
  15569. multiply(color: Color4): Color4;
  15570. /**
  15571. * Multipy a Color4 value by another and push the result in a reference value
  15572. * @param color defines the Color4 value to multiply by
  15573. * @param result defines the Color4 to fill the result in
  15574. * @returns the result Color4
  15575. */
  15576. multiplyToRef(color: Color4, result: Color4): Color4;
  15577. /**
  15578. * Creates a string with the Color4 current values
  15579. * @returns the string representation of the Color4 object
  15580. */
  15581. toString(): string;
  15582. /**
  15583. * Returns the string "Color4"
  15584. * @returns "Color4"
  15585. */
  15586. getClassName(): string;
  15587. /**
  15588. * Compute the Color4 hash code
  15589. * @returns an unique number that can be used to hash Color4 objects
  15590. */
  15591. getHashCode(): number;
  15592. /**
  15593. * Creates a new Color4 copied from the current one
  15594. * @returns a new Color4 object
  15595. */
  15596. clone(): Color4;
  15597. /**
  15598. * Copies the given Color4 values into the current one
  15599. * @param source defines the source Color4 object
  15600. * @returns the current updated Color4 object
  15601. */
  15602. copyFrom(source: Color4): Color4;
  15603. /**
  15604. * Copies the given float values into the current one
  15605. * @param r defines the red component to read from
  15606. * @param g defines the green component to read from
  15607. * @param b defines the blue component to read from
  15608. * @param a defines the alpha component to read from
  15609. * @returns the current updated Color4 object
  15610. */
  15611. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15612. /**
  15613. * Copies the given float values into the current one
  15614. * @param r defines the red component to read from
  15615. * @param g defines the green component to read from
  15616. * @param b defines the blue component to read from
  15617. * @param a defines the alpha component to read from
  15618. * @returns the current updated Color4 object
  15619. */
  15620. set(r: number, g: number, b: number, a: number): Color4;
  15621. /**
  15622. * Compute the Color4 hexadecimal code as a string
  15623. * @returns a string containing the hexadecimal representation of the Color4 object
  15624. */
  15625. toHexString(): string;
  15626. /**
  15627. * Computes a new Color4 converted from the current one to linear space
  15628. * @returns a new Color4 object
  15629. */
  15630. toLinearSpace(): Color4;
  15631. /**
  15632. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15633. * @param convertedColor defines the Color4 object where to store the linear space version
  15634. * @returns the unmodified Color4
  15635. */
  15636. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15637. /**
  15638. * Computes a new Color4 converted from the current one to gamma space
  15639. * @returns a new Color4 object
  15640. */
  15641. toGammaSpace(): Color4;
  15642. /**
  15643. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15644. * @param convertedColor defines the Color4 object where to store the gamma space version
  15645. * @returns the unmodified Color4
  15646. */
  15647. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15648. /**
  15649. * Creates a new Color4 from the string containing valid hexadecimal values
  15650. * @param hex defines a string containing valid hexadecimal values
  15651. * @returns a new Color4 object
  15652. */
  15653. static FromHexString(hex: string): Color4;
  15654. /**
  15655. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15656. * @param left defines the start value
  15657. * @param right defines the end value
  15658. * @param amount defines the gradient factor
  15659. * @returns a new Color4 object
  15660. */
  15661. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15662. /**
  15663. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15664. * @param left defines the start value
  15665. * @param right defines the end value
  15666. * @param amount defines the gradient factor
  15667. * @param result defines the Color4 object where to store data
  15668. */
  15669. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15670. /**
  15671. * Creates a new Color4 from the starting index element of the given array
  15672. * @param array defines the source array to read from
  15673. * @param offset defines the offset in the source array
  15674. * @returns a new Color4 object
  15675. */
  15676. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15677. /**
  15678. * Creates a new Color3 from integer values (< 256)
  15679. * @param r defines the red component to read from (value between 0 and 255)
  15680. * @param g defines the green component to read from (value between 0 and 255)
  15681. * @param b defines the blue component to read from (value between 0 and 255)
  15682. * @param a defines the alpha component to read from (value between 0 and 255)
  15683. * @returns a new Color3 object
  15684. */
  15685. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15686. /**
  15687. * Check the content of a given array and convert it to an array containing RGBA data
  15688. * If the original array was already containing count * 4 values then it is returned directly
  15689. * @param colors defines the array to check
  15690. * @param count defines the number of RGBA data to expect
  15691. * @returns an array containing count * 4 values (RGBA)
  15692. */
  15693. static CheckColors4(colors: number[], count: number): number[];
  15694. }
  15695. /**
  15696. * Class representing a vector containing 2 coordinates
  15697. */
  15698. class Vector2 {
  15699. /** defines the first coordinate */
  15700. x: number;
  15701. /** defines the second coordinate */
  15702. y: number;
  15703. /**
  15704. * Creates a new Vector2 from the given x and y coordinates
  15705. * @param x defines the first coordinate
  15706. * @param y defines the second coordinate
  15707. */
  15708. constructor(
  15709. /** defines the first coordinate */
  15710. x?: number,
  15711. /** defines the second coordinate */
  15712. y?: number);
  15713. /**
  15714. * Gets a string with the Vector2 coordinates
  15715. * @returns a string with the Vector2 coordinates
  15716. */
  15717. toString(): string;
  15718. /**
  15719. * Gets class name
  15720. * @returns the string "Vector2"
  15721. */
  15722. getClassName(): string;
  15723. /**
  15724. * Gets current vector hash code
  15725. * @returns the Vector2 hash code as a number
  15726. */
  15727. getHashCode(): number;
  15728. /**
  15729. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15730. * @param array defines the source array
  15731. * @param index defines the offset in source array
  15732. * @returns the current Vector2
  15733. */
  15734. toArray(array: FloatArray, index?: number): Vector2;
  15735. /**
  15736. * Copy the current vector to an array
  15737. * @returns a new array with 2 elements: the Vector2 coordinates.
  15738. */
  15739. asArray(): number[];
  15740. /**
  15741. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15742. * @param source defines the source Vector2
  15743. * @returns the current updated Vector2
  15744. */
  15745. copyFrom(source: Vector2): Vector2;
  15746. /**
  15747. * Sets the Vector2 coordinates with the given floats
  15748. * @param x defines the first coordinate
  15749. * @param y defines the second coordinate
  15750. * @returns the current updated Vector2
  15751. */
  15752. copyFromFloats(x: number, y: number): Vector2;
  15753. /**
  15754. * Sets the Vector2 coordinates with the given floats
  15755. * @param x defines the first coordinate
  15756. * @param y defines the second coordinate
  15757. * @returns the current updated Vector2
  15758. */
  15759. set(x: number, y: number): Vector2;
  15760. /**
  15761. * Add another vector with the current one
  15762. * @param otherVector defines the other vector
  15763. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15764. */
  15765. add(otherVector: Vector2): Vector2;
  15766. /**
  15767. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15768. * @param otherVector defines the other vector
  15769. * @param result defines the target vector
  15770. * @returns the unmodified current Vector2
  15771. */
  15772. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15773. /**
  15774. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15775. * @param otherVector defines the other vector
  15776. * @returns the current updated Vector2
  15777. */
  15778. addInPlace(otherVector: Vector2): Vector2;
  15779. /**
  15780. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15781. * @param otherVector defines the other vector
  15782. * @returns a new Vector2
  15783. */
  15784. addVector3(otherVector: Vector3): Vector2;
  15785. /**
  15786. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15787. * @param otherVector defines the other vector
  15788. * @returns a new Vector2
  15789. */
  15790. subtract(otherVector: Vector2): Vector2;
  15791. /**
  15792. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15793. * @param otherVector defines the other vector
  15794. * @param result defines the target vector
  15795. * @returns the unmodified current Vector2
  15796. */
  15797. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15798. /**
  15799. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15800. * @param otherVector defines the other vector
  15801. * @returns the current updated Vector2
  15802. */
  15803. subtractInPlace(otherVector: Vector2): Vector2;
  15804. /**
  15805. * Multiplies in place the current Vector2 coordinates by the given ones
  15806. * @param otherVector defines the other vector
  15807. * @returns the current updated Vector2
  15808. */
  15809. multiplyInPlace(otherVector: Vector2): Vector2;
  15810. /**
  15811. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15812. * @param otherVector defines the other vector
  15813. * @returns a new Vector2
  15814. */
  15815. multiply(otherVector: Vector2): Vector2;
  15816. /**
  15817. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15818. * @param otherVector defines the other vector
  15819. * @param result defines the target vector
  15820. * @returns the unmodified current Vector2
  15821. */
  15822. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15823. /**
  15824. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15825. * @param x defines the first coordinate
  15826. * @param y defines the second coordinate
  15827. * @returns a new Vector2
  15828. */
  15829. multiplyByFloats(x: number, y: number): Vector2;
  15830. /**
  15831. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15832. * @param otherVector defines the other vector
  15833. * @returns a new Vector2
  15834. */
  15835. divide(otherVector: Vector2): Vector2;
  15836. /**
  15837. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15838. * @param otherVector defines the other vector
  15839. * @param result defines the target vector
  15840. * @returns the unmodified current Vector2
  15841. */
  15842. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15843. /**
  15844. * Divides the current Vector3 coordinates by the given ones
  15845. * @param otherVector defines the other vector
  15846. * @returns the current updated Vector2
  15847. */
  15848. divideInPlace(otherVector: Vector2): Vector2;
  15849. /**
  15850. * Gets a new Vector2 with current Vector2 negated coordinates
  15851. * @returns a new Vector2
  15852. */
  15853. negate(): Vector2;
  15854. /**
  15855. * Multiply the Vector2 coordinates by scale
  15856. * @param scale defines the scaling factor
  15857. * @returns the current updated Vector2
  15858. */
  15859. scaleInPlace(scale: number): Vector2;
  15860. /**
  15861. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15862. * @param scale defines the scaling factor
  15863. * @returns a new Vector2
  15864. */
  15865. scale(scale: number): Vector2;
  15866. /**
  15867. * Scale the current Vector2 values by a factor to a given Vector2
  15868. * @param scale defines the scale factor
  15869. * @param result defines the Vector2 object where to store the result
  15870. * @returns the unmodified current Vector2
  15871. */
  15872. scaleToRef(scale: number, result: Vector2): Vector2;
  15873. /**
  15874. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15875. * @param scale defines the scale factor
  15876. * @param result defines the Vector2 object where to store the result
  15877. * @returns the unmodified current Vector2
  15878. */
  15879. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15880. /**
  15881. * Gets a boolean if two vectors are equals
  15882. * @param otherVector defines the other vector
  15883. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15884. */
  15885. equals(otherVector: Vector2): boolean;
  15886. /**
  15887. * Gets a boolean if two vectors are equals (using an epsilon value)
  15888. * @param otherVector defines the other vector
  15889. * @param epsilon defines the minimal distance to consider equality
  15890. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15891. */
  15892. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15893. /**
  15894. * Gets the length of the vector
  15895. * @returns the vector length (float)
  15896. */
  15897. length(): number;
  15898. /**
  15899. * Gets the vector squared length
  15900. * @returns the vector squared length (float)
  15901. */
  15902. lengthSquared(): number;
  15903. /**
  15904. * Normalize the vector
  15905. * @returns the current updated Vector2
  15906. */
  15907. normalize(): Vector2;
  15908. /**
  15909. * Gets a new Vector2 copied from the Vector2
  15910. * @returns a new Vector2
  15911. */
  15912. clone(): Vector2;
  15913. /**
  15914. * Gets a new Vector2(0, 0)
  15915. * @returns a new Vector2
  15916. */
  15917. static Zero(): Vector2;
  15918. /**
  15919. * Gets a new Vector2(1, 1)
  15920. * @returns a new Vector2
  15921. */
  15922. static One(): Vector2;
  15923. /**
  15924. * Gets a new Vector2 set from the given index element of the given array
  15925. * @param array defines the data source
  15926. * @param offset defines the offset in the data source
  15927. * @returns a new Vector2
  15928. */
  15929. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15930. /**
  15931. * Sets "result" from the given index element of the given array
  15932. * @param array defines the data source
  15933. * @param offset defines the offset in the data source
  15934. * @param result defines the target vector
  15935. */
  15936. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15937. /**
  15938. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15939. * @param value1 defines 1st point of control
  15940. * @param value2 defines 2nd point of control
  15941. * @param value3 defines 3rd point of control
  15942. * @param value4 defines 4th point of control
  15943. * @param amount defines the interpolation factor
  15944. * @returns a new Vector2
  15945. */
  15946. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15947. /**
  15948. * 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".
  15949. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15950. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15951. * @param value defines the value to clamp
  15952. * @param min defines the lower limit
  15953. * @param max defines the upper limit
  15954. * @returns a new Vector2
  15955. */
  15956. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15957. /**
  15958. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15959. * @param value1 defines the 1st control point
  15960. * @param tangent1 defines the outgoing tangent
  15961. * @param value2 defines the 2nd control point
  15962. * @param tangent2 defines the incoming tangent
  15963. * @param amount defines the interpolation factor
  15964. * @returns a new Vector2
  15965. */
  15966. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15967. /**
  15968. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15969. * @param start defines the start vector
  15970. * @param end defines the end vector
  15971. * @param amount defines the interpolation factor
  15972. * @returns a new Vector2
  15973. */
  15974. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15975. /**
  15976. * Gets the dot product of the vector "left" and the vector "right"
  15977. * @param left defines first vector
  15978. * @param right defines second vector
  15979. * @returns the dot product (float)
  15980. */
  15981. static Dot(left: Vector2, right: Vector2): number;
  15982. /**
  15983. * Returns a new Vector2 equal to the normalized given vector
  15984. * @param vector defines the vector to normalize
  15985. * @returns a new Vector2
  15986. */
  15987. static Normalize(vector: Vector2): Vector2;
  15988. /**
  15989. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15990. * @param left defines 1st vector
  15991. * @param right defines 2nd vector
  15992. * @returns a new Vector2
  15993. */
  15994. static Minimize(left: Vector2, right: Vector2): Vector2;
  15995. /**
  15996. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15997. * @param left defines 1st vector
  15998. * @param right defines 2nd vector
  15999. * @returns a new Vector2
  16000. */
  16001. static Maximize(left: Vector2, right: Vector2): Vector2;
  16002. /**
  16003. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16004. * @param vector defines the vector to transform
  16005. * @param transformation defines the matrix to apply
  16006. * @returns a new Vector2
  16007. */
  16008. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16009. /**
  16010. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16011. * @param vector defines the vector to transform
  16012. * @param transformation defines the matrix to apply
  16013. * @param result defines the target vector
  16014. */
  16015. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16016. /**
  16017. * Determines if a given vector is included in a triangle
  16018. * @param p defines the vector to test
  16019. * @param p0 defines 1st triangle point
  16020. * @param p1 defines 2nd triangle point
  16021. * @param p2 defines 3rd triangle point
  16022. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16023. */
  16024. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16025. /**
  16026. * Gets the distance between the vectors "value1" and "value2"
  16027. * @param value1 defines first vector
  16028. * @param value2 defines second vector
  16029. * @returns the distance between vectors
  16030. */
  16031. static Distance(value1: Vector2, value2: Vector2): number;
  16032. /**
  16033. * Returns the squared distance between the vectors "value1" and "value2"
  16034. * @param value1 defines first vector
  16035. * @param value2 defines second vector
  16036. * @returns the squared distance between vectors
  16037. */
  16038. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16039. /**
  16040. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16041. * @param value1 defines first vector
  16042. * @param value2 defines second vector
  16043. * @returns a new Vector2
  16044. */
  16045. static Center(value1: Vector2, value2: Vector2): Vector2;
  16046. /**
  16047. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16048. * @param p defines the middle point
  16049. * @param segA defines one point of the segment
  16050. * @param segB defines the other point of the segment
  16051. * @returns the shortest distance
  16052. */
  16053. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16054. }
  16055. /**
  16056. * Classed used to store (x,y,z) vector representation
  16057. * A Vector3 is the main object used in 3D geometry
  16058. * It can represent etiher the coordinates of a point the space, either a direction
  16059. * Reminder: Babylon.js uses a left handed forward facing system
  16060. */
  16061. class Vector3 {
  16062. /**
  16063. * Defines the first coordinates (on X axis)
  16064. */
  16065. x: number;
  16066. /**
  16067. * Defines the second coordinates (on Y axis)
  16068. */
  16069. y: number;
  16070. /**
  16071. * Defines the third coordinates (on Z axis)
  16072. */
  16073. z: number;
  16074. /**
  16075. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16076. * @param x defines the first coordinates (on X axis)
  16077. * @param y defines the second coordinates (on Y axis)
  16078. * @param z defines the third coordinates (on Z axis)
  16079. */
  16080. constructor(
  16081. /**
  16082. * Defines the first coordinates (on X axis)
  16083. */
  16084. x?: number,
  16085. /**
  16086. * Defines the second coordinates (on Y axis)
  16087. */
  16088. y?: number,
  16089. /**
  16090. * Defines the third coordinates (on Z axis)
  16091. */
  16092. z?: number);
  16093. /**
  16094. * Creates a string representation of the Vector3
  16095. * @returns a string with the Vector3 coordinates.
  16096. */
  16097. toString(): string;
  16098. /**
  16099. * Gets the class name
  16100. * @returns the string "Vector3"
  16101. */
  16102. getClassName(): string;
  16103. /**
  16104. * Creates the Vector3 hash code
  16105. * @returns a number which tends to be unique between Vector3 instances
  16106. */
  16107. getHashCode(): number;
  16108. /**
  16109. * Creates an array containing three elements : the coordinates of the Vector3
  16110. * @returns a new array of numbers
  16111. */
  16112. asArray(): number[];
  16113. /**
  16114. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16115. * @param array defines the destination array
  16116. * @param index defines the offset in the destination array
  16117. * @returns the current Vector3
  16118. */
  16119. toArray(array: FloatArray, index?: number): Vector3;
  16120. /**
  16121. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16122. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16123. */
  16124. toQuaternion(): Quaternion;
  16125. /**
  16126. * Adds the given vector to the current Vector3
  16127. * @param otherVector defines the second operand
  16128. * @returns the current updated Vector3
  16129. */
  16130. addInPlace(otherVector: Vector3): Vector3;
  16131. /**
  16132. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16133. * @param otherVector defines the second operand
  16134. * @returns the resulting Vector3
  16135. */
  16136. add(otherVector: Vector3): Vector3;
  16137. /**
  16138. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16139. * @param otherVector defines the second operand
  16140. * @param result defines the Vector3 object where to store the result
  16141. * @returns the current Vector3
  16142. */
  16143. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16144. /**
  16145. * Subtract the given vector from the current Vector3
  16146. * @param otherVector defines the second operand
  16147. * @returns the current updated Vector3
  16148. */
  16149. subtractInPlace(otherVector: Vector3): Vector3;
  16150. /**
  16151. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16152. * @param otherVector defines the second operand
  16153. * @returns the resulting Vector3
  16154. */
  16155. subtract(otherVector: Vector3): Vector3;
  16156. /**
  16157. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16158. * @param otherVector defines the second operand
  16159. * @param result defines the Vector3 object where to store the result
  16160. * @returns the current Vector3
  16161. */
  16162. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16163. /**
  16164. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16165. * @param x defines the x coordinate of the operand
  16166. * @param y defines the y coordinate of the operand
  16167. * @param z defines the z coordinate of the operand
  16168. * @returns the resulting Vector3
  16169. */
  16170. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16171. /**
  16172. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16173. * @param x defines the x coordinate of the operand
  16174. * @param y defines the y coordinate of the operand
  16175. * @param z defines the z coordinate of the operand
  16176. * @param result defines the Vector3 object where to store the result
  16177. * @returns the current Vector3
  16178. */
  16179. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16180. /**
  16181. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16182. * @returns a new Vector3
  16183. */
  16184. negate(): Vector3;
  16185. /**
  16186. * Multiplies the Vector3 coordinates by the float "scale"
  16187. * @param scale defines the multiplier factor
  16188. * @returns the current updated Vector3
  16189. */
  16190. scaleInPlace(scale: number): Vector3;
  16191. /**
  16192. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16193. * @param scale defines the multiplier factor
  16194. * @returns a new Vector3
  16195. */
  16196. scale(scale: number): Vector3;
  16197. /**
  16198. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16199. * @param scale defines the multiplier factor
  16200. * @param result defines the Vector3 object where to store the result
  16201. * @returns the current Vector3
  16202. */
  16203. scaleToRef(scale: number, result: Vector3): Vector3;
  16204. /**
  16205. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16206. * @param scale defines the scale factor
  16207. * @param result defines the Vector3 object where to store the result
  16208. * @returns the unmodified current Vector3
  16209. */
  16210. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16211. /**
  16212. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16213. * @param otherVector defines the second operand
  16214. * @returns true if both vectors are equals
  16215. */
  16216. equals(otherVector: Vector3): boolean;
  16217. /**
  16218. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16219. * @param otherVector defines the second operand
  16220. * @param epsilon defines the minimal distance to define values as equals
  16221. * @returns true if both vectors are distant less than epsilon
  16222. */
  16223. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16224. /**
  16225. * Returns true if the current Vector3 coordinates equals the given floats
  16226. * @param x defines the x coordinate of the operand
  16227. * @param y defines the y coordinate of the operand
  16228. * @param z defines the z coordinate of the operand
  16229. * @returns true if both vectors are equals
  16230. */
  16231. equalsToFloats(x: number, y: number, z: number): boolean;
  16232. /**
  16233. * Multiplies the current Vector3 coordinates by the given ones
  16234. * @param otherVector defines the second operand
  16235. * @returns the current updated Vector3
  16236. */
  16237. multiplyInPlace(otherVector: Vector3): Vector3;
  16238. /**
  16239. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16240. * @param otherVector defines the second operand
  16241. * @returns the new Vector3
  16242. */
  16243. multiply(otherVector: Vector3): Vector3;
  16244. /**
  16245. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16246. * @param otherVector defines the second operand
  16247. * @param result defines the Vector3 object where to store the result
  16248. * @returns the current Vector3
  16249. */
  16250. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16251. /**
  16252. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16253. * @param x defines the x coordinate of the operand
  16254. * @param y defines the y coordinate of the operand
  16255. * @param z defines the z coordinate of the operand
  16256. * @returns the new Vector3
  16257. */
  16258. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16259. /**
  16260. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16261. * @param otherVector defines the second operand
  16262. * @returns the new Vector3
  16263. */
  16264. divide(otherVector: Vector3): Vector3;
  16265. /**
  16266. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16267. * @param otherVector defines the second operand
  16268. * @param result defines the Vector3 object where to store the result
  16269. * @returns the current Vector3
  16270. */
  16271. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16272. /**
  16273. * Divides the current Vector3 coordinates by the given ones.
  16274. * @param otherVector defines the second operand
  16275. * @returns the current updated Vector3
  16276. */
  16277. divideInPlace(otherVector: Vector3): Vector3;
  16278. /**
  16279. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16280. * @param other defines the second operand
  16281. * @returns the current updated Vector3
  16282. */
  16283. minimizeInPlace(other: Vector3): Vector3;
  16284. /**
  16285. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16286. * @param other defines the second operand
  16287. * @returns the current updated Vector3
  16288. */
  16289. maximizeInPlace(other: Vector3): Vector3;
  16290. /**
  16291. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16292. */
  16293. readonly isNonUniform: boolean;
  16294. /**
  16295. * Gets the length of the Vector3
  16296. * @returns the length of the Vecto3
  16297. */
  16298. length(): number;
  16299. /**
  16300. * Gets the squared length of the Vector3
  16301. * @returns squared length of the Vector3
  16302. */
  16303. lengthSquared(): number;
  16304. /**
  16305. * Normalize the current Vector3.
  16306. * Please note that this is an in place operation.
  16307. * @returns the current updated Vector3
  16308. */
  16309. normalize(): Vector3;
  16310. /**
  16311. * Normalize the current Vector3 to a new vector
  16312. * @returns the new Vector3
  16313. */
  16314. normalizeToNew(): Vector3;
  16315. /**
  16316. * Normalize the current Vector3 to the reference
  16317. * @param reference define the Vector3 to update
  16318. * @returns the updated Vector3
  16319. */
  16320. normalizeToRef(reference: Vector3): Vector3;
  16321. /**
  16322. * Creates a new Vector3 copied from the current Vector3
  16323. * @returns the new Vector3
  16324. */
  16325. clone(): Vector3;
  16326. /**
  16327. * Copies the given vector coordinates to the current Vector3 ones
  16328. * @param source defines the source Vector3
  16329. * @returns the current updated Vector3
  16330. */
  16331. copyFrom(source: Vector3): Vector3;
  16332. /**
  16333. * Copies the given floats to the current Vector3 coordinates
  16334. * @param x defines the x coordinate of the operand
  16335. * @param y defines the y coordinate of the operand
  16336. * @param z defines the z coordinate of the operand
  16337. * @returns the current updated Vector3
  16338. */
  16339. copyFromFloats(x: number, y: number, z: number): Vector3;
  16340. /**
  16341. * Copies the given floats to the current Vector3 coordinates
  16342. * @param x defines the x coordinate of the operand
  16343. * @param y defines the y coordinate of the operand
  16344. * @param z defines the z coordinate of the operand
  16345. * @returns the current updated Vector3
  16346. */
  16347. set(x: number, y: number, z: number): Vector3;
  16348. /**
  16349. * Get the clip factor between two vectors
  16350. * @param vector0 defines the first operand
  16351. * @param vector1 defines the second operand
  16352. * @param axis defines the axis to use
  16353. * @param size defines the size along the axis
  16354. * @returns the clip factor
  16355. */
  16356. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16357. /**
  16358. * Get angle between two vectors
  16359. * @param vector0 angle between vector0 and vector1
  16360. * @param vector1 angle between vector0 and vector1
  16361. * @param normal direction of the normal
  16362. * @return the angle between vector0 and vector1
  16363. */
  16364. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16365. /**
  16366. * Returns a new Vector3 set from the index "offset" of the given array
  16367. * @param array defines the source array
  16368. * @param offset defines the offset in the source array
  16369. * @returns the new Vector3
  16370. */
  16371. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16372. /**
  16373. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16374. * This function is deprecated. Use FromArray instead
  16375. * @param array defines the source array
  16376. * @param offset defines the offset in the source array
  16377. * @returns the new Vector3
  16378. */
  16379. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16380. /**
  16381. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16382. * @param array defines the source array
  16383. * @param offset defines the offset in the source array
  16384. * @param result defines the Vector3 where to store the result
  16385. */
  16386. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16387. /**
  16388. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16389. * This function is deprecated. Use FromArrayToRef instead.
  16390. * @param array defines the source array
  16391. * @param offset defines the offset in the source array
  16392. * @param result defines the Vector3 where to store the result
  16393. */
  16394. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16395. /**
  16396. * Sets the given vector "result" with the given floats.
  16397. * @param x defines the x coordinate of the source
  16398. * @param y defines the y coordinate of the source
  16399. * @param z defines the z coordinate of the source
  16400. * @param result defines the Vector3 where to store the result
  16401. */
  16402. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16403. /**
  16404. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16405. * @returns a new empty Vector3
  16406. */
  16407. static Zero(): Vector3;
  16408. /**
  16409. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16410. * @returns a new unit Vector3
  16411. */
  16412. static One(): Vector3;
  16413. /**
  16414. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16415. * @returns a new up Vector3
  16416. */
  16417. static Up(): Vector3;
  16418. /**
  16419. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16420. * @returns a new down Vector3
  16421. */
  16422. static Down(): Vector3;
  16423. /**
  16424. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16425. * @returns a new forward Vector3
  16426. */
  16427. static Forward(): Vector3;
  16428. /**
  16429. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16430. * @returns a new right Vector3
  16431. */
  16432. static Right(): Vector3;
  16433. /**
  16434. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16435. * @returns a new left Vector3
  16436. */
  16437. static Left(): Vector3;
  16438. /**
  16439. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16440. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16441. * @param vector defines the Vector3 to transform
  16442. * @param transformation defines the transformation matrix
  16443. * @returns the transformed Vector3
  16444. */
  16445. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16446. /**
  16447. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16448. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16449. * @param vector defines the Vector3 to transform
  16450. * @param transformation defines the transformation matrix
  16451. * @param result defines the Vector3 where to store the result
  16452. */
  16453. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16454. /**
  16455. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16456. * This method computes tranformed coordinates only, not transformed direction vectors
  16457. * @param x define the x coordinate of the source vector
  16458. * @param y define the y coordinate of the source vector
  16459. * @param z define the z coordinate of the source vector
  16460. * @param transformation defines the transformation matrix
  16461. * @param result defines the Vector3 where to store the result
  16462. */
  16463. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16464. /**
  16465. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16466. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16467. * @param vector defines the Vector3 to transform
  16468. * @param transformation defines the transformation matrix
  16469. * @returns the new Vector3
  16470. */
  16471. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16472. /**
  16473. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16474. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16475. * @param vector defines the Vector3 to transform
  16476. * @param transformation defines the transformation matrix
  16477. * @param result defines the Vector3 where to store the result
  16478. */
  16479. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16480. /**
  16481. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16482. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16483. * @param x define the x coordinate of the source vector
  16484. * @param y define the y coordinate of the source vector
  16485. * @param z define the z coordinate of the source vector
  16486. * @param transformation defines the transformation matrix
  16487. * @param result defines the Vector3 where to store the result
  16488. */
  16489. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16490. /**
  16491. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16492. * @param value1 defines the first control point
  16493. * @param value2 defines the second control point
  16494. * @param value3 defines the third control point
  16495. * @param value4 defines the fourth control point
  16496. * @param amount defines the amount on the spline to use
  16497. * @returns the new Vector3
  16498. */
  16499. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16500. /**
  16501. * 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"
  16502. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16503. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16504. * @param value defines the current value
  16505. * @param min defines the lower range value
  16506. * @param max defines the upper range value
  16507. * @returns the new Vector3
  16508. */
  16509. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16510. /**
  16511. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16512. * @param value1 defines the first control point
  16513. * @param tangent1 defines the first tangent vector
  16514. * @param value2 defines the second control point
  16515. * @param tangent2 defines the second tangent vector
  16516. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16517. * @returns the new Vector3
  16518. */
  16519. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16520. /**
  16521. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16522. * @param start defines the start value
  16523. * @param end defines the end value
  16524. * @param amount max defines amount between both (between 0 and 1)
  16525. * @returns the new Vector3
  16526. */
  16527. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16528. /**
  16529. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16530. * @param start defines the start value
  16531. * @param end defines the end value
  16532. * @param amount max defines amount between both (between 0 and 1)
  16533. * @param result defines the Vector3 where to store the result
  16534. */
  16535. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16536. /**
  16537. * Returns the dot product (float) between the vectors "left" and "right"
  16538. * @param left defines the left operand
  16539. * @param right defines the right operand
  16540. * @returns the dot product
  16541. */
  16542. static Dot(left: Vector3, right: Vector3): number;
  16543. /**
  16544. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16545. * The cross product is then orthogonal to both "left" and "right"
  16546. * @param left defines the left operand
  16547. * @param right defines the right operand
  16548. * @returns the cross product
  16549. */
  16550. static Cross(left: Vector3, right: Vector3): Vector3;
  16551. /**
  16552. * Sets the given vector "result" with the cross product of "left" and "right"
  16553. * The cross product is then orthogonal to both "left" and "right"
  16554. * @param left defines the left operand
  16555. * @param right defines the right operand
  16556. * @param result defines the Vector3 where to store the result
  16557. */
  16558. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16559. /**
  16560. * Returns a new Vector3 as the normalization of the given vector
  16561. * @param vector defines the Vector3 to normalize
  16562. * @returns the new Vector3
  16563. */
  16564. static Normalize(vector: Vector3): Vector3;
  16565. /**
  16566. * Sets the given vector "result" with the normalization of the given first vector
  16567. * @param vector defines the Vector3 to normalize
  16568. * @param result defines the Vector3 where to store the result
  16569. */
  16570. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16571. private static _viewportMatrixCache;
  16572. /**
  16573. * Project a Vector3 onto screen space
  16574. * @param vector defines the Vector3 to project
  16575. * @param world defines the world matrix to use
  16576. * @param transform defines the transform (view x projection) matrix to use
  16577. * @param viewport defines the screen viewport to use
  16578. * @returns the new Vector3
  16579. */
  16580. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16581. /**
  16582. * Unproject from screen space to object space
  16583. * @param source defines the screen space Vector3 to use
  16584. * @param viewportWidth defines the current width of the viewport
  16585. * @param viewportHeight defines the current height of the viewport
  16586. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16587. * @param transform defines the transform (view x projection) matrix to use
  16588. * @returns the new Vector3
  16589. */
  16590. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16591. /**
  16592. * Unproject from screen space to object space
  16593. * @param source defines the screen space Vector3 to use
  16594. * @param viewportWidth defines the current width of the viewport
  16595. * @param viewportHeight defines the current height of the viewport
  16596. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16597. * @param view defines the view matrix to use
  16598. * @param projection defines the projection matrix to use
  16599. * @returns the new Vector3
  16600. */
  16601. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16602. /**
  16603. * Unproject from screen space to object space
  16604. * @param source defines the screen space Vector3 to use
  16605. * @param viewportWidth defines the current width of the viewport
  16606. * @param viewportHeight defines the current height of the viewport
  16607. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16608. * @param view defines the view matrix to use
  16609. * @param projection defines the projection matrix to use
  16610. * @param result defines the Vector3 where to store the result
  16611. */
  16612. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16613. /**
  16614. * Unproject from screen space to object space
  16615. * @param sourceX defines the screen space x coordinate to use
  16616. * @param sourceY defines the screen space y coordinate to use
  16617. * @param sourceZ defines the screen space z coordinate to use
  16618. * @param viewportWidth defines the current width of the viewport
  16619. * @param viewportHeight defines the current height of the viewport
  16620. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16621. * @param view defines the view matrix to use
  16622. * @param projection defines the projection matrix to use
  16623. * @param result defines the Vector3 where to store the result
  16624. */
  16625. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16626. /**
  16627. * Gets the minimal coordinate values between two Vector3
  16628. * @param left defines the first operand
  16629. * @param right defines the second operand
  16630. * @returns the new Vector3
  16631. */
  16632. static Minimize(left: Vector3, right: Vector3): Vector3;
  16633. /**
  16634. * Gets the maximal coordinate values between two Vector3
  16635. * @param left defines the first operand
  16636. * @param right defines the second operand
  16637. * @returns the new Vector3
  16638. */
  16639. static Maximize(left: Vector3, right: Vector3): Vector3;
  16640. /**
  16641. * Returns the distance between the vectors "value1" and "value2"
  16642. * @param value1 defines the first operand
  16643. * @param value2 defines the second operand
  16644. * @returns the distance
  16645. */
  16646. static Distance(value1: Vector3, value2: Vector3): number;
  16647. /**
  16648. * Returns the squared distance between the vectors "value1" and "value2"
  16649. * @param value1 defines the first operand
  16650. * @param value2 defines the second operand
  16651. * @returns the squared distance
  16652. */
  16653. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16654. /**
  16655. * Returns a new Vector3 located at the center between "value1" and "value2"
  16656. * @param value1 defines the first operand
  16657. * @param value2 defines the second operand
  16658. * @returns the new Vector3
  16659. */
  16660. static Center(value1: Vector3, value2: Vector3): Vector3;
  16661. /**
  16662. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16663. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16664. * to something in order to rotate it from its local system to the given target system
  16665. * Note: axis1, axis2 and axis3 are normalized during this operation
  16666. * @param axis1 defines the first axis
  16667. * @param axis2 defines the second axis
  16668. * @param axis3 defines the third axis
  16669. * @returns a new Vector3
  16670. */
  16671. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16672. /**
  16673. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16674. * @param axis1 defines the first axis
  16675. * @param axis2 defines the second axis
  16676. * @param axis3 defines the third axis
  16677. * @param ref defines the Vector3 where to store the result
  16678. */
  16679. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16680. }
  16681. class Vector4 {
  16682. x: number;
  16683. y: number;
  16684. z: number;
  16685. w: number;
  16686. /**
  16687. * Creates a Vector4 object from the given floats.
  16688. */
  16689. constructor(x: number, y: number, z: number, w: number);
  16690. /**
  16691. * Returns the string with the Vector4 coordinates.
  16692. */
  16693. toString(): string;
  16694. /**
  16695. * Returns the string "Vector4".
  16696. */
  16697. getClassName(): string;
  16698. /**
  16699. * Returns the Vector4 hash code.
  16700. */
  16701. getHashCode(): number;
  16702. /**
  16703. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16704. */
  16705. asArray(): number[];
  16706. /**
  16707. * Populates the given array from the given index with the Vector4 coordinates.
  16708. * Returns the Vector4.
  16709. */
  16710. toArray(array: FloatArray, index?: number): Vector4;
  16711. /**
  16712. * Adds the given vector to the current Vector4.
  16713. * Returns the updated Vector4.
  16714. */
  16715. addInPlace(otherVector: Vector4): Vector4;
  16716. /**
  16717. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16718. */
  16719. add(otherVector: Vector4): Vector4;
  16720. /**
  16721. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16722. * Returns the current Vector4.
  16723. */
  16724. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16725. /**
  16726. * Subtract in place the given vector from the current Vector4.
  16727. * Returns the updated Vector4.
  16728. */
  16729. subtractInPlace(otherVector: Vector4): Vector4;
  16730. /**
  16731. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16732. */
  16733. subtract(otherVector: Vector4): Vector4;
  16734. /**
  16735. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16736. * Returns the current Vector4.
  16737. */
  16738. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16739. /**
  16740. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16741. */
  16742. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16743. /**
  16744. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16745. * Returns the current Vector4.
  16746. */
  16747. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16748. /**
  16749. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16750. */
  16751. negate(): Vector4;
  16752. /**
  16753. * Multiplies the current Vector4 coordinates by scale (float).
  16754. * Returns the updated Vector4.
  16755. */
  16756. scaleInPlace(scale: number): Vector4;
  16757. /**
  16758. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16759. */
  16760. scale(scale: number): Vector4;
  16761. /**
  16762. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16763. * Returns the current Vector4.
  16764. */
  16765. scaleToRef(scale: number, result: Vector4): Vector4;
  16766. /**
  16767. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16768. * @param scale defines the scale factor
  16769. * @param result defines the Vector4 object where to store the result
  16770. * @returns the unmodified current Vector4
  16771. */
  16772. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16773. /**
  16774. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16775. */
  16776. equals(otherVector: Vector4): boolean;
  16777. /**
  16778. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16779. */
  16780. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16781. /**
  16782. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16783. */
  16784. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16785. /**
  16786. * Multiplies in place the current Vector4 by the given one.
  16787. * Returns the updated Vector4.
  16788. */
  16789. multiplyInPlace(otherVector: Vector4): Vector4;
  16790. /**
  16791. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16792. */
  16793. multiply(otherVector: Vector4): Vector4;
  16794. /**
  16795. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16796. * Returns the current Vector4.
  16797. */
  16798. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16799. /**
  16800. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16801. */
  16802. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16803. /**
  16804. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16805. */
  16806. divide(otherVector: Vector4): Vector4;
  16807. /**
  16808. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16809. * Returns the current Vector4.
  16810. */
  16811. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16812. /**
  16813. * Divides the current Vector3 coordinates by the given ones.
  16814. * @returns the updated Vector3.
  16815. */
  16816. divideInPlace(otherVector: Vector4): Vector4;
  16817. /**
  16818. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16819. * @param other defines the second operand
  16820. * @returns the current updated Vector4
  16821. */
  16822. minimizeInPlace(other: Vector4): Vector4;
  16823. /**
  16824. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16825. * @param other defines the second operand
  16826. * @returns the current updated Vector4
  16827. */
  16828. maximizeInPlace(other: Vector4): Vector4;
  16829. /**
  16830. * Returns the Vector4 length (float).
  16831. */
  16832. length(): number;
  16833. /**
  16834. * Returns the Vector4 squared length (float).
  16835. */
  16836. lengthSquared(): number;
  16837. /**
  16838. * Normalizes in place the Vector4.
  16839. * Returns the updated Vector4.
  16840. */
  16841. normalize(): Vector4;
  16842. /**
  16843. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16844. */
  16845. toVector3(): Vector3;
  16846. /**
  16847. * Returns a new Vector4 copied from the current one.
  16848. */
  16849. clone(): Vector4;
  16850. /**
  16851. * Updates the current Vector4 with the given one coordinates.
  16852. * Returns the updated Vector4.
  16853. */
  16854. copyFrom(source: Vector4): Vector4;
  16855. /**
  16856. * Updates the current Vector4 coordinates with the given floats.
  16857. * Returns the updated Vector4.
  16858. */
  16859. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16860. /**
  16861. * Updates the current Vector4 coordinates with the given floats.
  16862. * Returns the updated Vector4.
  16863. */
  16864. set(x: number, y: number, z: number, w: number): Vector4;
  16865. /**
  16866. * Returns a new Vector4 set from the starting index of the given array.
  16867. */
  16868. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16869. /**
  16870. * Updates the given vector "result" from the starting index of the given array.
  16871. */
  16872. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16873. /**
  16874. * Updates the given vector "result" from the starting index of the given Float32Array.
  16875. */
  16876. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16877. /**
  16878. * Updates the given vector "result" coordinates from the given floats.
  16879. */
  16880. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16881. /**
  16882. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16883. */
  16884. static Zero(): Vector4;
  16885. /**
  16886. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16887. */
  16888. static One(): Vector4;
  16889. /**
  16890. * Returns a new normalized Vector4 from the given one.
  16891. */
  16892. static Normalize(vector: Vector4): Vector4;
  16893. /**
  16894. * Updates the given vector "result" from the normalization of the given one.
  16895. */
  16896. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16897. static Minimize(left: Vector4, right: Vector4): Vector4;
  16898. static Maximize(left: Vector4, right: Vector4): Vector4;
  16899. /**
  16900. * Returns the distance (float) between the vectors "value1" and "value2".
  16901. */
  16902. static Distance(value1: Vector4, value2: Vector4): number;
  16903. /**
  16904. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16905. */
  16906. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16907. /**
  16908. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16909. */
  16910. static Center(value1: Vector4, value2: Vector4): Vector4;
  16911. /**
  16912. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16913. * This methods computes transformed normalized direction vectors only.
  16914. */
  16915. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16916. /**
  16917. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16918. * This methods computes transformed normalized direction vectors only.
  16919. */
  16920. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16921. /**
  16922. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16923. * This methods computes transformed normalized direction vectors only.
  16924. */
  16925. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16926. }
  16927. interface ISize {
  16928. width: number;
  16929. height: number;
  16930. }
  16931. class Size implements ISize {
  16932. width: number;
  16933. height: number;
  16934. /**
  16935. * Creates a Size object from the given width and height (floats).
  16936. */
  16937. constructor(width: number, height: number);
  16938. toString(): string;
  16939. /**
  16940. * Returns the string "Size"
  16941. */
  16942. getClassName(): string;
  16943. /**
  16944. * Returns the Size hash code.
  16945. */
  16946. getHashCode(): number;
  16947. /**
  16948. * Updates the current size from the given one.
  16949. * Returns the updated Size.
  16950. */
  16951. copyFrom(src: Size): void;
  16952. /**
  16953. * Updates in place the current Size from the given floats.
  16954. * Returns the updated Size.
  16955. */
  16956. copyFromFloats(width: number, height: number): Size;
  16957. /**
  16958. * Updates in place the current Size from the given floats.
  16959. * Returns the updated Size.
  16960. */
  16961. set(width: number, height: number): Size;
  16962. /**
  16963. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16964. */
  16965. multiplyByFloats(w: number, h: number): Size;
  16966. /**
  16967. * Returns a new Size copied from the given one.
  16968. */
  16969. clone(): Size;
  16970. /**
  16971. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16972. */
  16973. equals(other: Size): boolean;
  16974. /**
  16975. * Returns the surface of the Size : width * height (float).
  16976. */
  16977. readonly surface: number;
  16978. /**
  16979. * Returns a new Size set to (0.0, 0.0)
  16980. */
  16981. static Zero(): Size;
  16982. /**
  16983. * Returns a new Size set as the addition result of the current Size and the given one.
  16984. */
  16985. add(otherSize: Size): Size;
  16986. /**
  16987. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16988. */
  16989. subtract(otherSize: Size): Size;
  16990. /**
  16991. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16992. */
  16993. static Lerp(start: Size, end: Size, amount: number): Size;
  16994. }
  16995. /**
  16996. * Class used to store quaternion data
  16997. * @see https://en.wikipedia.org/wiki/Quaternion
  16998. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16999. */
  17000. class Quaternion {
  17001. /** defines the first component (0 by default) */
  17002. x: number;
  17003. /** defines the second component (0 by default) */
  17004. y: number;
  17005. /** defines the third component (0 by default) */
  17006. z: number;
  17007. /** defines the fourth component (1.0 by default) */
  17008. w: number;
  17009. /**
  17010. * Creates a new Quaternion from the given floats
  17011. * @param x defines the first component (0 by default)
  17012. * @param y defines the second component (0 by default)
  17013. * @param z defines the third component (0 by default)
  17014. * @param w defines the fourth component (1.0 by default)
  17015. */
  17016. constructor(
  17017. /** defines the first component (0 by default) */
  17018. x?: number,
  17019. /** defines the second component (0 by default) */
  17020. y?: number,
  17021. /** defines the third component (0 by default) */
  17022. z?: number,
  17023. /** defines the fourth component (1.0 by default) */
  17024. w?: number);
  17025. /**
  17026. * Gets a string representation for the current quaternion
  17027. * @returns a string with the Quaternion coordinates
  17028. */
  17029. toString(): string;
  17030. /**
  17031. * Gets the class name of the quaternion
  17032. * @returns the string "Quaternion"
  17033. */
  17034. getClassName(): string;
  17035. /**
  17036. * Gets a hash code for this quaternion
  17037. * @returns the quaternion hash code
  17038. */
  17039. getHashCode(): number;
  17040. /**
  17041. * Copy the quaternion to an array
  17042. * @returns a new array populated with 4 elements from the quaternion coordinates
  17043. */
  17044. asArray(): number[];
  17045. /**
  17046. * Check if two quaternions are equals
  17047. * @param otherQuaternion defines the second operand
  17048. * @return true if the current quaternion and the given one coordinates are strictly equals
  17049. */
  17050. equals(otherQuaternion: Quaternion): boolean;
  17051. /**
  17052. * Clone the current quaternion
  17053. * @returns a new quaternion copied from the current one
  17054. */
  17055. clone(): Quaternion;
  17056. /**
  17057. * Copy a quaternion to the current one
  17058. * @param other defines the other quaternion
  17059. * @returns the updated current quaternion
  17060. */
  17061. copyFrom(other: Quaternion): Quaternion;
  17062. /**
  17063. * Updates the current quaternion with the given float coordinates
  17064. * @param x defines the x coordinate
  17065. * @param y defines the y coordinate
  17066. * @param z defines the z coordinate
  17067. * @param w defines the w coordinate
  17068. * @returns the updated current quaternion
  17069. */
  17070. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17071. /**
  17072. * Updates the current quaternion from the given float coordinates
  17073. * @param x defines the x coordinate
  17074. * @param y defines the y coordinate
  17075. * @param z defines the z coordinate
  17076. * @param w defines the w coordinate
  17077. * @returns the updated current quaternion
  17078. */
  17079. set(x: number, y: number, z: number, w: number): Quaternion;
  17080. /**
  17081. * Adds two quaternions
  17082. * @param other defines the second operand
  17083. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17084. */
  17085. add(other: Quaternion): Quaternion;
  17086. /**
  17087. * Add a quaternion to the current one
  17088. * @param other defines the quaternion to add
  17089. * @returns the current quaternion
  17090. */
  17091. addInPlace(other: Quaternion): Quaternion;
  17092. /**
  17093. * Subtract two quaternions
  17094. * @param other defines the second operand
  17095. * @returns a new quaternion as the subtraction result of the given one from the current one
  17096. */
  17097. subtract(other: Quaternion): Quaternion;
  17098. /**
  17099. * Multiplies the current quaternion by a scale factor
  17100. * @param value defines the scale factor
  17101. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17102. */
  17103. scale(value: number): Quaternion;
  17104. /**
  17105. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17106. * @param scale defines the scale factor
  17107. * @param result defines the Quaternion object where to store the result
  17108. * @returns the unmodified current quaternion
  17109. */
  17110. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17111. /**
  17112. * Multiplies in place the current quaternion by a scale factor
  17113. * @param value defines the scale factor
  17114. * @returns the current modified quaternion
  17115. */
  17116. scaleInPlace(value: number): Quaternion;
  17117. /**
  17118. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17119. * @param scale defines the scale factor
  17120. * @param result defines the Quaternion object where to store the result
  17121. * @returns the unmodified current quaternion
  17122. */
  17123. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17124. /**
  17125. * Multiplies two quaternions
  17126. * @param q1 defines the second operand
  17127. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17128. */
  17129. multiply(q1: Quaternion): Quaternion;
  17130. /**
  17131. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17132. * @param q1 defines the second operand
  17133. * @param result defines the target quaternion
  17134. * @returns the current quaternion
  17135. */
  17136. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17137. /**
  17138. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17139. * @param q1 defines the second operand
  17140. * @returns the currentupdated quaternion
  17141. */
  17142. multiplyInPlace(q1: Quaternion): Quaternion;
  17143. /**
  17144. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17145. * @param ref defines the target quaternion
  17146. * @returns the current quaternion
  17147. */
  17148. conjugateToRef(ref: Quaternion): Quaternion;
  17149. /**
  17150. * Conjugates in place (1-q) the current quaternion
  17151. * @returns the current updated quaternion
  17152. */
  17153. conjugateInPlace(): Quaternion;
  17154. /**
  17155. * Conjugates in place (1-q) the current quaternion
  17156. * @returns a new quaternion
  17157. */
  17158. conjugate(): Quaternion;
  17159. /**
  17160. * Gets length of current quaternion
  17161. * @returns the quaternion length (float)
  17162. */
  17163. length(): number;
  17164. /**
  17165. * Normalize in place the current quaternion
  17166. * @returns the current updated quaternion
  17167. */
  17168. normalize(): Quaternion;
  17169. /**
  17170. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17171. * @param order is a reserved parameter and is ignore for now
  17172. * @returns a new Vector3 containing the Euler angles
  17173. */
  17174. toEulerAngles(order?: string): Vector3;
  17175. /**
  17176. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17177. * @param result defines the vector which will be filled with the Euler angles
  17178. * @param order is a reserved parameter and is ignore for now
  17179. * @returns the current unchanged quaternion
  17180. */
  17181. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17182. /**
  17183. * Updates the given rotation matrix with the current quaternion values
  17184. * @param result defines the target matrix
  17185. * @returns the current unchanged quaternion
  17186. */
  17187. toRotationMatrix(result: Matrix): Quaternion;
  17188. /**
  17189. * Updates the current quaternion from the given rotation matrix values
  17190. * @param matrix defines the source matrix
  17191. * @returns the current updated quaternion
  17192. */
  17193. fromRotationMatrix(matrix: Matrix): Quaternion;
  17194. /**
  17195. * Creates a new quaternion from a rotation matrix
  17196. * @param matrix defines the source matrix
  17197. * @returns a new quaternion created from the given rotation matrix values
  17198. */
  17199. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17200. /**
  17201. * Updates the given quaternion with the given rotation matrix values
  17202. * @param matrix defines the source matrix
  17203. * @param result defines the target quaternion
  17204. */
  17205. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17206. /**
  17207. * Returns the dot product (float) between the quaternions "left" and "right"
  17208. * @param left defines the left operand
  17209. * @param right defines the right operand
  17210. * @returns the dot product
  17211. */
  17212. static Dot(left: Quaternion, right: Quaternion): number;
  17213. /**
  17214. * Checks if the two quaternions are close to each other
  17215. * @param quat0 defines the first quaternion to check
  17216. * @param quat1 defines the second quaternion to check
  17217. * @returns true if the two quaternions are close to each other
  17218. */
  17219. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17220. /**
  17221. * Creates an empty quaternion
  17222. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17223. */
  17224. static Zero(): Quaternion;
  17225. /**
  17226. * Inverse a given quaternion
  17227. * @param q defines the source quaternion
  17228. * @returns a new quaternion as the inverted current quaternion
  17229. */
  17230. static Inverse(q: Quaternion): Quaternion;
  17231. /**
  17232. * Creates an identity quaternion
  17233. * @returns the identity quaternion
  17234. */
  17235. static Identity(): Quaternion;
  17236. /**
  17237. * Gets a boolean indicating if the given quaternion is identity
  17238. * @param quaternion defines the quaternion to check
  17239. * @returns true if the quaternion is identity
  17240. */
  17241. static IsIdentity(quaternion: Quaternion): boolean;
  17242. /**
  17243. * Creates a quaternion from a rotation around an axis
  17244. * @param axis defines the axis to use
  17245. * @param angle defines the angle to use
  17246. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17247. */
  17248. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17249. /**
  17250. * Creates a rotation around an axis and stores it into the given quaternion
  17251. * @param axis defines the axis to use
  17252. * @param angle defines the angle to use
  17253. * @param result defines the target quaternion
  17254. * @returns the target quaternion
  17255. */
  17256. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17257. /**
  17258. * Creates a new quaternion from data stored into an array
  17259. * @param array defines the data source
  17260. * @param offset defines the offset in the source array where the data starts
  17261. * @returns a new quaternion
  17262. */
  17263. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17264. /**
  17265. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17266. * @param yaw defines the rotation around Y axis
  17267. * @param pitch defines the rotation around X axis
  17268. * @param roll defines the rotation around Z axis
  17269. * @returns the new quaternion
  17270. */
  17271. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17272. /**
  17273. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17274. * @param yaw defines the rotation around Y axis
  17275. * @param pitch defines the rotation around X axis
  17276. * @param roll defines the rotation around Z axis
  17277. * @param result defines the target quaternion
  17278. */
  17279. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17280. /**
  17281. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17282. * @param alpha defines the rotation around first axis
  17283. * @param beta defines the rotation around second axis
  17284. * @param gamma defines the rotation around third axis
  17285. * @returns the new quaternion
  17286. */
  17287. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17288. /**
  17289. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17290. * @param alpha defines the rotation around first axis
  17291. * @param beta defines the rotation around second axis
  17292. * @param gamma defines the rotation around third axis
  17293. * @param result defines the target quaternion
  17294. */
  17295. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17296. /**
  17297. * 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)
  17298. * @param axis1 defines the first axis
  17299. * @param axis2 defines the second axis
  17300. * @param axis3 defines the third axis
  17301. * @returns the new quaternion
  17302. */
  17303. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17304. /**
  17305. * 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
  17306. * @param axis1 defines the first axis
  17307. * @param axis2 defines the second axis
  17308. * @param axis3 defines the third axis
  17309. * @param ref defines the target quaternion
  17310. */
  17311. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17312. /**
  17313. * Interpolates between two quaternions
  17314. * @param left defines first quaternion
  17315. * @param right defines second quaternion
  17316. * @param amount defines the gradient to use
  17317. * @returns the new interpolated quaternion
  17318. */
  17319. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17320. /**
  17321. * Interpolates between two quaternions and stores it into a target quaternion
  17322. * @param left defines first quaternion
  17323. * @param right defines second quaternion
  17324. * @param amount defines the gradient to use
  17325. * @param result defines the target quaternion
  17326. */
  17327. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17328. /**
  17329. * Interpolate between two quaternions using Hermite interpolation
  17330. * @param value1 defines first quaternion
  17331. * @param tangent1 defines the incoming tangent
  17332. * @param value2 defines second quaternion
  17333. * @param tangent2 defines the outgoing tangent
  17334. * @param amount defines the target quaternion
  17335. * @returns the new interpolated quaternion
  17336. */
  17337. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17338. }
  17339. /**
  17340. * Class used to store matrix data (4x4)
  17341. */
  17342. class Matrix {
  17343. private static _tempQuaternion;
  17344. private static _xAxis;
  17345. private static _yAxis;
  17346. private static _zAxis;
  17347. private static _updateFlagSeed;
  17348. private static _identityReadOnly;
  17349. private _isIdentity;
  17350. private _isIdentityDirty;
  17351. /**
  17352. * Gets the update flag of the matrix which is an unique number for the matrix.
  17353. * It will be incremented every time the matrix data change.
  17354. * You can use it to speed the comparison between two versions of the same matrix.
  17355. */
  17356. updateFlag: number;
  17357. /**
  17358. * Gets or sets the internal data of the matrix
  17359. */
  17360. m: Float32Array;
  17361. /** @hidden */
  17362. _markAsUpdated(): void;
  17363. /**
  17364. * Creates an empty matrix (filled with zeros)
  17365. */
  17366. constructor();
  17367. /**
  17368. * Check if the current matrix is indentity
  17369. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17370. * @returns true is the matrix is the identity matrix
  17371. */
  17372. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17373. /**
  17374. * Gets the determinant of the matrix
  17375. * @returns the matrix determinant
  17376. */
  17377. determinant(): number;
  17378. /**
  17379. * Returns the matrix as a Float32Array
  17380. * @returns the matrix underlying array
  17381. */
  17382. toArray(): Float32Array;
  17383. /**
  17384. * Returns the matrix as a Float32Array
  17385. * @returns the matrix underlying array.
  17386. */
  17387. asArray(): Float32Array;
  17388. /**
  17389. * Inverts the current matrix in place
  17390. * @returns the current inverted matrix
  17391. */
  17392. invert(): Matrix;
  17393. /**
  17394. * Sets all the matrix elements to zero
  17395. * @returns the current matrix
  17396. */
  17397. reset(): Matrix;
  17398. /**
  17399. * Adds the current matrix with a second one
  17400. * @param other defines the matrix to add
  17401. * @returns a new matrix as the addition of the current matrix and the given one
  17402. */
  17403. add(other: Matrix): Matrix;
  17404. /**
  17405. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17406. * @param other defines the matrix to add
  17407. * @param result defines the target matrix
  17408. * @returns the current matrix
  17409. */
  17410. addToRef(other: Matrix, result: Matrix): Matrix;
  17411. /**
  17412. * Adds in place the given matrix to the current matrix
  17413. * @param other defines the second operand
  17414. * @returns the current updated matrix
  17415. */
  17416. addToSelf(other: Matrix): Matrix;
  17417. /**
  17418. * Sets the given matrix to the current inverted Matrix
  17419. * @param other defines the target matrix
  17420. * @returns the unmodified current matrix
  17421. */
  17422. invertToRef(other: Matrix): Matrix;
  17423. /**
  17424. * Inserts the translation vector (using 3 floats) in the current matrix
  17425. * @param x defines the 1st component of the translation
  17426. * @param y defines the 2nd component of the translation
  17427. * @param z defines the 3rd component of the translation
  17428. * @returns the current updated matrix
  17429. */
  17430. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17431. /**
  17432. * Inserts the translation vector in the current matrix
  17433. * @param vector3 defines the translation to insert
  17434. * @returns the current updated matrix
  17435. */
  17436. setTranslation(vector3: Vector3): Matrix;
  17437. /**
  17438. * Gets the translation value of the current matrix
  17439. * @returns a new Vector3 as the extracted translation from the matrix
  17440. */
  17441. getTranslation(): Vector3;
  17442. /**
  17443. * Fill a Vector3 with the extracted translation from the matrix
  17444. * @param result defines the Vector3 where to store the translation
  17445. * @returns the current matrix
  17446. */
  17447. getTranslationToRef(result: Vector3): Matrix;
  17448. /**
  17449. * Remove rotation and scaling part from the matrix
  17450. * @returns the updated matrix
  17451. */
  17452. removeRotationAndScaling(): Matrix;
  17453. /**
  17454. * Multiply two matrices
  17455. * @param other defines the second operand
  17456. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17457. */
  17458. multiply(other: Matrix): Matrix;
  17459. /**
  17460. * Copy the current matrix from the given one
  17461. * @param other defines the source matrix
  17462. * @returns the current updated matrix
  17463. */
  17464. copyFrom(other: Matrix): Matrix;
  17465. /**
  17466. * Populates the given array from the starting index with the current matrix values
  17467. * @param array defines the target array
  17468. * @param offset defines the offset in the target array where to start storing values
  17469. * @returns the current matrix
  17470. */
  17471. copyToArray(array: Float32Array, offset?: number): Matrix;
  17472. /**
  17473. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17474. * @param other defines the second operand
  17475. * @param result defines the matrix where to store the multiplication
  17476. * @returns the current matrix
  17477. */
  17478. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17479. /**
  17480. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17481. * @param other defines the second operand
  17482. * @param result defines the array where to store the multiplication
  17483. * @param offset defines the offset in the target array where to start storing values
  17484. * @returns the current matrix
  17485. */
  17486. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17487. /**
  17488. * Check equality between this matrix and a second one
  17489. * @param value defines the second matrix to compare
  17490. * @returns true is the current matrix and the given one values are strictly equal
  17491. */
  17492. equals(value: Matrix): boolean;
  17493. /**
  17494. * Clone the current matrix
  17495. * @returns a new matrix from the current matrix
  17496. */
  17497. clone(): Matrix;
  17498. /**
  17499. * Returns the name of the current matrix class
  17500. * @returns the string "Matrix"
  17501. */
  17502. getClassName(): string;
  17503. /**
  17504. * Gets the hash code of the current matrix
  17505. * @returns the hash code
  17506. */
  17507. getHashCode(): number;
  17508. /**
  17509. * Decomposes the current Matrix into a translation, rotation and scaling components
  17510. * @param scale defines the scale vector3 given as a reference to update
  17511. * @param rotation defines the rotation quaternion given as a reference to update
  17512. * @param translation defines the translation vector3 given as a reference to update
  17513. * @returns true if operation was successful
  17514. */
  17515. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17516. /**
  17517. * Gets specific row of the matrix
  17518. * @param index defines the number of the row to get
  17519. * @returns the index-th row of the current matrix as a new Vector4
  17520. */
  17521. getRow(index: number): Nullable<Vector4>;
  17522. /**
  17523. * Sets the index-th row of the current matrix to the vector4 values
  17524. * @param index defines the number of the row to set
  17525. * @param row defines the target vector4
  17526. * @returns the updated current matrix
  17527. */
  17528. setRow(index: number, row: Vector4): Matrix;
  17529. /**
  17530. * Compute the transpose of the matrix
  17531. * @returns the new transposed matrix
  17532. */
  17533. transpose(): Matrix;
  17534. /**
  17535. * Compute the transpose of the matrix and store it in a given matrix
  17536. * @param result defines the target matrix
  17537. * @returns the current matrix
  17538. */
  17539. transposeToRef(result: Matrix): Matrix;
  17540. /**
  17541. * Sets the index-th row of the current matrix with the given 4 x float values
  17542. * @param index defines the row index
  17543. * @param x defines the x component to set
  17544. * @param y defines the y component to set
  17545. * @param z defines the z component to set
  17546. * @param w defines the w component to set
  17547. * @returns the updated current matrix
  17548. */
  17549. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17550. /**
  17551. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17552. * @param scale defines the scale factor
  17553. * @returns a new matrix
  17554. */
  17555. scale(scale: number): Matrix;
  17556. /**
  17557. * Scale the current matrix values by a factor to a given result matrix
  17558. * @param scale defines the scale factor
  17559. * @param result defines the matrix to store the result
  17560. * @returns the current matrix
  17561. */
  17562. scaleToRef(scale: number, result: Matrix): Matrix;
  17563. /**
  17564. * Scale the current matrix values by a factor and add the result to a given matrix
  17565. * @param scale defines the scale factor
  17566. * @param result defines the Matrix to store the result
  17567. * @returns the current matrix
  17568. */
  17569. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17570. /**
  17571. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17572. * @param ref matrix to store the result
  17573. */
  17574. toNormalMatrix(ref: Matrix): void;
  17575. /**
  17576. * Gets only rotation part of the current matrix
  17577. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17578. */
  17579. getRotationMatrix(): Matrix;
  17580. /**
  17581. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17582. * @param result defines the target matrix to store data to
  17583. * @returns the current matrix
  17584. */
  17585. getRotationMatrixToRef(result: Matrix): Matrix;
  17586. /**
  17587. * Creates a matrix from an array
  17588. * @param array defines the source array
  17589. * @param offset defines an offset in the source array
  17590. * @returns a new Matrix set from the starting index of the given array
  17591. */
  17592. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17593. /**
  17594. * Copy the content of an array into a given matrix
  17595. * @param array defines the source array
  17596. * @param offset defines an offset in the source array
  17597. * @param result defines the target matrix
  17598. */
  17599. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17600. /**
  17601. * Stores an array into a matrix after having multiplied each component by a given factor
  17602. * @param array defines the source array
  17603. * @param offset defines the offset in the source array
  17604. * @param scale defines the scaling factor
  17605. * @param result defines the target matrix
  17606. */
  17607. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17608. /**
  17609. * Stores a list of values (16) inside a given matrix
  17610. * @param initialM11 defines 1st value of 1st row
  17611. * @param initialM12 defines 2nd value of 1st row
  17612. * @param initialM13 defines 3rd value of 1st row
  17613. * @param initialM14 defines 4th value of 1st row
  17614. * @param initialM21 defines 1st value of 2nd row
  17615. * @param initialM22 defines 2nd value of 2nd row
  17616. * @param initialM23 defines 3rd value of 2nd row
  17617. * @param initialM24 defines 4th value of 2nd row
  17618. * @param initialM31 defines 1st value of 3rd row
  17619. * @param initialM32 defines 2nd value of 3rd row
  17620. * @param initialM33 defines 3rd value of 3rd row
  17621. * @param initialM34 defines 4th value of 3rd row
  17622. * @param initialM41 defines 1st value of 4th row
  17623. * @param initialM42 defines 2nd value of 4th row
  17624. * @param initialM43 defines 3rd value of 4th row
  17625. * @param initialM44 defines 4th value of 4th row
  17626. * @param result defines the target matrix
  17627. */
  17628. 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;
  17629. /**
  17630. * Gets an identity matrix that must not be updated
  17631. */
  17632. static readonly IdentityReadOnly: Matrix;
  17633. /**
  17634. * Creates new matrix from a list of values (16)
  17635. * @param initialM11 defines 1st value of 1st row
  17636. * @param initialM12 defines 2nd value of 1st row
  17637. * @param initialM13 defines 3rd value of 1st row
  17638. * @param initialM14 defines 4th value of 1st row
  17639. * @param initialM21 defines 1st value of 2nd row
  17640. * @param initialM22 defines 2nd value of 2nd row
  17641. * @param initialM23 defines 3rd value of 2nd row
  17642. * @param initialM24 defines 4th value of 2nd row
  17643. * @param initialM31 defines 1st value of 3rd row
  17644. * @param initialM32 defines 2nd value of 3rd row
  17645. * @param initialM33 defines 3rd value of 3rd row
  17646. * @param initialM34 defines 4th value of 3rd row
  17647. * @param initialM41 defines 1st value of 4th row
  17648. * @param initialM42 defines 2nd value of 4th row
  17649. * @param initialM43 defines 3rd value of 4th row
  17650. * @param initialM44 defines 4th value of 4th row
  17651. * @returns the new matrix
  17652. */
  17653. 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;
  17654. /**
  17655. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17656. * @param scale defines the scale vector3
  17657. * @param rotation defines the rotation quaternion
  17658. * @param translation defines the translation vector3
  17659. * @returns a new matrix
  17660. */
  17661. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17662. /**
  17663. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17664. * @param scale defines the scale vector3
  17665. * @param rotation defines the rotation quaternion
  17666. * @param translation defines the translation vector3
  17667. * @param result defines the target matrix
  17668. */
  17669. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17670. /**
  17671. * Creates a new identity matrix
  17672. * @returns a new identity matrix
  17673. */
  17674. static Identity(): Matrix;
  17675. /**
  17676. * Creates a new identity matrix and stores the result in a given matrix
  17677. * @param result defines the target matrix
  17678. */
  17679. static IdentityToRef(result: Matrix): void;
  17680. /**
  17681. * Creates a new zero matrix
  17682. * @returns a new zero matrix
  17683. */
  17684. static Zero(): Matrix;
  17685. /**
  17686. * Creates a new rotation matrix for "angle" radians around the X axis
  17687. * @param angle defines the angle (in radians) to use
  17688. * @return the new matrix
  17689. */
  17690. static RotationX(angle: number): Matrix;
  17691. /**
  17692. * Creates a new matrix as the invert of a given matrix
  17693. * @param source defines the source matrix
  17694. * @returns the new matrix
  17695. */
  17696. static Invert(source: Matrix): Matrix;
  17697. /**
  17698. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17699. * @param angle defines the angle (in radians) to use
  17700. * @param result defines the target matrix
  17701. */
  17702. static RotationXToRef(angle: number, result: Matrix): void;
  17703. /**
  17704. * Creates a new rotation matrix for "angle" radians around the Y axis
  17705. * @param angle defines the angle (in radians) to use
  17706. * @return the new matrix
  17707. */
  17708. static RotationY(angle: number): Matrix;
  17709. /**
  17710. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17711. * @param angle defines the angle (in radians) to use
  17712. * @param result defines the target matrix
  17713. */
  17714. static RotationYToRef(angle: number, result: Matrix): void;
  17715. /**
  17716. * Creates a new rotation matrix for "angle" radians around the Z axis
  17717. * @param angle defines the angle (in radians) to use
  17718. * @return the new matrix
  17719. */
  17720. static RotationZ(angle: number): Matrix;
  17721. /**
  17722. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17723. * @param angle defines the angle (in radians) to use
  17724. * @param result defines the target matrix
  17725. */
  17726. static RotationZToRef(angle: number, result: Matrix): void;
  17727. /**
  17728. * Creates a new rotation matrix for "angle" radians around the given axis
  17729. * @param axis defines the axis to use
  17730. * @param angle defines the angle (in radians) to use
  17731. * @return the new matrix
  17732. */
  17733. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17734. /**
  17735. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17736. * @param axis defines the axis to use
  17737. * @param angle defines the angle (in radians) to use
  17738. * @param result defines the target matrix
  17739. */
  17740. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17741. /**
  17742. * Creates a rotation matrix
  17743. * @param yaw defines the yaw angle in radians (Y axis)
  17744. * @param pitch defines the pitch angle in radians (X axis)
  17745. * @param roll defines the roll angle in radians (X axis)
  17746. * @returns the new rotation matrix
  17747. */
  17748. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17749. /**
  17750. * Creates a rotation matrix and stores it in a given matrix
  17751. * @param yaw defines the yaw angle in radians (Y axis)
  17752. * @param pitch defines the pitch angle in radians (X axis)
  17753. * @param roll defines the roll angle in radians (X axis)
  17754. * @param result defines the target matrix
  17755. */
  17756. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17757. /**
  17758. * Creates a scaling matrix
  17759. * @param x defines the scale factor on X axis
  17760. * @param y defines the scale factor on Y axis
  17761. * @param z defines the scale factor on Z axis
  17762. * @returns the new matrix
  17763. */
  17764. static Scaling(x: number, y: number, z: number): Matrix;
  17765. /**
  17766. * Creates a scaling matrix and stores it in a given matrix
  17767. * @param x defines the scale factor on X axis
  17768. * @param y defines the scale factor on Y axis
  17769. * @param z defines the scale factor on Z axis
  17770. * @param result defines the target matrix
  17771. */
  17772. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17773. /**
  17774. * Creates a translation matrix
  17775. * @param x defines the translation on X axis
  17776. * @param y defines the translation on Y axis
  17777. * @param z defines the translationon Z axis
  17778. * @returns the new matrix
  17779. */
  17780. static Translation(x: number, y: number, z: number): Matrix;
  17781. /**
  17782. * Creates a translation matrix and stores it in a given matrix
  17783. * @param x defines the translation on X axis
  17784. * @param y defines the translation on Y axis
  17785. * @param z defines the translationon Z axis
  17786. * @param result defines the target matrix
  17787. */
  17788. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17789. /**
  17790. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17791. * @param startValue defines the start value
  17792. * @param endValue defines the end value
  17793. * @param gradient defines the gradient factor
  17794. * @returns the new matrix
  17795. */
  17796. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17797. /**
  17798. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17799. * @param startValue defines the start value
  17800. * @param endValue defines the end value
  17801. * @param gradient defines the gradient factor
  17802. * @param result defines the Matrix object where to store data
  17803. */
  17804. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17805. /**
  17806. * Builds a new matrix whose values are computed by:
  17807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17810. * @param startValue defines the first matrix
  17811. * @param endValue defines the second matrix
  17812. * @param gradient defines the gradient between the two matrices
  17813. * @returns the new matrix
  17814. */
  17815. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17816. /**
  17817. * Update a matrix to values which are computed by:
  17818. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17819. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17820. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17821. * @param startValue defines the first matrix
  17822. * @param endValue defines the second matrix
  17823. * @param gradient defines the gradient between the two matrices
  17824. * @param result defines the target matrix
  17825. */
  17826. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17827. /**
  17828. * 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"
  17829. * This function works in left handed mode
  17830. * @param eye defines the final position of the entity
  17831. * @param target defines where the entity should look at
  17832. * @param up defines the up vector for the entity
  17833. * @returns the new matrix
  17834. */
  17835. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17836. /**
  17837. * 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".
  17838. * This function works in left handed mode
  17839. * @param eye defines the final position of the entity
  17840. * @param target defines where the entity should look at
  17841. * @param up defines the up vector for the entity
  17842. * @param result defines the target matrix
  17843. */
  17844. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17845. /**
  17846. * 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"
  17847. * This function works in right handed mode
  17848. * @param eye defines the final position of the entity
  17849. * @param target defines where the entity should look at
  17850. * @param up defines the up vector for the entity
  17851. * @returns the new matrix
  17852. */
  17853. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17854. /**
  17855. * 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".
  17856. * This function works in right handed mode
  17857. * @param eye defines the final position of the entity
  17858. * @param target defines where the entity should look at
  17859. * @param up defines the up vector for the entity
  17860. * @param result defines the target matrix
  17861. */
  17862. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17863. /**
  17864. * Create a left-handed orthographic projection matrix
  17865. * @param width defines the viewport width
  17866. * @param height defines the viewport height
  17867. * @param znear defines the near clip plane
  17868. * @param zfar defines the far clip plane
  17869. * @returns a new matrix as a left-handed orthographic projection matrix
  17870. */
  17871. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17872. /**
  17873. * Store a left-handed orthographic projection to a given matrix
  17874. * @param width defines the viewport width
  17875. * @param height defines the viewport height
  17876. * @param znear defines the near clip plane
  17877. * @param zfar defines the far clip plane
  17878. * @param result defines the target matrix
  17879. */
  17880. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17881. /**
  17882. * Create a left-handed orthographic projection matrix
  17883. * @param left defines the viewport left coordinate
  17884. * @param right defines the viewport right coordinate
  17885. * @param bottom defines the viewport bottom coordinate
  17886. * @param top defines the viewport top coordinate
  17887. * @param znear defines the near clip plane
  17888. * @param zfar defines the far clip plane
  17889. * @returns a new matrix as a left-handed orthographic projection matrix
  17890. */
  17891. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17892. /**
  17893. * Stores a left-handed orthographic projection into a given matrix
  17894. * @param left defines the viewport left coordinate
  17895. * @param right defines the viewport right coordinate
  17896. * @param bottom defines the viewport bottom coordinate
  17897. * @param top defines the viewport top coordinate
  17898. * @param znear defines the near clip plane
  17899. * @param zfar defines the far clip plane
  17900. * @param result defines the target matrix
  17901. */
  17902. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17903. /**
  17904. * Creates a right-handed orthographic projection matrix
  17905. * @param left defines the viewport left coordinate
  17906. * @param right defines the viewport right coordinate
  17907. * @param bottom defines the viewport bottom coordinate
  17908. * @param top defines the viewport top coordinate
  17909. * @param znear defines the near clip plane
  17910. * @param zfar defines the far clip plane
  17911. * @returns a new matrix as a right-handed orthographic projection matrix
  17912. */
  17913. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17914. /**
  17915. * Stores a right-handed orthographic projection into a given matrix
  17916. * @param left defines the viewport left coordinate
  17917. * @param right defines the viewport right coordinate
  17918. * @param bottom defines the viewport bottom coordinate
  17919. * @param top defines the viewport top coordinate
  17920. * @param znear defines the near clip plane
  17921. * @param zfar defines the far clip plane
  17922. * @param result defines the target matrix
  17923. */
  17924. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17925. /**
  17926. * Creates a left-handed perspective projection matrix
  17927. * @param width defines the viewport width
  17928. * @param height defines the viewport height
  17929. * @param znear defines the near clip plane
  17930. * @param zfar defines the far clip plane
  17931. * @returns a new matrix as a left-handed perspective projection matrix
  17932. */
  17933. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17934. /**
  17935. * Creates a left-handed perspective projection matrix
  17936. * @param fov defines the horizontal field of view
  17937. * @param aspect defines the aspect ratio
  17938. * @param znear defines the near clip plane
  17939. * @param zfar defines the far clip plane
  17940. * @returns a new matrix as a left-handed perspective projection matrix
  17941. */
  17942. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17943. /**
  17944. * Stores a left-handed perspective projection into a given matrix
  17945. * @param fov defines the horizontal field of view
  17946. * @param aspect defines the aspect ratio
  17947. * @param znear defines the near clip plane
  17948. * @param zfar defines the far clip plane
  17949. * @param result defines the target matrix
  17950. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17951. */
  17952. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17953. /**
  17954. * Creates a right-handed perspective projection matrix
  17955. * @param fov defines the horizontal field of view
  17956. * @param aspect defines the aspect ratio
  17957. * @param znear defines the near clip plane
  17958. * @param zfar defines the far clip plane
  17959. * @returns a new matrix as a right-handed perspective projection matrix
  17960. */
  17961. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17962. /**
  17963. * Stores a right-handed perspective projection into a given matrix
  17964. * @param fov defines the horizontal field of view
  17965. * @param aspect defines the aspect ratio
  17966. * @param znear defines the near clip plane
  17967. * @param zfar defines the far clip plane
  17968. * @param result defines the target matrix
  17969. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17970. */
  17971. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17972. /**
  17973. * Stores a perspective projection for WebVR info a given matrix
  17974. * @param fov defines the field of view
  17975. * @param znear defines the near clip plane
  17976. * @param zfar defines the far clip plane
  17977. * @param result defines the target matrix
  17978. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17979. */
  17980. static PerspectiveFovWebVRToRef(fov: {
  17981. upDegrees: number;
  17982. downDegrees: number;
  17983. leftDegrees: number;
  17984. rightDegrees: number;
  17985. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17986. /**
  17987. * Computes a complete transformation matrix
  17988. * @param viewport defines the viewport to use
  17989. * @param world defines the world matrix
  17990. * @param view defines the view matrix
  17991. * @param projection defines the projection matrix
  17992. * @param zmin defines the near clip plane
  17993. * @param zmax defines the far clip plane
  17994. * @returns the transformation matrix
  17995. */
  17996. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17997. /**
  17998. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17999. * @param matrix defines the matrix to use
  18000. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18001. */
  18002. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18003. /**
  18004. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18005. * @param matrix defines the matrix to use
  18006. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18007. */
  18008. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18009. /**
  18010. * Compute the transpose of a given matrix
  18011. * @param matrix defines the matrix to transpose
  18012. * @returns the new matrix
  18013. */
  18014. static Transpose(matrix: Matrix): Matrix;
  18015. /**
  18016. * Compute the transpose of a matrix and store it in a target matrix
  18017. * @param matrix defines the matrix to transpose
  18018. * @param result defines the target matrix
  18019. */
  18020. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18021. /**
  18022. * Computes a reflection matrix from a plane
  18023. * @param plane defines the reflection plane
  18024. * @returns a new matrix
  18025. */
  18026. static Reflection(plane: Plane): Matrix;
  18027. /**
  18028. * Computes a reflection matrix from a plane
  18029. * @param plane defines the reflection plane
  18030. * @param result defines the target matrix
  18031. */
  18032. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18033. /**
  18034. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18035. * @param xaxis defines the value of the 1st axis
  18036. * @param yaxis defines the value of the 2nd axis
  18037. * @param zaxis defines the value of the 3rd axis
  18038. * @param result defines the target matrix
  18039. */
  18040. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18041. /**
  18042. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18043. * @param quat defines the quaternion to use
  18044. * @param result defines the target matrix
  18045. */
  18046. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18047. }
  18048. class Plane {
  18049. normal: Vector3;
  18050. d: number;
  18051. /**
  18052. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18053. */
  18054. constructor(a: number, b: number, c: number, d: number);
  18055. /**
  18056. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18057. */
  18058. asArray(): number[];
  18059. /**
  18060. * Returns a new plane copied from the current Plane.
  18061. */
  18062. clone(): Plane;
  18063. /**
  18064. * Returns the string "Plane".
  18065. */
  18066. getClassName(): string;
  18067. /**
  18068. * Returns the Plane hash code.
  18069. */
  18070. getHashCode(): number;
  18071. /**
  18072. * Normalize the current Plane in place.
  18073. * Returns the updated Plane.
  18074. */
  18075. normalize(): Plane;
  18076. /**
  18077. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18078. */
  18079. transform(transformation: Matrix): Plane;
  18080. /**
  18081. * Returns the dot product (float) of the point coordinates and the plane normal.
  18082. */
  18083. dotCoordinate(point: Vector3): number;
  18084. /**
  18085. * Updates the current Plane from the plane defined by the three given points.
  18086. * Returns the updated Plane.
  18087. */
  18088. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18089. /**
  18090. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18091. */
  18092. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18093. /**
  18094. * Returns the signed distance (float) from the given point to the Plane.
  18095. */
  18096. signedDistanceTo(point: Vector3): number;
  18097. /**
  18098. * Returns a new Plane from the given array.
  18099. */
  18100. static FromArray(array: ArrayLike<number>): Plane;
  18101. /**
  18102. * Returns a new Plane defined by the three given points.
  18103. */
  18104. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18105. /**
  18106. * Returns a new Plane the normal vector to this plane at the given origin point.
  18107. * Note : the vector "normal" is updated because normalized.
  18108. */
  18109. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18110. /**
  18111. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18112. */
  18113. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18114. }
  18115. class Viewport {
  18116. x: number;
  18117. y: number;
  18118. width: number;
  18119. height: number;
  18120. /**
  18121. * Creates a Viewport object located at (x, y) and sized (width, height).
  18122. */
  18123. constructor(x: number, y: number, width: number, height: number);
  18124. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18125. /**
  18126. * Returns a new Viewport copied from the current one.
  18127. */
  18128. clone(): Viewport;
  18129. }
  18130. class Frustum {
  18131. /**
  18132. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18133. */
  18134. static GetPlanes(transform: Matrix): Plane[];
  18135. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18136. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18137. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18138. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18139. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18140. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18141. /**
  18142. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18143. */
  18144. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18145. }
  18146. /** Defines supported spaces */
  18147. enum Space {
  18148. /** Local (object) space */
  18149. LOCAL = 0,
  18150. /** World space */
  18151. WORLD = 1,
  18152. /** Bone space */
  18153. BONE = 2,
  18154. }
  18155. /** Defines the 3 main axes */
  18156. class Axis {
  18157. /** X axis */
  18158. static X: Vector3;
  18159. /** Y axis */
  18160. static Y: Vector3;
  18161. /** Z axis */
  18162. static Z: Vector3;
  18163. }
  18164. class BezierCurve {
  18165. /**
  18166. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18167. */
  18168. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18169. }
  18170. /**
  18171. * Defines potential orientation for back face culling
  18172. */
  18173. enum Orientation {
  18174. /**
  18175. * Clockwise
  18176. */
  18177. CW = 0,
  18178. /** Counter clockwise */
  18179. CCW = 1,
  18180. }
  18181. /**
  18182. * Defines angle representation
  18183. */
  18184. class Angle {
  18185. private _radians;
  18186. /**
  18187. * Creates an Angle object of "radians" radians (float).
  18188. */
  18189. constructor(radians: number);
  18190. /**
  18191. * Get value in degrees
  18192. * @returns the Angle value in degrees (float)
  18193. */
  18194. degrees(): number;
  18195. /**
  18196. * Get value in radians
  18197. * @returns the Angle value in radians (float)
  18198. */
  18199. radians(): number;
  18200. /**
  18201. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18202. * @param a defines first vector
  18203. * @param b defines second vector
  18204. * @returns a new Angle
  18205. */
  18206. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18207. /**
  18208. * Gets a new Angle object from the given float in radians
  18209. * @param radians defines the angle value in radians
  18210. * @returns a new Angle
  18211. */
  18212. static FromRadians(radians: number): Angle;
  18213. /**
  18214. * Gets a new Angle object from the given float in degrees
  18215. * @param degrees defines the angle value in degrees
  18216. * @returns a new Angle
  18217. */
  18218. static FromDegrees(degrees: number): Angle;
  18219. }
  18220. class Arc2 {
  18221. startPoint: Vector2;
  18222. midPoint: Vector2;
  18223. endPoint: Vector2;
  18224. centerPoint: Vector2;
  18225. radius: number;
  18226. angle: Angle;
  18227. startAngle: Angle;
  18228. orientation: Orientation;
  18229. /**
  18230. * Creates an Arc object from the three given points : start, middle and end.
  18231. */
  18232. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18233. }
  18234. class Path2 {
  18235. private _points;
  18236. private _length;
  18237. closed: boolean;
  18238. /**
  18239. * Creates a Path2 object from the starting 2D coordinates x and y.
  18240. */
  18241. constructor(x: number, y: number);
  18242. /**
  18243. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18244. * Returns the updated Path2.
  18245. */
  18246. addLineTo(x: number, y: number): Path2;
  18247. /**
  18248. * 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.
  18249. * Returns the updated Path2.
  18250. */
  18251. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18252. /**
  18253. * Closes the Path2.
  18254. * Returns the Path2.
  18255. */
  18256. close(): Path2;
  18257. /**
  18258. * Returns the Path2 total length (float).
  18259. */
  18260. length(): number;
  18261. /**
  18262. * Returns the Path2 internal array of points.
  18263. */
  18264. getPoints(): Vector2[];
  18265. /**
  18266. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18267. */
  18268. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18269. /**
  18270. * Returns a new Path2 starting at the coordinates (x, y).
  18271. */
  18272. static StartingAt(x: number, y: number): Path2;
  18273. }
  18274. class Path3D {
  18275. path: Vector3[];
  18276. private _curve;
  18277. private _distances;
  18278. private _tangents;
  18279. private _normals;
  18280. private _binormals;
  18281. private _raw;
  18282. /**
  18283. * new Path3D(path, normal, raw)
  18284. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18285. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18286. * path : an array of Vector3, the curve axis of the Path3D
  18287. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18288. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18289. */
  18290. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18291. /**
  18292. * Returns the Path3D array of successive Vector3 designing its curve.
  18293. */
  18294. getCurve(): Vector3[];
  18295. /**
  18296. * Returns an array populated with tangent vectors on each Path3D curve point.
  18297. */
  18298. getTangents(): Vector3[];
  18299. /**
  18300. * Returns an array populated with normal vectors on each Path3D curve point.
  18301. */
  18302. getNormals(): Vector3[];
  18303. /**
  18304. * Returns an array populated with binormal vectors on each Path3D curve point.
  18305. */
  18306. getBinormals(): Vector3[];
  18307. /**
  18308. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18309. */
  18310. getDistances(): number[];
  18311. /**
  18312. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18313. * Returns the same object updated.
  18314. */
  18315. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18316. private _compute(firstNormal);
  18317. private _getFirstNonNullVector(index);
  18318. private _getLastNonNullVector(index);
  18319. private _normalVector(v0, vt, va);
  18320. }
  18321. class Curve3 {
  18322. private _points;
  18323. private _length;
  18324. /**
  18325. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18326. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18327. * @param v1 (Vector3) the control point
  18328. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18329. * @param nbPoints (integer) the wanted number of points in the curve
  18330. */
  18331. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18332. /**
  18333. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18334. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18335. * @param v1 (Vector3) the first control point
  18336. * @param v2 (Vector3) the second control point
  18337. * @param v3 (Vector3) the end point of the Cubic Bezier
  18338. * @param nbPoints (integer) the wanted number of points in the curve
  18339. */
  18340. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18341. /**
  18342. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18343. * @param p1 (Vector3) the origin point of the Hermite Spline
  18344. * @param t1 (Vector3) the tangent vector at the origin point
  18345. * @param p2 (Vector3) the end point of the Hermite Spline
  18346. * @param t2 (Vector3) the tangent vector at the end point
  18347. * @param nbPoints (integer) the wanted number of points in the curve
  18348. */
  18349. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18350. /**
  18351. * Returns a Curve3 object along a CatmullRom Spline curve :
  18352. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18353. * @param nbPoints (integer) the wanted number of points between each curve control points
  18354. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18355. */
  18356. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18357. /**
  18358. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18359. * A Curve3 is designed from a series of successive Vector3.
  18360. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18361. */
  18362. constructor(points: Vector3[]);
  18363. /**
  18364. * Returns the Curve3 stored array of successive Vector3
  18365. */
  18366. getPoints(): Vector3[];
  18367. /**
  18368. * Returns the computed length (float) of the curve.
  18369. */
  18370. length(): number;
  18371. /**
  18372. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18373. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18374. * curveA and curveB keep unchanged.
  18375. */
  18376. continue(curve: Curve3): Curve3;
  18377. private _computeLength(path);
  18378. }
  18379. class PositionNormalVertex {
  18380. position: Vector3;
  18381. normal: Vector3;
  18382. constructor(position?: Vector3, normal?: Vector3);
  18383. clone(): PositionNormalVertex;
  18384. }
  18385. class PositionNormalTextureVertex {
  18386. position: Vector3;
  18387. normal: Vector3;
  18388. uv: Vector2;
  18389. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18390. clone(): PositionNormalTextureVertex;
  18391. }
  18392. class Tmp {
  18393. static Color3: Color3[];
  18394. static Color4: Color4[];
  18395. static Vector2: Vector2[];
  18396. static Vector3: Vector3[];
  18397. static Vector4: Vector4[];
  18398. static Quaternion: Quaternion[];
  18399. static Matrix: Matrix[];
  18400. }
  18401. }
  18402. declare module BABYLON {
  18403. class SphericalPolynomial {
  18404. x: Vector3;
  18405. y: Vector3;
  18406. z: Vector3;
  18407. xx: Vector3;
  18408. yy: Vector3;
  18409. zz: Vector3;
  18410. xy: Vector3;
  18411. yz: Vector3;
  18412. zx: Vector3;
  18413. addAmbient(color: Color3): void;
  18414. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18415. scale(scale: number): void;
  18416. }
  18417. class SphericalHarmonics {
  18418. L00: Vector3;
  18419. L1_1: Vector3;
  18420. L10: Vector3;
  18421. L11: Vector3;
  18422. L2_2: Vector3;
  18423. L2_1: Vector3;
  18424. L20: Vector3;
  18425. L21: Vector3;
  18426. L22: Vector3;
  18427. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18428. scale(scale: number): void;
  18429. convertIncidentRadianceToIrradiance(): void;
  18430. convertIrradianceToLambertianRadiance(): void;
  18431. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18432. }
  18433. }
  18434. declare module BABYLON {
  18435. /**
  18436. * Defines a target to use with MorphTargetManager
  18437. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18438. */
  18439. class MorphTarget implements IAnimatable {
  18440. /** defines the name of the target */
  18441. name: string;
  18442. /**
  18443. * Gets or sets the list of animations
  18444. */
  18445. animations: Animation[];
  18446. private _scene;
  18447. private _positions;
  18448. private _normals;
  18449. private _tangents;
  18450. private _influence;
  18451. /**
  18452. * Observable raised when the influence changes
  18453. */
  18454. onInfluenceChanged: Observable<boolean>;
  18455. /**
  18456. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18457. */
  18458. influence: number;
  18459. private _animationPropertiesOverride;
  18460. /**
  18461. * Gets or sets the animation properties override
  18462. */
  18463. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18464. /**
  18465. * Creates a new MorphTarget
  18466. * @param name defines the name of the target
  18467. * @param influence defines the influence to use
  18468. */
  18469. constructor(
  18470. /** defines the name of the target */
  18471. name: string, influence?: number, scene?: Nullable<Scene>);
  18472. /**
  18473. * Gets a boolean defining if the target contains position data
  18474. */
  18475. readonly hasPositions: boolean;
  18476. /**
  18477. * Gets a boolean defining if the target contains normal data
  18478. */
  18479. readonly hasNormals: boolean;
  18480. /**
  18481. * Gets a boolean defining if the target contains tangent data
  18482. */
  18483. readonly hasTangents: boolean;
  18484. /**
  18485. * Affects position data to this target
  18486. * @param data defines the position data to use
  18487. */
  18488. setPositions(data: Nullable<FloatArray>): void;
  18489. /**
  18490. * Gets the position data stored in this target
  18491. * @returns a FloatArray containing the position data (or null if not present)
  18492. */
  18493. getPositions(): Nullable<FloatArray>;
  18494. /**
  18495. * Affects normal data to this target
  18496. * @param data defines the normal data to use
  18497. */
  18498. setNormals(data: Nullable<FloatArray>): void;
  18499. /**
  18500. * Gets the normal data stored in this target
  18501. * @returns a FloatArray containing the normal data (or null if not present)
  18502. */
  18503. getNormals(): Nullable<FloatArray>;
  18504. /**
  18505. * Affects tangent data to this target
  18506. * @param data defines the tangent data to use
  18507. */
  18508. setTangents(data: Nullable<FloatArray>): void;
  18509. /**
  18510. * Gets the tangent data stored in this target
  18511. * @returns a FloatArray containing the tangent data (or null if not present)
  18512. */
  18513. getTangents(): Nullable<FloatArray>;
  18514. /**
  18515. * Serializes the current target into a Serialization object
  18516. * @returns the serialized object
  18517. */
  18518. serialize(): any;
  18519. /**
  18520. * Creates a new target from serialized data
  18521. * @param serializationObject defines the serialized data to use
  18522. * @returns a new MorphTarget
  18523. */
  18524. static Parse(serializationObject: any): MorphTarget;
  18525. /**
  18526. * Creates a MorphTarget from mesh data
  18527. * @param mesh defines the source mesh
  18528. * @param name defines the name to use for the new target
  18529. * @param influence defines the influence to attach to the target
  18530. * @returns a new MorphTarget
  18531. */
  18532. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18533. }
  18534. }
  18535. declare module BABYLON {
  18536. /**
  18537. * This class is used to deform meshes using morphing between different targets
  18538. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18539. */
  18540. class MorphTargetManager {
  18541. private _targets;
  18542. private _targetObservable;
  18543. private _activeTargets;
  18544. private _scene;
  18545. private _influences;
  18546. private _supportsNormals;
  18547. private _supportsTangents;
  18548. private _vertexCount;
  18549. private _uniqueId;
  18550. private _tempInfluences;
  18551. /**
  18552. * Creates a new MorphTargetManager
  18553. * @param scene defines the current scene
  18554. */
  18555. constructor(scene?: Nullable<Scene>);
  18556. /**
  18557. * Gets the unique ID of this manager
  18558. */
  18559. readonly uniqueId: number;
  18560. /**
  18561. * Gets the number of vertices handled by this manager
  18562. */
  18563. readonly vertexCount: number;
  18564. /**
  18565. * Gets a boolean indicating if this manager supports morphing of normals
  18566. */
  18567. readonly supportsNormals: boolean;
  18568. /**
  18569. * Gets a boolean indicating if this manager supports morphing of tangents
  18570. */
  18571. readonly supportsTangents: boolean;
  18572. /**
  18573. * Gets the number of targets stored in this manager
  18574. */
  18575. readonly numTargets: number;
  18576. /**
  18577. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18578. */
  18579. readonly numInfluencers: number;
  18580. /**
  18581. * Gets the list of influences (one per target)
  18582. */
  18583. readonly influences: Float32Array;
  18584. /**
  18585. * Gets the active target at specified index. An active target is a target with an influence > 0
  18586. * @param index defines the index to check
  18587. * @returns the requested target
  18588. */
  18589. getActiveTarget(index: number): MorphTarget;
  18590. /**
  18591. * Gets the target at specified index
  18592. * @param index defines the index to check
  18593. * @returns the requested target
  18594. */
  18595. getTarget(index: number): MorphTarget;
  18596. /**
  18597. * Add a new target to this manager
  18598. * @param target defines the target to add
  18599. */
  18600. addTarget(target: MorphTarget): void;
  18601. /**
  18602. * Removes a target from the manager
  18603. * @param target defines the target to remove
  18604. */
  18605. removeTarget(target: MorphTarget): void;
  18606. /**
  18607. * Serializes the current manager into a Serialization object
  18608. * @returns the serialized object
  18609. */
  18610. serialize(): any;
  18611. private _syncActiveTargets(needUpdate);
  18612. /**
  18613. * Syncrhonize the targets with all the meshes using this morph target manager
  18614. */
  18615. synchronize(): void;
  18616. /**
  18617. * Creates a new MorphTargetManager from serialized data
  18618. * @param serializationObject defines the serialized data
  18619. * @param scene defines the hosting scene
  18620. * @returns the new MorphTargetManager
  18621. */
  18622. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18623. }
  18624. }
  18625. declare module BABYLON {
  18626. /**
  18627. * Class used to store all common mesh properties
  18628. */
  18629. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18630. /** No occlusion */
  18631. static OCCLUSION_TYPE_NONE: number;
  18632. /** Occlusion set to optimisitic */
  18633. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18634. /** Occlusion set to strict */
  18635. static OCCLUSION_TYPE_STRICT: number;
  18636. /** Use an accurante occlusion algorithm */
  18637. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18638. /** Use a conservative occlusion algorithm */
  18639. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18640. /**
  18641. * No billboard
  18642. */
  18643. static readonly BILLBOARDMODE_NONE: number;
  18644. /** Billboard on X axis */
  18645. static readonly BILLBOARDMODE_X: number;
  18646. /** Billboard on Y axis */
  18647. static readonly BILLBOARDMODE_Y: number;
  18648. /** Billboard on Z axis */
  18649. static readonly BILLBOARDMODE_Z: number;
  18650. /** Billboard on all axes */
  18651. static readonly BILLBOARDMODE_ALL: number;
  18652. private _facetPositions;
  18653. private _facetNormals;
  18654. private _facetPartitioning;
  18655. private _facetNb;
  18656. private _partitioningSubdivisions;
  18657. private _partitioningBBoxRatio;
  18658. private _facetDataEnabled;
  18659. private _facetParameters;
  18660. private _bbSize;
  18661. private _subDiv;
  18662. private _facetDepthSort;
  18663. private _facetDepthSortEnabled;
  18664. private _depthSortedIndices;
  18665. private _depthSortedFacets;
  18666. private _facetDepthSortFunction;
  18667. private _facetDepthSortFrom;
  18668. private _facetDepthSortOrigin;
  18669. private _invertedMatrix;
  18670. /**
  18671. * Gets the number of facets in the mesh
  18672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18673. */
  18674. readonly facetNb: number;
  18675. /**
  18676. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18678. */
  18679. partitioningSubdivisions: number;
  18680. /**
  18681. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18682. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18684. */
  18685. partitioningBBoxRatio: number;
  18686. /**
  18687. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18688. * Works only for updatable meshes.
  18689. * Doesn't work with multi-materials
  18690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18691. */
  18692. mustDepthSortFacets: boolean;
  18693. /**
  18694. * The location (Vector3) where the facet depth sort must be computed from.
  18695. * By default, the active camera position.
  18696. * Used only when facet depth sort is enabled
  18697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18698. */
  18699. facetDepthSortFrom: Vector3;
  18700. /**
  18701. * gets a boolean indicating if facetData is enabled
  18702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18703. */
  18704. readonly isFacetDataEnabled: boolean;
  18705. /** @hidden */
  18706. _updateNonUniformScalingState(value: boolean): boolean;
  18707. /**
  18708. * An event triggered when this mesh collides with another one
  18709. */
  18710. onCollideObservable: Observable<AbstractMesh>;
  18711. private _onCollideObserver;
  18712. /** Set a function to call when this mesh collides with another one */
  18713. onCollide: () => void;
  18714. /**
  18715. * An event triggered when the collision's position changes
  18716. */
  18717. onCollisionPositionChangeObservable: Observable<Vector3>;
  18718. private _onCollisionPositionChangeObserver;
  18719. /** Set a function to call when the collision's position changes */
  18720. onCollisionPositionChange: () => void;
  18721. /**
  18722. * An event triggered when material is changed
  18723. */
  18724. onMaterialChangedObservable: Observable<AbstractMesh>;
  18725. /**
  18726. * Gets or sets the orientation for POV movement & rotation
  18727. */
  18728. definedFacingForward: boolean;
  18729. /**
  18730. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18731. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18732. * * 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.
  18733. * @see http://doc.babylonjs.com/features/occlusionquery
  18734. */
  18735. occlusionQueryAlgorithmType: number;
  18736. /**
  18737. * 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:
  18738. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18739. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18740. * * 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.
  18741. * @see http://doc.babylonjs.com/features/occlusionquery
  18742. */
  18743. occlusionType: number;
  18744. /**
  18745. * 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.
  18746. * The default value is -1 which means don't break the query and wait till the result
  18747. * @see http://doc.babylonjs.com/features/occlusionquery
  18748. */
  18749. occlusionRetryCount: number;
  18750. private _occlusionInternalRetryCounter;
  18751. protected _isOccluded: boolean;
  18752. /**
  18753. * 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
  18754. * @see http://doc.babylonjs.com/features/occlusionquery
  18755. */
  18756. isOccluded: boolean;
  18757. private _isOcclusionQueryInProgress;
  18758. /**
  18759. * Flag to check the progress status of the query
  18760. * @see http://doc.babylonjs.com/features/occlusionquery
  18761. */
  18762. readonly isOcclusionQueryInProgress: boolean;
  18763. private _occlusionQuery;
  18764. private _visibility;
  18765. /**
  18766. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18767. */
  18768. /**
  18769. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18770. */
  18771. visibility: number;
  18772. /** Gets or sets the alpha index used to sort transparent meshes
  18773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18774. */
  18775. alphaIndex: number;
  18776. /**
  18777. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18778. */
  18779. isVisible: boolean;
  18780. /**
  18781. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18782. */
  18783. isPickable: boolean;
  18784. /**
  18785. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18786. */
  18787. showBoundingBox: boolean;
  18788. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18789. showSubMeshesBoundingBox: boolean;
  18790. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18791. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18792. */
  18793. isBlocker: boolean;
  18794. /**
  18795. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18796. */
  18797. enablePointerMoveEvents: boolean;
  18798. /**
  18799. * Specifies the rendering group id for this mesh (0 by default)
  18800. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18801. */
  18802. renderingGroupId: number;
  18803. private _material;
  18804. /** Gets or sets current material */
  18805. material: Nullable<Material>;
  18806. private _receiveShadows;
  18807. /**
  18808. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18809. * @see http://doc.babylonjs.com/babylon101/shadows
  18810. */
  18811. receiveShadows: boolean;
  18812. /**
  18813. * Gets or sets a boolean indicating if the outline must be rendered as well
  18814. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18815. */
  18816. renderOutline: boolean;
  18817. /** Defines color to use when rendering outline */
  18818. outlineColor: Color3;
  18819. /** Define width to use when rendering outline */
  18820. outlineWidth: number;
  18821. /**
  18822. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18823. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18824. */
  18825. renderOverlay: boolean;
  18826. /** Defines color to use when rendering overlay */
  18827. overlayColor: Color3;
  18828. /** Defines alpha to use when rendering overlay */
  18829. overlayAlpha: number;
  18830. private _hasVertexAlpha;
  18831. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18832. hasVertexAlpha: boolean;
  18833. private _useVertexColors;
  18834. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  18835. useVertexColors: boolean;
  18836. private _computeBonesUsingShaders;
  18837. /**
  18838. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18839. */
  18840. computeBonesUsingShaders: boolean;
  18841. private _numBoneInfluencers;
  18842. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18843. numBoneInfluencers: number;
  18844. private _applyFog;
  18845. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18846. applyFog: boolean;
  18847. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18848. useOctreeForRenderingSelection: boolean;
  18849. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18850. useOctreeForPicking: boolean;
  18851. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18852. useOctreeForCollisions: boolean;
  18853. private _layerMask;
  18854. /**
  18855. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18856. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18857. */
  18858. layerMask: number;
  18859. /**
  18860. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18861. */
  18862. alwaysSelectAsActiveMesh: boolean;
  18863. /**
  18864. * Gets or sets the current action manager
  18865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18866. */
  18867. actionManager: Nullable<ActionManager>;
  18868. /**
  18869. * Gets or sets impostor used for physic simulation
  18870. * @see http://doc.babylonjs.com/features/physics_engine
  18871. */
  18872. physicsImpostor: Nullable<PhysicsImpostor>;
  18873. private _checkCollisions;
  18874. private _collisionMask;
  18875. private _collisionGroup;
  18876. /**
  18877. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18879. */
  18880. ellipsoid: Vector3;
  18881. /**
  18882. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18884. */
  18885. ellipsoidOffset: Vector3;
  18886. private _collider;
  18887. private _oldPositionForCollisions;
  18888. private _diffPositionForCollisions;
  18889. /**
  18890. * Gets or sets a collision mask used to mask collisions (default is -1).
  18891. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18892. */
  18893. collisionMask: number;
  18894. /**
  18895. * Gets or sets the current collision group mask (-1 by default).
  18896. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18897. */
  18898. collisionGroup: number;
  18899. /**
  18900. * Defines edge width used when edgesRenderer is enabled
  18901. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18902. */
  18903. edgesWidth: number;
  18904. /**
  18905. * Defines edge color used when edgesRenderer is enabled
  18906. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18907. */
  18908. edgesColor: Color4;
  18909. /** @hidden */
  18910. _edgesRenderer: Nullable<EdgesRenderer>;
  18911. private _collisionsTransformMatrix;
  18912. private _collisionsScalingMatrix;
  18913. /** @hidden */
  18914. _masterMesh: Nullable<AbstractMesh>;
  18915. /** @hidden */
  18916. _boundingInfo: Nullable<BoundingInfo>;
  18917. /** @hidden */
  18918. _renderId: number;
  18919. /**
  18920. * Gets or sets the list of subMeshes
  18921. * @see http://doc.babylonjs.com/how_to/multi_materials
  18922. */
  18923. subMeshes: SubMesh[];
  18924. /** @hidden */
  18925. _submeshesOctree: Octree<SubMesh>;
  18926. /** @hidden */
  18927. _intersectionsInProgress: AbstractMesh[];
  18928. /** @hidden */
  18929. _unIndexed: boolean;
  18930. /** @hidden */
  18931. _lightSources: Light[];
  18932. /** @hidden */
  18933. readonly _positions: Nullable<Vector3[]>;
  18934. /** @hidden */
  18935. _waitingActions: any;
  18936. /** @hidden */
  18937. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18938. private _skeleton;
  18939. /** @hidden */
  18940. _bonesTransformMatrices: Nullable<Float32Array>;
  18941. /**
  18942. * Gets or sets a skeleton to apply skining transformations
  18943. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18944. */
  18945. skeleton: Nullable<Skeleton>;
  18946. /**
  18947. * Creates a new AbstractMesh
  18948. * @param name defines the name of the mesh
  18949. * @param scene defines the hosting scene
  18950. */
  18951. constructor(name: string, scene?: Nullable<Scene>);
  18952. /**
  18953. * Returns the string "AbstractMesh"
  18954. * @returns "AbstractMesh"
  18955. */
  18956. getClassName(): string;
  18957. /**
  18958. * Gets a string representation of the current mesh
  18959. * @param fullDetails defines a boolean indicating if full details must be included
  18960. * @returns a string representation of the current mesh
  18961. */
  18962. toString(fullDetails?: boolean): string;
  18963. /** @hidden */
  18964. _rebuild(): void;
  18965. /** @hidden */
  18966. _resyncLightSources(): void;
  18967. /** @hidden */
  18968. _resyncLighSource(light: Light): void;
  18969. /** @hidden */
  18970. _unBindEffect(): void;
  18971. /** @hidden */
  18972. _removeLightSource(light: Light): void;
  18973. private _markSubMeshesAsDirty(func);
  18974. /** @hidden */
  18975. _markSubMeshesAsLightDirty(): void;
  18976. /** @hidden */
  18977. _markSubMeshesAsAttributesDirty(): void;
  18978. /** @hidden */
  18979. _markSubMeshesAsMiscDirty(): void;
  18980. /**
  18981. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18982. */
  18983. scaling: Vector3;
  18984. /**
  18985. * Disables the mesh edge rendering mode
  18986. * @returns the currentAbstractMesh
  18987. */
  18988. disableEdgesRendering(): AbstractMesh;
  18989. /**
  18990. * Enables the edge rendering mode on the mesh.
  18991. * This mode makes the mesh edges visible
  18992. * @param epsilon defines the maximal distance between two angles to detect a face
  18993. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18994. * @returns the currentAbstractMesh
  18995. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18996. */
  18997. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18998. /**
  18999. * Gets the edgesRenderer associated with the mesh
  19000. */
  19001. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19002. /**
  19003. * Returns true if the mesh is blocked. Implemented by child classes
  19004. */
  19005. readonly isBlocked: boolean;
  19006. /**
  19007. * Returns the mesh itself by default. Implemented by child classes
  19008. * @param camera defines the camera to use to pick the right LOD level
  19009. * @returns the currentAbstractMesh
  19010. */
  19011. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19012. /**
  19013. * Returns 0 by default. Implemented by child classes
  19014. * @returns an integer
  19015. */
  19016. getTotalVertices(): number;
  19017. /**
  19018. * Returns null by default. Implemented by child classes
  19019. * @returns null
  19020. */
  19021. getIndices(): Nullable<IndicesArray>;
  19022. /**
  19023. * Returns the array of the requested vertex data kind. Implemented by child classes
  19024. * @param kind defines the vertex data kind to use
  19025. * @returns null
  19026. */
  19027. getVerticesData(kind: string): Nullable<FloatArray>;
  19028. /**
  19029. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19030. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19031. * Note that a new underlying VertexBuffer object is created each call.
  19032. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19033. * @param kind defines vertex data kind:
  19034. * * BABYLON.VertexBuffer.PositionKind
  19035. * * BABYLON.VertexBuffer.UVKind
  19036. * * BABYLON.VertexBuffer.UV2Kind
  19037. * * BABYLON.VertexBuffer.UV3Kind
  19038. * * BABYLON.VertexBuffer.UV4Kind
  19039. * * BABYLON.VertexBuffer.UV5Kind
  19040. * * BABYLON.VertexBuffer.UV6Kind
  19041. * * BABYLON.VertexBuffer.ColorKind
  19042. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19043. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19044. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19045. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19046. * @param data defines the data source
  19047. * @param updatable defines if the data must be flagged as updatable (or static)
  19048. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  19049. * @returns the current mesh
  19050. */
  19051. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19052. /**
  19053. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19054. * If the mesh has no geometry, it is simply returned as it is.
  19055. * @param kind defines vertex data kind:
  19056. * * BABYLON.VertexBuffer.PositionKind
  19057. * * BABYLON.VertexBuffer.UVKind
  19058. * * BABYLON.VertexBuffer.UV2Kind
  19059. * * BABYLON.VertexBuffer.UV3Kind
  19060. * * BABYLON.VertexBuffer.UV4Kind
  19061. * * BABYLON.VertexBuffer.UV5Kind
  19062. * * BABYLON.VertexBuffer.UV6Kind
  19063. * * BABYLON.VertexBuffer.ColorKind
  19064. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19065. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19066. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19067. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19068. * @param data defines the data source
  19069. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  19070. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19071. * @returns the current mesh
  19072. */
  19073. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19074. /**
  19075. * Sets the mesh indices,
  19076. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19077. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19078. * @param totalVertices Defines the total number of vertices
  19079. * @returns the current mesh
  19080. */
  19081. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19082. /**
  19083. * Gets a boolean indicating if specific vertex data is present
  19084. * @param kind defines the vertex data kind to use
  19085. * @returns true is data kind is present
  19086. */
  19087. isVerticesDataPresent(kind: string): boolean;
  19088. /**
  19089. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19090. * @returns a BoundingInfo
  19091. */
  19092. getBoundingInfo(): BoundingInfo;
  19093. /**
  19094. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19095. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19096. * @returns the current mesh
  19097. */
  19098. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19099. /**
  19100. * Overwrite the current bounding info
  19101. * @param boundingInfo defines the new bounding info
  19102. * @returns the current mesh
  19103. */
  19104. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19105. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19106. readonly useBones: boolean;
  19107. /** @hidden */
  19108. _preActivate(): void;
  19109. /** @hidden */
  19110. _preActivateForIntermediateRendering(renderId: number): void;
  19111. /** @hidden */
  19112. _activate(renderId: number): void;
  19113. /**
  19114. * Gets the current world matrix
  19115. * @returns a Matrix
  19116. */
  19117. getWorldMatrix(): Matrix;
  19118. /** @hidden */
  19119. _getWorldMatrixDeterminant(): number;
  19120. /**
  19121. * Perform relative position change from the point of view of behind the front of the mesh.
  19122. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19123. * Supports definition of mesh facing forward or backward
  19124. * @param amountRight defines the distance on the right axis
  19125. * @param amountUp defines the distance on the up axis
  19126. * @param amountForward defines the distance on the forward axis
  19127. * @returns the current mesh
  19128. */
  19129. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19130. /**
  19131. * Calculate relative position change from the point of view of behind the front of the mesh.
  19132. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19133. * Supports definition of mesh facing forward or backward
  19134. * @param amountRight defines the distance on the right axis
  19135. * @param amountUp defines the distance on the up axis
  19136. * @param amountForward defines the distance on the forward axis
  19137. * @returns the new displacement vector
  19138. */
  19139. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19140. /**
  19141. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19142. * Supports definition of mesh facing forward or backward
  19143. * @param flipBack defines the flip
  19144. * @param twirlClockwise defines the twirl
  19145. * @param tiltRight defines the tilt
  19146. * @returns the current mesh
  19147. */
  19148. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19149. /**
  19150. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19151. * Supports definition of mesh facing forward or backward.
  19152. * @param flipBack defines the flip
  19153. * @param twirlClockwise defines the twirl
  19154. * @param tiltRight defines the tilt
  19155. * @returns the new rotation vector
  19156. */
  19157. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19158. /**
  19159. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19160. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19161. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  19162. * @returns the new bounding vectors
  19163. */
  19164. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19165. min: Vector3;
  19166. max: Vector3;
  19167. };
  19168. /** @hidden */
  19169. _updateBoundingInfo(): AbstractMesh;
  19170. /** @hidden */
  19171. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19172. /** @hidden */
  19173. protected _afterComputeWorldMatrix(): void;
  19174. /**
  19175. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19176. * A mesh is in the frustum if its bounding box intersects the frustum
  19177. * @param frustumPlanes defines the frustum to test
  19178. * @returns true if the mesh is in the frustum planes
  19179. */
  19180. isInFrustum(frustumPlanes: Plane[]): boolean;
  19181. /**
  19182. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19183. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19184. * @param frustumPlanes defines the frustum to test
  19185. * @returns true if the mesh is completely in the frustum planes
  19186. */
  19187. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19188. /**
  19189. * True if the mesh intersects another mesh or a SolidParticle object
  19190. * @param mesh defines a target mesh or SolidParticle to test
  19191. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  19192. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19193. * @returns true if there is an intersection
  19194. */
  19195. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19196. /**
  19197. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19198. * @param point defines the point to test
  19199. * @returns true if there is an intersection
  19200. */
  19201. intersectsPoint(point: Vector3): boolean;
  19202. /**
  19203. * Gets the current physics impostor
  19204. * @see http://doc.babylonjs.com/features/physics_engine
  19205. * @returns a physics impostor or null
  19206. */
  19207. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19208. /**
  19209. * Gets the position of the current mesh in camera space
  19210. * @param camera defines the camera to use
  19211. * @returns a position
  19212. */
  19213. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19214. /**
  19215. * Returns the distance from the mesh to the active camera
  19216. * @param camera defines the camera to use
  19217. * @returns the distance
  19218. */
  19219. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19220. /**
  19221. * Apply a physic impulse to the mesh
  19222. * @param force defines the force to apply
  19223. * @param contactPoint defines where to apply the force
  19224. * @returns the current mesh
  19225. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19226. */
  19227. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19228. /**
  19229. * Creates a physic joint between two meshes
  19230. * @param otherMesh defines the other mesh to use
  19231. * @param pivot1 defines the pivot to use on this mesh
  19232. * @param pivot2 defines the pivot to use on the other mesh
  19233. * @param options defines additional options (can be plugin dependent)
  19234. * @returns the current mesh
  19235. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19236. */
  19237. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19238. /**
  19239. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19241. */
  19242. checkCollisions: boolean;
  19243. /**
  19244. * Gets Collider object used to compute collisions (not physics)
  19245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19246. */
  19247. readonly collider: Collider;
  19248. /**
  19249. * Move the mesh using collision engine
  19250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19251. * @param displacement defines the requested displacement vector
  19252. * @returns the current mesh
  19253. */
  19254. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19255. private _onCollisionPositionChange;
  19256. /**
  19257. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19258. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19259. * @param maxCapacity defines the maximum size of each block (64 by default)
  19260. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19261. * @returns the new octree
  19262. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19264. */
  19265. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19266. /** @hidden */
  19267. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19268. /** @hidden */
  19269. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19270. /** @hidden */
  19271. _checkCollision(collider: Collider): AbstractMesh;
  19272. /** @hidden */
  19273. _generatePointsArray(): boolean;
  19274. /**
  19275. * Checks if the passed Ray intersects with the mesh
  19276. * @param ray defines the ray to use
  19277. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19278. * @returns the picking info
  19279. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19280. */
  19281. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19282. /**
  19283. * Clones the current mesh
  19284. * @param name defines the mesh name
  19285. * @param newParent defines the new mesh parent
  19286. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19287. * @returns the new mesh
  19288. */
  19289. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19290. /**
  19291. * Disposes all the submeshes of the current meshnp
  19292. * @returns the current mesh
  19293. */
  19294. releaseSubMeshes(): AbstractMesh;
  19295. /**
  19296. * Releases resources associated with this abstract mesh.
  19297. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19298. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19299. */
  19300. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19301. /**
  19302. * Adds the passed mesh as a child to the current mesh
  19303. * @param mesh defines the child mesh
  19304. * @returns the current mesh
  19305. */
  19306. addChild(mesh: AbstractMesh): AbstractMesh;
  19307. /**
  19308. * Removes the passed mesh from the current mesh children list
  19309. * @param mesh defines the child mesh
  19310. * @returns the current mesh
  19311. */
  19312. removeChild(mesh: AbstractMesh): AbstractMesh;
  19313. /** @hidden */
  19314. private _initFacetData();
  19315. /**
  19316. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19317. * This method can be called within the render loop.
  19318. * 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
  19319. * @returns the current mesh
  19320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19321. */
  19322. updateFacetData(): AbstractMesh;
  19323. /**
  19324. * Returns the facetLocalNormals array.
  19325. * The normals are expressed in the mesh local spac
  19326. * @returns an array of Vector3
  19327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19328. */
  19329. getFacetLocalNormals(): Vector3[];
  19330. /**
  19331. * Returns the facetLocalPositions array.
  19332. * The facet positions are expressed in the mesh local space
  19333. * @returns an array of Vector3
  19334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19335. */
  19336. getFacetLocalPositions(): Vector3[];
  19337. /**
  19338. * Returns the facetLocalPartioning array
  19339. * @returns an array of array of numbers
  19340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19341. */
  19342. getFacetLocalPartitioning(): number[][];
  19343. /**
  19344. * Returns the i-th facet position in the world system.
  19345. * This method allocates a new Vector3 per call
  19346. * @param i defines the facet index
  19347. * @returns a new Vector3
  19348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19349. */
  19350. getFacetPosition(i: number): Vector3;
  19351. /**
  19352. * Sets the reference Vector3 with the i-th facet position in the world system
  19353. * @param i defines the facet index
  19354. * @param ref defines the target vector
  19355. * @returns the current mesh
  19356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19357. */
  19358. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19359. /**
  19360. * Returns the i-th facet normal in the world system.
  19361. * This method allocates a new Vector3 per call
  19362. * @param i defines the facet index
  19363. * @returns a new Vector3
  19364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19365. */
  19366. getFacetNormal(i: number): Vector3;
  19367. /**
  19368. * Sets the reference Vector3 with the i-th facet normal in the world system
  19369. * @param i defines the facet index
  19370. * @param ref defines the target vector
  19371. * @returns the current mesh
  19372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19373. */
  19374. getFacetNormalToRef(i: number, ref: Vector3): this;
  19375. /**
  19376. * 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)
  19377. * @param x defines x coordinate
  19378. * @param y defines y coordinate
  19379. * @param z defines z coordinate
  19380. * @returns the array of facet indexes
  19381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19382. */
  19383. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19384. /**
  19385. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19386. * @param projected sets as the (x,y,z) world projection on the facet
  19387. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  19388. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  19389. * @param x defines x coordinate
  19390. * @param y defines y coordinate
  19391. * @param z defines z coordinate
  19392. * @returns the face index if found (or null instead)
  19393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19394. */
  19395. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19396. /**
  19397. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19398. * @param projected sets as the (x,y,z) local projection on the facet
  19399. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  19400. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  19401. * @param x defines x coordinate
  19402. * @param y defines y coordinate
  19403. * @param z defines z coordinate
  19404. * @returns the face index if found (or null instead)
  19405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19406. */
  19407. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19408. /**
  19409. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19410. * @returns the parameters
  19411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19412. */
  19413. getFacetDataParameters(): any;
  19414. /**
  19415. * Disables the feature FacetData and frees the related memory
  19416. * @returns the current mesh
  19417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19418. */
  19419. disableFacetData(): AbstractMesh;
  19420. /**
  19421. * Updates the AbstractMesh indices array
  19422. * @param indices defines the data source
  19423. * @returns the current mesh
  19424. */
  19425. updateIndices(indices: IndicesArray): AbstractMesh;
  19426. /**
  19427. * Creates new normals data for the mesh
  19428. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19429. * @returns the current mesh
  19430. */
  19431. createNormals(updatable: boolean): AbstractMesh;
  19432. /**
  19433. * Align the mesh with a normal
  19434. * @param normal defines the normal to use
  19435. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19436. * @returns the current mesh
  19437. */
  19438. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19439. /** @hidden */
  19440. protected _checkOcclusionQuery(): void;
  19441. }
  19442. }
  19443. declare module BABYLON {
  19444. class Buffer {
  19445. private _engine;
  19446. private _buffer;
  19447. /** @hidden */
  19448. _data: Nullable<DataArray>;
  19449. private _updatable;
  19450. private _instanced;
  19451. /**
  19452. * Gets the byte stride.
  19453. */
  19454. readonly byteStride: number;
  19455. /**
  19456. * Constructor
  19457. * @param engine the engine
  19458. * @param data the data to use for this buffer
  19459. * @param updatable whether the data is updatable
  19460. * @param stride the stride (optional)
  19461. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19462. * @param instanced whether the buffer is instanced (optional)
  19463. * @param useBytes set to true if the stride in in bytes (optional)
  19464. */
  19465. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19466. /**
  19467. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19468. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19469. * @param offset defines offset in the buffer (0 by default)
  19470. * @param size defines the size in floats of attributes (position is 3 for instance)
  19471. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19472. * @param instanced defines if the vertex buffer contains indexed data
  19473. * @param useBytes defines if the offset and stride are in bytes
  19474. * @returns the new vertex buffer
  19475. */
  19476. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19477. isUpdatable(): boolean;
  19478. getData(): Nullable<DataArray>;
  19479. getBuffer(): Nullable<WebGLBuffer>;
  19480. /**
  19481. * Gets the stride in float32 units (i.e. byte stride / 4).
  19482. * May not be an integer if the byte stride is not divisible by 4.
  19483. * DEPRECATED. Use byteStride instead.
  19484. * @returns the stride in float32 units
  19485. */
  19486. getStrideSize(): number;
  19487. create(data?: Nullable<DataArray>): void;
  19488. _rebuild(): void;
  19489. update(data: DataArray): void;
  19490. /**
  19491. * Updates the data directly.
  19492. * @param data the new data
  19493. * @param offset the new offset
  19494. * @param vertexCount the vertex count (optional)
  19495. * @param useBytes set to true if the offset is in bytes
  19496. */
  19497. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19498. dispose(): void;
  19499. }
  19500. }
  19501. declare module BABYLON {
  19502. class CSG {
  19503. private polygons;
  19504. matrix: Matrix;
  19505. position: Vector3;
  19506. rotation: Vector3;
  19507. rotationQuaternion: Nullable<Quaternion>;
  19508. scaling: Vector3;
  19509. static FromMesh(mesh: Mesh): CSG;
  19510. private static FromPolygons(polygons);
  19511. clone(): CSG;
  19512. union(csg: CSG): CSG;
  19513. unionInPlace(csg: CSG): void;
  19514. subtract(csg: CSG): CSG;
  19515. subtractInPlace(csg: CSG): void;
  19516. intersect(csg: CSG): CSG;
  19517. intersectInPlace(csg: CSG): void;
  19518. inverse(): CSG;
  19519. inverseInPlace(): void;
  19520. copyTransformAttributes(csg: CSG): CSG;
  19521. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19522. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19523. }
  19524. }
  19525. declare module BABYLON {
  19526. /**
  19527. * Class used to store geometry data (vertex buffers + index buffer)
  19528. */
  19529. class Geometry implements IGetSetVerticesData {
  19530. /**
  19531. * Gets or sets the unique ID of the geometry
  19532. */
  19533. id: string;
  19534. /**
  19535. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19536. */
  19537. delayLoadState: number;
  19538. /**
  19539. * Gets the file containing the data to load when running in delay load state
  19540. */
  19541. delayLoadingFile: Nullable<string>;
  19542. /**
  19543. * Callback called when the geometry is updated
  19544. */
  19545. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19546. private _scene;
  19547. private _engine;
  19548. private _meshes;
  19549. private _totalVertices;
  19550. /** @hidden */
  19551. _indices: IndicesArray;
  19552. /** @hidden */
  19553. _vertexBuffers: {
  19554. [key: string]: VertexBuffer;
  19555. };
  19556. private _isDisposed;
  19557. private _extend;
  19558. private _boundingBias;
  19559. /** @hidden */
  19560. _delayInfo: Array<string>;
  19561. private _indexBuffer;
  19562. private _indexBufferIsUpdatable;
  19563. /** @hidden */
  19564. _boundingInfo: Nullable<BoundingInfo>;
  19565. /** @hidden */
  19566. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19567. /** @hidden */
  19568. _softwareSkinningRenderId: number;
  19569. private _vertexArrayObjects;
  19570. private _updatable;
  19571. /** @hidden */
  19572. _positions: Nullable<Vector3[]>;
  19573. /**
  19574. * 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
  19575. */
  19576. /**
  19577. * 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
  19578. */
  19579. boundingBias: Vector2;
  19580. /**
  19581. * Static function used to attach a new empty geometry to a mesh
  19582. * @param mesh defines the mesh to attach the geometry to
  19583. * @returns the new {BABYLON.Geometry}
  19584. */
  19585. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19586. /**
  19587. * Creates a new geometry
  19588. * @param id defines the unique ID
  19589. * @param scene defines the hosting scene
  19590. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19591. * @param updatable defines if geometry must be updatable (false by default)
  19592. * @param mesh defines the mesh that will be associated with the geometry
  19593. */
  19594. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19595. /**
  19596. * Gets the current extend of the geometry
  19597. */
  19598. readonly extend: {
  19599. minimum: Vector3;
  19600. maximum: Vector3;
  19601. };
  19602. /**
  19603. * Gets the hosting scene
  19604. * @returns the hosting {BABYLON.Scene}
  19605. */
  19606. getScene(): Scene;
  19607. /**
  19608. * Gets the hosting engine
  19609. * @returns the hosting {BABYLON.Engine}
  19610. */
  19611. getEngine(): Engine;
  19612. /**
  19613. * Defines if the geometry is ready to use
  19614. * @returns true if the geometry is ready to be used
  19615. */
  19616. isReady(): boolean;
  19617. /**
  19618. * Gets a value indicating that the geometry should not be serialized
  19619. */
  19620. readonly doNotSerialize: boolean;
  19621. /** @hidden */
  19622. _rebuild(): void;
  19623. /**
  19624. * Affects all geometry data in one call
  19625. * @param vertexData defines the geometry data
  19626. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19627. */
  19628. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19629. /**
  19630. * Set specific vertex data
  19631. * @param kind defines the data kind (Position, normal, etc...)
  19632. * @param data defines the vertex data to use
  19633. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19634. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19635. */
  19636. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19637. /**
  19638. * Removes a specific vertex data
  19639. * @param kind defines the data kind (Position, normal, etc...)
  19640. */
  19641. removeVerticesData(kind: string): void;
  19642. /**
  19643. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19644. * @param buffer defines the vertex buffer to use
  19645. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19646. */
  19647. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19648. /**
  19649. * Update a specific vertex buffer
  19650. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19651. * It will do nothing if the buffer is not updatable
  19652. * @param kind defines the data kind (Position, normal, etc...)
  19653. * @param data defines the data to use
  19654. * @param offset defines the offset in the target buffer where to store the data
  19655. * @param useBytes set to true if the offset is in bytes
  19656. */
  19657. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19658. /**
  19659. * Update a specific vertex buffer
  19660. * This function will create a new buffer if the current one is not updatable
  19661. * @param kind defines the data kind (Position, normal, etc...)
  19662. * @param data defines the data to use
  19663. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19664. */
  19665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19666. private _updateBoundingInfo(updateExtends, data);
  19667. /** @hidden */
  19668. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19669. /**
  19670. * Gets total number of vertices
  19671. * @returns the total number of vertices
  19672. */
  19673. getTotalVertices(): number;
  19674. /**
  19675. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19676. * @param kind defines the data kind (Position, normal, etc...)
  19677. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19678. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19679. * @returns a float array containing vertex data
  19680. */
  19681. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19682. /**
  19683. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19684. * @param kind defines the data kind (Position, normal, etc...)
  19685. * @returns true if the vertex buffer with the specified kind is updatable
  19686. */
  19687. isVertexBufferUpdatable(kind: string): boolean;
  19688. /**
  19689. * Gets a specific vertex buffer
  19690. * @param kind defines the data kind (Position, normal, etc...)
  19691. * @returns a {BABYLON.VertexBuffer}
  19692. */
  19693. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19694. /**
  19695. * Returns all vertex buffers
  19696. * @return an object holding all vertex buffers indexed by kind
  19697. */
  19698. getVertexBuffers(): Nullable<{
  19699. [key: string]: VertexBuffer;
  19700. }>;
  19701. /**
  19702. * Gets a boolean indicating if specific vertex buffer is present
  19703. * @param kind defines the data kind (Position, normal, etc...)
  19704. * @returns true if data is present
  19705. */
  19706. isVerticesDataPresent(kind: string): boolean;
  19707. /**
  19708. * Gets a list of all attached data kinds (Position, normal, etc...)
  19709. * @returns a list of string containing all kinds
  19710. */
  19711. getVerticesDataKinds(): string[];
  19712. /**
  19713. * Update index buffer
  19714. * @param indices defines the indices to store in the index buffer
  19715. * @param offset defines the offset in the target buffer where to store the data
  19716. */
  19717. updateIndices(indices: IndicesArray, offset?: number): void;
  19718. /**
  19719. * Creates a new index buffer
  19720. * @param indices defines the indices to store in the index buffer
  19721. * @param totalVertices defines the total number of vertices (could be null)
  19722. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19723. */
  19724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19725. /**
  19726. * Return the total number of indices
  19727. * @returns the total number of indices
  19728. */
  19729. getTotalIndices(): number;
  19730. /**
  19731. * Gets the index buffer array
  19732. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19733. * @returns the index buffer array
  19734. */
  19735. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19736. /**
  19737. * Gets the index buffer
  19738. * @return the index buffer
  19739. */
  19740. getIndexBuffer(): Nullable<WebGLBuffer>;
  19741. /** @hidden */
  19742. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19743. /**
  19744. * Release the associated resources for a specific mesh
  19745. * @param mesh defines the source mesh
  19746. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19747. */
  19748. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19749. /**
  19750. * Apply current geometry to a given mesh
  19751. * @param mesh defines the mesh to apply geometry to
  19752. */
  19753. applyToMesh(mesh: Mesh): void;
  19754. private _updateExtend(data?);
  19755. private _applyToMesh(mesh);
  19756. private notifyUpdate(kind?);
  19757. /**
  19758. * Load the geometry if it was flagged as delay loaded
  19759. * @param scene defines the hosting scene
  19760. * @param onLoaded defines a callback called when the geometry is loaded
  19761. */
  19762. load(scene: Scene, onLoaded?: () => void): void;
  19763. private _queueLoad(scene, onLoaded?);
  19764. /**
  19765. * Invert the geometry to move from a right handed system to a left handed one.
  19766. */
  19767. toLeftHanded(): void;
  19768. /** @hidden */
  19769. _resetPointsArrayCache(): void;
  19770. /** @hidden */
  19771. _generatePointsArray(): boolean;
  19772. /**
  19773. * Gets a value indicating if the geometry is disposed
  19774. * @returns true if the geometry was disposed
  19775. */
  19776. isDisposed(): boolean;
  19777. private _disposeVertexArrayObjects();
  19778. /**
  19779. * Free all associated resources
  19780. */
  19781. dispose(): void;
  19782. /**
  19783. * Clone the current geometry into a new geometry
  19784. * @param id defines the unique ID of the new geometry
  19785. * @returns a new geometry object
  19786. */
  19787. copy(id: string): Geometry;
  19788. /**
  19789. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19790. * @return a JSON representation of the current geometry data (without the vertices data)
  19791. */
  19792. serialize(): any;
  19793. private toNumberArray(origin);
  19794. /**
  19795. * Serialize all vertices data into a JSON oject
  19796. * @returns a JSON representation of the current geometry data
  19797. */
  19798. serializeVerticeData(): any;
  19799. /**
  19800. * Extracts a clone of a mesh geometry
  19801. * @param mesh defines the source mesh
  19802. * @param id defines the unique ID of the new geometry object
  19803. * @returns the new geometry object
  19804. */
  19805. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19806. /**
  19807. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19808. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19809. * Be aware Math.random() could cause collisions, but:
  19810. * "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"
  19811. * @returns a string containing a new GUID
  19812. */
  19813. static RandomId(): string;
  19814. /** @hidden */
  19815. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19816. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19817. /**
  19818. * Create a new geometry from persisted data (Using .babylon file format)
  19819. * @param parsedVertexData defines the persisted data
  19820. * @param scene defines the hosting scene
  19821. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19822. * @returns the new geometry object
  19823. */
  19824. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19825. }
  19826. /**
  19827. * Abstract class used to provide common services for all typed geometries
  19828. * @hidden
  19829. */
  19830. class _PrimitiveGeometry extends Geometry {
  19831. private _canBeRegenerated;
  19832. private _beingRegenerated;
  19833. /**
  19834. * Creates a new typed geometry
  19835. * @param id defines the unique ID of the geometry
  19836. * @param scene defines the hosting scene
  19837. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19838. * @param mesh defines the hosting mesh (can be null)
  19839. */
  19840. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19841. /**
  19842. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19843. * @returns true if the geometry can be regenerated
  19844. */
  19845. canBeRegenerated(): boolean;
  19846. /**
  19847. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19848. */
  19849. regenerate(): void;
  19850. /**
  19851. * Clone the geometry
  19852. * @param id defines the unique ID of the new geometry
  19853. * @returns the new geometry
  19854. */
  19855. asNewGeometry(id: string): Geometry;
  19856. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19857. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19858. /** @hidden */
  19859. _regenerateVertexData(): VertexData;
  19860. copy(id: string): Geometry;
  19861. serialize(): any;
  19862. }
  19863. /**
  19864. * Creates a ribbon geometry
  19865. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19866. */
  19867. class RibbonGeometry extends _PrimitiveGeometry {
  19868. /**
  19869. * Defines the array of paths to use
  19870. */
  19871. pathArray: Vector3[][];
  19872. /**
  19873. * Defines if the last and first points of each path in your pathArray must be joined
  19874. */
  19875. closeArray: boolean;
  19876. /**
  19877. * Defines if the last and first points of each path in your pathArray must be joined
  19878. */
  19879. closePath: boolean;
  19880. /**
  19881. * Defines the offset between points
  19882. */
  19883. offset: number;
  19884. /**
  19885. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19886. */
  19887. side: number;
  19888. /**
  19889. * Creates a ribbon geometry
  19890. * @param id defines the unique ID of the geometry
  19891. * @param scene defines the hosting scene
  19892. * @param pathArray defines the array of paths to use
  19893. * @param closeArray defines if the last path and the first path must be joined
  19894. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19895. * @param offset defines the offset between points
  19896. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19897. * @param mesh defines the hosting mesh (can be null)
  19898. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19899. */
  19900. constructor(id: string, scene: Scene,
  19901. /**
  19902. * Defines the array of paths to use
  19903. */
  19904. pathArray: Vector3[][],
  19905. /**
  19906. * Defines if the last and first points of each path in your pathArray must be joined
  19907. */
  19908. closeArray: boolean,
  19909. /**
  19910. * Defines if the last and first points of each path in your pathArray must be joined
  19911. */
  19912. closePath: boolean,
  19913. /**
  19914. * Defines the offset between points
  19915. */
  19916. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19917. /**
  19918. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19919. */
  19920. side?: number);
  19921. /** @hidden */
  19922. _regenerateVertexData(): VertexData;
  19923. copy(id: string): Geometry;
  19924. }
  19925. /**
  19926. * Creates a box geometry
  19927. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19928. */
  19929. class BoxGeometry extends _PrimitiveGeometry {
  19930. /**
  19931. * Defines the zise of the box (width, height and depth are the same)
  19932. */
  19933. size: number;
  19934. /**
  19935. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19936. */
  19937. side: number;
  19938. /**
  19939. * Creates a box geometry
  19940. * @param id defines the unique ID of the geometry
  19941. * @param scene defines the hosting scene
  19942. * @param size defines the zise of the box (width, height and depth are the same)
  19943. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19944. * @param mesh defines the hosting mesh (can be null)
  19945. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19946. */
  19947. constructor(id: string, scene: Scene,
  19948. /**
  19949. * Defines the zise of the box (width, height and depth are the same)
  19950. */
  19951. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19952. /**
  19953. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19954. */
  19955. side?: number);
  19956. _regenerateVertexData(): VertexData;
  19957. copy(id: string): Geometry;
  19958. serialize(): any;
  19959. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19960. }
  19961. /**
  19962. * Creates a sphere geometry
  19963. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19964. */
  19965. class SphereGeometry extends _PrimitiveGeometry {
  19966. /**
  19967. * Defines the number of segments to use to create the sphere
  19968. */
  19969. segments: number;
  19970. /**
  19971. * Defines the diameter of the sphere
  19972. */
  19973. diameter: number;
  19974. /**
  19975. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19976. */
  19977. side: number;
  19978. /**
  19979. * Create a new sphere geometry
  19980. * @param id defines the unique ID of the geometry
  19981. * @param scene defines the hosting scene
  19982. * @param segments defines the number of segments to use to create the sphere
  19983. * @param diameter defines the diameter of the sphere
  19984. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19985. * @param mesh defines the hosting mesh (can be null)
  19986. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19987. */
  19988. constructor(id: string, scene: Scene,
  19989. /**
  19990. * Defines the number of segments to use to create the sphere
  19991. */
  19992. segments: number,
  19993. /**
  19994. * Defines the diameter of the sphere
  19995. */
  19996. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19997. /**
  19998. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19999. */
  20000. side?: number);
  20001. _regenerateVertexData(): VertexData;
  20002. copy(id: string): Geometry;
  20003. serialize(): any;
  20004. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20005. }
  20006. /**
  20007. * Creates a disc geometry
  20008. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20009. */
  20010. class DiscGeometry extends _PrimitiveGeometry {
  20011. /**
  20012. * Defines the radius of the disc
  20013. */
  20014. radius: number;
  20015. /**
  20016. * Defines the tesselation factor to apply to the disc
  20017. */
  20018. tessellation: number;
  20019. /**
  20020. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20021. */
  20022. side: number;
  20023. /**
  20024. * Creates a new disc geometry
  20025. * @param id defines the unique ID of the geometry
  20026. * @param scene defines the hosting scene
  20027. * @param radius defines the radius of the disc
  20028. * @param tessellation defines the tesselation factor to apply to the disc
  20029. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20030. * @param mesh defines the hosting mesh (can be null)
  20031. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20032. */
  20033. constructor(id: string, scene: Scene,
  20034. /**
  20035. * Defines the radius of the disc
  20036. */
  20037. radius: number,
  20038. /**
  20039. * Defines the tesselation factor to apply to the disc
  20040. */
  20041. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20042. /**
  20043. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20044. */
  20045. side?: number);
  20046. _regenerateVertexData(): VertexData;
  20047. copy(id: string): Geometry;
  20048. }
  20049. /**
  20050. * Creates a new cylinder geometry
  20051. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20052. */
  20053. class CylinderGeometry extends _PrimitiveGeometry {
  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;
  20074. /**
  20075. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20076. */
  20077. side: number;
  20078. /**
  20079. * Creates a new cylinder geometry
  20080. * @param id defines the unique ID of the geometry
  20081. * @param scene defines the hosting scene
  20082. * @param height defines the height of the cylinder
  20083. * @param diameterTop defines the diameter of the cylinder's top cap
  20084. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20085. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20086. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20087. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20088. * @param mesh defines the hosting mesh (can be null)
  20089. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20090. */
  20091. constructor(id: string, scene: Scene,
  20092. /**
  20093. * Defines the height of the cylinder
  20094. */
  20095. height: number,
  20096. /**
  20097. * Defines the diameter of the cylinder's top cap
  20098. */
  20099. diameterTop: number,
  20100. /**
  20101. * Defines the diameter of the cylinder's bottom cap
  20102. */
  20103. diameterBottom: number,
  20104. /**
  20105. * Defines the tessellation factor to apply to the cylinder
  20106. */
  20107. tessellation: number,
  20108. /**
  20109. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20110. */
  20111. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20112. /**
  20113. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20114. */
  20115. side?: number);
  20116. _regenerateVertexData(): VertexData;
  20117. copy(id: string): Geometry;
  20118. serialize(): any;
  20119. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20120. }
  20121. /**
  20122. * Creates a new torus geometry
  20123. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20124. */
  20125. class TorusGeometry extends _PrimitiveGeometry {
  20126. /**
  20127. * Defines the diameter of the torus
  20128. */
  20129. diameter: number;
  20130. /**
  20131. * Defines the thickness of the torus (ie. internal diameter)
  20132. */
  20133. thickness: number;
  20134. /**
  20135. * Defines the tesselation factor to apply to the torus
  20136. */
  20137. tessellation: number;
  20138. /**
  20139. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20140. */
  20141. side: number;
  20142. /**
  20143. * Creates a new torus geometry
  20144. * @param id defines the unique ID of the geometry
  20145. * @param scene defines the hosting scene
  20146. * @param diameter defines the diameter of the torus
  20147. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20148. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20149. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20150. * @param mesh defines the hosting mesh (can be null)
  20151. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20152. */
  20153. constructor(id: string, scene: Scene,
  20154. /**
  20155. * Defines the diameter of the torus
  20156. */
  20157. diameter: number,
  20158. /**
  20159. * Defines the thickness of the torus (ie. internal diameter)
  20160. */
  20161. thickness: number,
  20162. /**
  20163. * Defines the tesselation factor to apply to the torus
  20164. */
  20165. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20166. /**
  20167. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20168. */
  20169. side?: number);
  20170. _regenerateVertexData(): VertexData;
  20171. copy(id: string): Geometry;
  20172. serialize(): any;
  20173. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20174. }
  20175. /**
  20176. * Creates a new ground geometry
  20177. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20178. */
  20179. class GroundGeometry extends _PrimitiveGeometry {
  20180. /**
  20181. * Defines the width of the ground
  20182. */
  20183. width: number;
  20184. /**
  20185. * Defines the height of the ground
  20186. */
  20187. height: number;
  20188. /**
  20189. * Defines the subdivisions to apply to the ground
  20190. */
  20191. subdivisions: number;
  20192. /**
  20193. * Creates a new ground geometry
  20194. * @param id defines the unique ID of the geometry
  20195. * @param scene defines the hosting scene
  20196. * @param width defines the width of the ground
  20197. * @param height defines the height of the ground
  20198. * @param subdivisions defines the subdivisions to apply to the ground
  20199. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20200. * @param mesh defines the hosting mesh (can be null)
  20201. */
  20202. constructor(id: string, scene: Scene,
  20203. /**
  20204. * Defines the width of the ground
  20205. */
  20206. width: number,
  20207. /**
  20208. * Defines the height of the ground
  20209. */
  20210. height: number,
  20211. /**
  20212. * Defines the subdivisions to apply to the ground
  20213. */
  20214. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20215. _regenerateVertexData(): VertexData;
  20216. copy(id: string): Geometry;
  20217. serialize(): any;
  20218. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20219. }
  20220. /**
  20221. * Creates a tiled ground geometry
  20222. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20223. */
  20224. class TiledGroundGeometry extends _PrimitiveGeometry {
  20225. /**
  20226. * Defines the minimum value on X axis
  20227. */
  20228. xmin: number;
  20229. /**
  20230. * Defines the minimum value on Z axis
  20231. */
  20232. zmin: number;
  20233. /**
  20234. * Defines the maximum value on X axis
  20235. */
  20236. xmax: number;
  20237. /**
  20238. * Defines the maximum value on Z axis
  20239. */
  20240. zmax: number;
  20241. /**
  20242. * Defines the subdivisions to apply to the ground
  20243. */
  20244. subdivisions: {
  20245. w: number;
  20246. h: number;
  20247. };
  20248. /**
  20249. * Defines the precision to use when computing the tiles
  20250. */
  20251. precision: {
  20252. w: number;
  20253. h: number;
  20254. };
  20255. /**
  20256. * Creates a tiled ground geometry
  20257. * @param id defines the unique ID of the geometry
  20258. * @param scene defines the hosting scene
  20259. * @param xmin defines the minimum value on X axis
  20260. * @param zmin defines the minimum value on Z axis
  20261. * @param xmax defines the maximum value on X axis
  20262. * @param zmax defines the maximum value on Z axis
  20263. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20264. * @param precision defines the precision to use when computing the tiles
  20265. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20266. * @param mesh defines the hosting mesh (can be null)
  20267. */
  20268. constructor(id: string, scene: Scene,
  20269. /**
  20270. * Defines the minimum value on X axis
  20271. */
  20272. xmin: number,
  20273. /**
  20274. * Defines the minimum value on Z axis
  20275. */
  20276. zmin: number,
  20277. /**
  20278. * Defines the maximum value on X axis
  20279. */
  20280. xmax: number,
  20281. /**
  20282. * Defines the maximum value on Z axis
  20283. */
  20284. zmax: number,
  20285. /**
  20286. * Defines the subdivisions to apply to the ground
  20287. */
  20288. subdivisions: {
  20289. w: number;
  20290. h: number;
  20291. },
  20292. /**
  20293. * Defines the precision to use when computing the tiles
  20294. */
  20295. precision: {
  20296. w: number;
  20297. h: number;
  20298. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20299. _regenerateVertexData(): VertexData;
  20300. copy(id: string): Geometry;
  20301. }
  20302. /**
  20303. * Creates a plane geometry
  20304. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20305. */
  20306. class PlaneGeometry extends _PrimitiveGeometry {
  20307. /**
  20308. * Defines the size of the plane (width === height)
  20309. */
  20310. size: number;
  20311. /**
  20312. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20313. */
  20314. side: number;
  20315. /**
  20316. * Creates a plane geometry
  20317. * @param id defines the unique ID of the geometry
  20318. * @param scene defines the hosting scene
  20319. * @param size defines the size of the plane (width === height)
  20320. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20321. * @param mesh defines the hosting mesh (can be null)
  20322. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20323. */
  20324. constructor(id: string, scene: Scene,
  20325. /**
  20326. * Defines the size of the plane (width === height)
  20327. */
  20328. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20329. /**
  20330. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20331. */
  20332. side?: number);
  20333. _regenerateVertexData(): VertexData;
  20334. copy(id: string): Geometry;
  20335. serialize(): any;
  20336. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20337. }
  20338. /**
  20339. * Creates a torus knot geometry
  20340. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20341. */
  20342. class TorusKnotGeometry extends _PrimitiveGeometry {
  20343. /**
  20344. * Defines the radius of the torus knot
  20345. */
  20346. radius: number;
  20347. /**
  20348. * Defines the thickness of the torus knot tube
  20349. */
  20350. tube: number;
  20351. /**
  20352. * Defines the number of radial segments
  20353. */
  20354. radialSegments: number;
  20355. /**
  20356. * Defines the number of tubular segments
  20357. */
  20358. tubularSegments: number;
  20359. /**
  20360. * Defines the first number of windings
  20361. */
  20362. p: number;
  20363. /**
  20364. * Defines the second number of windings
  20365. */
  20366. q: number;
  20367. /**
  20368. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20369. */
  20370. side: number;
  20371. /**
  20372. * Creates a torus knot geometry
  20373. * @param id defines the unique ID of the geometry
  20374. * @param scene defines the hosting scene
  20375. * @param radius defines the radius of the torus knot
  20376. * @param tube defines the thickness of the torus knot tube
  20377. * @param radialSegments defines the number of radial segments
  20378. * @param tubularSegments defines the number of tubular segments
  20379. * @param p defines the first number of windings
  20380. * @param q defines the second number of windings
  20381. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20382. * @param mesh defines the hosting mesh (can be null)
  20383. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20384. */
  20385. constructor(id: string, scene: Scene,
  20386. /**
  20387. * Defines the radius of the torus knot
  20388. */
  20389. radius: number,
  20390. /**
  20391. * Defines the thickness of the torus knot tube
  20392. */
  20393. tube: number,
  20394. /**
  20395. * Defines the number of radial segments
  20396. */
  20397. radialSegments: number,
  20398. /**
  20399. * Defines the number of tubular segments
  20400. */
  20401. tubularSegments: number,
  20402. /**
  20403. * Defines the first number of windings
  20404. */
  20405. p: number,
  20406. /**
  20407. * Defines the second number of windings
  20408. */
  20409. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20410. /**
  20411. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20412. */
  20413. side?: number);
  20414. _regenerateVertexData(): VertexData;
  20415. copy(id: string): Geometry;
  20416. serialize(): any;
  20417. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20418. }
  20419. }
  20420. declare module BABYLON {
  20421. class GroundMesh extends Mesh {
  20422. generateOctree: boolean;
  20423. private _heightQuads;
  20424. _subdivisionsX: number;
  20425. _subdivisionsY: number;
  20426. _width: number;
  20427. _height: number;
  20428. _minX: number;
  20429. _maxX: number;
  20430. _minZ: number;
  20431. _maxZ: number;
  20432. constructor(name: string, scene: Scene);
  20433. getClassName(): string;
  20434. readonly subdivisions: number;
  20435. readonly subdivisionsX: number;
  20436. readonly subdivisionsY: number;
  20437. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20438. /**
  20439. * Returns a height (y) value in the Worl system :
  20440. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20441. * Returns the ground y position if (x, z) are outside the ground surface.
  20442. */
  20443. getHeightAtCoordinates(x: number, z: number): number;
  20444. /**
  20445. * Returns a normalized vector (Vector3) orthogonal to the ground
  20446. * at the ground coordinates (x, z) expressed in the World system.
  20447. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20448. */
  20449. getNormalAtCoordinates(x: number, z: number): Vector3;
  20450. /**
  20451. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20452. * at the ground coordinates (x, z) expressed in the World system.
  20453. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20454. * Returns the GroundMesh.
  20455. */
  20456. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20457. /**
  20458. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20459. * if the ground has been updated.
  20460. * This can be used in the render loop.
  20461. * Returns the GroundMesh.
  20462. */
  20463. updateCoordinateHeights(): GroundMesh;
  20464. private _getFacetAt(x, z);
  20465. private _initHeightQuads();
  20466. private _computeHeightQuads();
  20467. serialize(serializationObject: any): void;
  20468. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20469. }
  20470. }
  20471. declare module BABYLON {
  20472. /**
  20473. * Creates an instance based on a source mesh.
  20474. */
  20475. class InstancedMesh extends AbstractMesh {
  20476. private _sourceMesh;
  20477. private _currentLOD;
  20478. constructor(name: string, source: Mesh);
  20479. /**
  20480. * Returns the string "InstancedMesh".
  20481. */
  20482. getClassName(): string;
  20483. readonly receiveShadows: boolean;
  20484. readonly material: Nullable<Material>;
  20485. readonly visibility: number;
  20486. readonly skeleton: Nullable<Skeleton>;
  20487. renderingGroupId: number;
  20488. /**
  20489. * Returns the total number of vertices (integer).
  20490. */
  20491. getTotalVertices(): number;
  20492. readonly sourceMesh: Mesh;
  20493. /**
  20494. * Is this node ready to be used/rendered
  20495. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20496. * @return {boolean} is it ready
  20497. */
  20498. isReady(completeCheck?: boolean): boolean;
  20499. /**
  20500. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20501. */
  20502. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20503. /**
  20504. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20505. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20506. * The `data` are either a numeric array either a Float32Array.
  20507. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20508. * 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).
  20509. * Note that a new underlying VertexBuffer object is created each call.
  20510. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20511. *
  20512. * Possible `kind` values :
  20513. * - BABYLON.VertexBuffer.PositionKind
  20514. * - BABYLON.VertexBuffer.UVKind
  20515. * - BABYLON.VertexBuffer.UV2Kind
  20516. * - BABYLON.VertexBuffer.UV3Kind
  20517. * - BABYLON.VertexBuffer.UV4Kind
  20518. * - BABYLON.VertexBuffer.UV5Kind
  20519. * - BABYLON.VertexBuffer.UV6Kind
  20520. * - BABYLON.VertexBuffer.ColorKind
  20521. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20522. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20523. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20524. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20525. *
  20526. * Returns the Mesh.
  20527. */
  20528. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20529. /**
  20530. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20531. * If the mesh has no geometry, it is simply returned as it is.
  20532. * The `data` are either a numeric array either a Float32Array.
  20533. * No new underlying VertexBuffer object is created.
  20534. * 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.
  20535. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20536. *
  20537. * Possible `kind` values :
  20538. * - BABYLON.VertexBuffer.PositionKind
  20539. * - BABYLON.VertexBuffer.UVKind
  20540. * - BABYLON.VertexBuffer.UV2Kind
  20541. * - BABYLON.VertexBuffer.UV3Kind
  20542. * - BABYLON.VertexBuffer.UV4Kind
  20543. * - BABYLON.VertexBuffer.UV5Kind
  20544. * - BABYLON.VertexBuffer.UV6Kind
  20545. * - BABYLON.VertexBuffer.ColorKind
  20546. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20547. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20548. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20549. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20550. *
  20551. * Returns the Mesh.
  20552. */
  20553. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20554. /**
  20555. * Sets the mesh indices.
  20556. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20557. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20558. * This method creates a new index buffer each call.
  20559. * Returns the Mesh.
  20560. */
  20561. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20562. /**
  20563. * Boolean : True if the mesh owns the requested kind of data.
  20564. */
  20565. isVerticesDataPresent(kind: string): boolean;
  20566. /**
  20567. * Returns an array of indices (IndicesArray).
  20568. */
  20569. getIndices(): Nullable<IndicesArray>;
  20570. readonly _positions: Nullable<Vector3[]>;
  20571. /**
  20572. * Sets a new updated BoundingInfo to the mesh.
  20573. * Returns the mesh.
  20574. */
  20575. refreshBoundingInfo(): InstancedMesh;
  20576. _preActivate(): InstancedMesh;
  20577. _activate(renderId: number): InstancedMesh;
  20578. /**
  20579. * Returns the current associated LOD AbstractMesh.
  20580. */
  20581. getLOD(camera: Camera): AbstractMesh;
  20582. _syncSubMeshes(): InstancedMesh;
  20583. _generatePointsArray(): boolean;
  20584. /**
  20585. * Creates a new InstancedMesh from the current mesh.
  20586. * - name (string) : the cloned mesh name
  20587. * - newParent (optional Node) : the optional Node to parent the clone to.
  20588. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20589. *
  20590. * Returns the clone.
  20591. */
  20592. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20593. /**
  20594. * Disposes the InstancedMesh.
  20595. * Returns nothing.
  20596. */
  20597. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. class LinesMesh extends Mesh {
  20602. useVertexColor: boolean | undefined;
  20603. useVertexAlpha: boolean | undefined;
  20604. color: Color3;
  20605. alpha: number;
  20606. /**
  20607. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20608. * This margin is expressed in world space coordinates, so its value may vary.
  20609. * Default value is 0.1
  20610. * @returns the intersection Threshold value.
  20611. */
  20612. /**
  20613. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20614. * This margin is expressed in world space coordinates, so its value may vary.
  20615. * @param value the new threshold to apply
  20616. */
  20617. intersectionThreshold: number;
  20618. private _intersectionThreshold;
  20619. private _colorShader;
  20620. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20621. /**
  20622. * Returns the string "LineMesh"
  20623. */
  20624. getClassName(): string;
  20625. material: Material;
  20626. readonly checkCollisions: boolean;
  20627. createInstance(name: string): InstancedMesh;
  20628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20629. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20630. dispose(doNotRecurse?: boolean): void;
  20631. /**
  20632. * Returns a new LineMesh object cloned from the current one.
  20633. */
  20634. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20635. }
  20636. }
  20637. declare module BABYLON {
  20638. /**
  20639. * @hidden
  20640. **/
  20641. class _InstancesBatch {
  20642. mustReturn: boolean;
  20643. visibleInstances: Nullable<InstancedMesh[]>[];
  20644. renderSelf: boolean[];
  20645. }
  20646. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20647. static _FRONTSIDE: number;
  20648. static _BACKSIDE: number;
  20649. static _DOUBLESIDE: number;
  20650. static _DEFAULTSIDE: number;
  20651. static _NO_CAP: number;
  20652. static _CAP_START: number;
  20653. static _CAP_END: number;
  20654. static _CAP_ALL: number;
  20655. /**
  20656. * Mesh side orientation : usually the external or front surface
  20657. */
  20658. static readonly FRONTSIDE: number;
  20659. /**
  20660. * Mesh side orientation : usually the internal or back surface
  20661. */
  20662. static readonly BACKSIDE: number;
  20663. /**
  20664. * Mesh side orientation : both internal and external or front and back surfaces
  20665. */
  20666. static readonly DOUBLESIDE: number;
  20667. /**
  20668. * Mesh side orientation : by default, `FRONTSIDE`
  20669. */
  20670. static readonly DEFAULTSIDE: number;
  20671. /**
  20672. * Mesh cap setting : no cap
  20673. */
  20674. static readonly NO_CAP: number;
  20675. /**
  20676. * Mesh cap setting : one cap at the beginning of the mesh
  20677. */
  20678. static readonly CAP_START: number;
  20679. /**
  20680. * Mesh cap setting : one cap at the end of the mesh
  20681. */
  20682. static readonly CAP_END: number;
  20683. /**
  20684. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20685. */
  20686. static readonly CAP_ALL: number;
  20687. /**
  20688. * An event triggered before rendering the mesh
  20689. */
  20690. onBeforeRenderObservable: Observable<Mesh>;
  20691. /**
  20692. * An event triggered after rendering the mesh
  20693. */
  20694. onAfterRenderObservable: Observable<Mesh>;
  20695. /**
  20696. * An event triggered before drawing the mesh
  20697. */
  20698. onBeforeDrawObservable: Observable<Mesh>;
  20699. private _onBeforeDrawObserver;
  20700. onBeforeDraw: () => void;
  20701. delayLoadState: number;
  20702. instances: InstancedMesh[];
  20703. delayLoadingFile: string;
  20704. _binaryInfo: any;
  20705. private _LODLevels;
  20706. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20707. private _morphTargetManager;
  20708. morphTargetManager: Nullable<MorphTargetManager>;
  20709. _geometry: Nullable<Geometry>;
  20710. _delayInfo: Array<string>;
  20711. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20712. _visibleInstances: any;
  20713. private _renderIdForInstances;
  20714. private _batchCache;
  20715. private _instancesBufferSize;
  20716. private _instancesBuffer;
  20717. private _instancesData;
  20718. private _overridenInstanceCount;
  20719. private _effectiveMaterial;
  20720. _shouldGenerateFlatShading: boolean;
  20721. private _preActivateId;
  20722. _originalBuilderSideOrientation: number;
  20723. overrideMaterialSideOrientation: Nullable<number>;
  20724. private _areNormalsFrozen;
  20725. private _sourcePositions;
  20726. private _sourceNormals;
  20727. private _source;
  20728. readonly source: Nullable<Mesh>;
  20729. isUnIndexed: boolean;
  20730. /**
  20731. * @constructor
  20732. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20733. * @param {Scene} scene The scene to add this mesh to.
  20734. * @param {Node} parent The parent of this mesh, if it has one
  20735. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20736. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20737. * When false, achieved by calling a clone(), also passing False.
  20738. * This will make creation of children, recursive.
  20739. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20740. */
  20741. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20742. /**
  20743. * Returns the string "Mesh".
  20744. */
  20745. getClassName(): string;
  20746. /**
  20747. * Returns a string.
  20748. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20749. */
  20750. toString(fullDetails?: boolean): string;
  20751. _unBindEffect(): void;
  20752. /**
  20753. * True if the mesh has some Levels Of Details (LOD).
  20754. * Returns a boolean.
  20755. */
  20756. readonly hasLODLevels: boolean;
  20757. /**
  20758. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20759. * @returns an array of {BABYLON.MeshLODLevel}
  20760. */
  20761. getLODLevels(): MeshLODLevel[];
  20762. private _sortLODLevels();
  20763. /**
  20764. * Add a mesh as LOD level triggered at the given distance.
  20765. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20766. * @param distance The distance from the center of the object to show this level
  20767. * @param mesh The mesh to be added as LOD level (can be null)
  20768. * @return This mesh (for chaining)
  20769. */
  20770. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20771. /**
  20772. * Returns the LOD level mesh at the passed distance or null if not found.
  20773. * It is related to the method `addLODLevel(distance, mesh)`.
  20774. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20775. * Returns an object Mesh or `null`.
  20776. */
  20777. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20778. /**
  20779. * Remove a mesh from the LOD array
  20780. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20781. * @param {Mesh} mesh The mesh to be removed.
  20782. * @return {Mesh} This mesh (for chaining)
  20783. */
  20784. removeLODLevel(mesh: Mesh): Mesh;
  20785. /**
  20786. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20787. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  20788. */
  20789. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20790. /**
  20791. * Returns the mesh internal Geometry object.
  20792. */
  20793. readonly geometry: Nullable<Geometry>;
  20794. /**
  20795. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20796. */
  20797. getTotalVertices(): number;
  20798. /**
  20799. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20800. * 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.
  20801. * You can force the copy with forceCopy === true
  20802. * Returns null if the mesh has no geometry or no vertex buffer.
  20803. * Possible `kind` values :
  20804. * - BABYLON.VertexBuffer.PositionKind
  20805. * - BABYLON.VertexBuffer.UVKind
  20806. * - BABYLON.VertexBuffer.UV2Kind
  20807. * - BABYLON.VertexBuffer.UV3Kind
  20808. * - BABYLON.VertexBuffer.UV4Kind
  20809. * - BABYLON.VertexBuffer.UV5Kind
  20810. * - BABYLON.VertexBuffer.UV6Kind
  20811. * - BABYLON.VertexBuffer.ColorKind
  20812. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20813. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20814. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20815. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20816. */
  20817. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20818. /**
  20819. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20820. * Returns `null` if the mesh has no geometry.
  20821. * Possible `kind` values :
  20822. * - BABYLON.VertexBuffer.PositionKind
  20823. * - BABYLON.VertexBuffer.UVKind
  20824. * - BABYLON.VertexBuffer.UV2Kind
  20825. * - BABYLON.VertexBuffer.UV3Kind
  20826. * - BABYLON.VertexBuffer.UV4Kind
  20827. * - BABYLON.VertexBuffer.UV5Kind
  20828. * - BABYLON.VertexBuffer.UV6Kind
  20829. * - BABYLON.VertexBuffer.ColorKind
  20830. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20831. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20832. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20833. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20834. */
  20835. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20836. isVerticesDataPresent(kind: string): boolean;
  20837. /**
  20838. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20839. * Possible `kind` values :
  20840. * - BABYLON.VertexBuffer.PositionKind
  20841. * - BABYLON.VertexBuffer.UVKind
  20842. * - BABYLON.VertexBuffer.UV2Kind
  20843. * - BABYLON.VertexBuffer.UV3Kind
  20844. * - BABYLON.VertexBuffer.UV4Kind
  20845. * - BABYLON.VertexBuffer.UV5Kind
  20846. * - BABYLON.VertexBuffer.UV6Kind
  20847. * - BABYLON.VertexBuffer.ColorKind
  20848. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20849. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20850. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20851. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20852. */
  20853. isVertexBufferUpdatable(kind: string): boolean;
  20854. /**
  20855. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20856. * Possible `kind` values :
  20857. * - BABYLON.VertexBuffer.PositionKind
  20858. * - BABYLON.VertexBuffer.UVKind
  20859. * - BABYLON.VertexBuffer.UV2Kind
  20860. * - BABYLON.VertexBuffer.UV3Kind
  20861. * - BABYLON.VertexBuffer.UV4Kind
  20862. * - BABYLON.VertexBuffer.UV5Kind
  20863. * - BABYLON.VertexBuffer.UV6Kind
  20864. * - BABYLON.VertexBuffer.ColorKind
  20865. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20866. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20867. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20868. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20869. */
  20870. getVerticesDataKinds(): string[];
  20871. /**
  20872. * Returns a positive integer : the total number of indices in this mesh geometry.
  20873. * Returns zero if the mesh has no geometry.
  20874. */
  20875. getTotalIndices(): number;
  20876. /**
  20877. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20878. * 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.
  20879. * Returns an empty array if the mesh has no geometry.
  20880. */
  20881. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20882. readonly isBlocked: boolean;
  20883. /**
  20884. * Determine if the current mesh is ready to be rendered
  20885. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20886. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20887. * @returns true if all associated assets are ready (material, textures, shaders)
  20888. */
  20889. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20890. /**
  20891. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20892. * This property is pertinent only for updatable parametric shapes.
  20893. */
  20894. readonly areNormalsFrozen: boolean;
  20895. /**
  20896. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20897. * It has no effect at all on other shapes.
  20898. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20899. * Returns the Mesh.
  20900. */
  20901. freezeNormals(): Mesh;
  20902. /**
  20903. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20904. * It has no effect at all on other shapes.
  20905. * It reactivates the mesh normals computation if it was previously frozen.
  20906. * Returns the Mesh.
  20907. */
  20908. unfreezeNormals(): Mesh;
  20909. /**
  20910. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20911. */
  20912. overridenInstanceCount: number;
  20913. _preActivate(): Mesh;
  20914. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20915. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20916. /**
  20917. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20918. * This means the mesh underlying bounding box and sphere are recomputed.
  20919. * Returns the Mesh.
  20920. */
  20921. refreshBoundingInfo(): Mesh;
  20922. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20923. private _getPositionData(applySkeleton);
  20924. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20925. subdivide(count: number): void;
  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. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20934. /**
  20935. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20936. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20937. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20938. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20939. * Returns the Mesh.
  20940. */
  20941. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20942. /**
  20943. * Creates a un-shared specific occurence of the geometry for the mesh.
  20944. * Returns the Mesh.
  20945. */
  20946. makeGeometryUnique(): Mesh;
  20947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20948. /**
  20949. * Update the current index buffer
  20950. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20951. * Returns the Mesh.
  20952. */
  20953. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20954. /**
  20955. * Invert the geometry to move from a right handed system to a left handed one.
  20956. * Returns the Mesh.
  20957. */
  20958. toLeftHanded(): Mesh;
  20959. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20960. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20961. /**
  20962. * Registers for this mesh a javascript function called just before the rendering process.
  20963. * This function is passed the current mesh.
  20964. * Return the Mesh.
  20965. */
  20966. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20967. /**
  20968. * Disposes a previously registered javascript function called before the rendering.
  20969. * This function is passed the current mesh.
  20970. * Returns the Mesh.
  20971. */
  20972. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just after the rendering is complete.
  20975. * This function is passed the current mesh.
  20976. * Returns the Mesh.
  20977. */
  20978. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called after the rendering.
  20981. * This function is passed the current mesh.
  20982. * Return the Mesh.
  20983. */
  20984. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20986. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20987. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20988. /**
  20989. * Triggers the draw call for the mesh.
  20990. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20991. * Returns the Mesh.
  20992. */
  20993. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20994. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20995. /**
  20996. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20997. */
  20998. getEmittedParticleSystems(): IParticleSystem[];
  20999. /**
  21000. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21001. */
  21002. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21003. /**
  21004. * Normalize matrix weights so that all vertices have a total weight set to 1
  21005. */
  21006. cleanMatrixWeights(): void;
  21007. _checkDelayState(): Mesh;
  21008. private _queueLoad(scene);
  21009. /**
  21010. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21011. */
  21012. isInFrustum(frustumPlanes: Plane[]): boolean;
  21013. /**
  21014. * Sets the mesh material by the material or multiMaterial `id` property.
  21015. * The material `id` is a string identifying the material or the multiMaterial.
  21016. * This method returns the Mesh.
  21017. */
  21018. setMaterialByID(id: string): Mesh;
  21019. /**
  21020. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21021. */
  21022. getAnimatables(): IAnimatable[];
  21023. /**
  21024. * Modifies the mesh geometry according to the passed transformation matrix.
  21025. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21026. * The mesh normals are modified accordingly the same transformation.
  21027. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21028. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21029. * Returns the Mesh.
  21030. */
  21031. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21032. /**
  21033. * Modifies the mesh geometry according to its own current World Matrix.
  21034. * The mesh World Matrix is then reset.
  21035. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21036. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21037. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21038. * Returns the Mesh.
  21039. */
  21040. bakeCurrentTransformIntoVertices(): Mesh;
  21041. readonly _positions: Nullable<Vector3[]>;
  21042. _resetPointsArrayCache(): Mesh;
  21043. _generatePointsArray(): boolean;
  21044. /**
  21045. * Returns a new Mesh object generated from the current mesh properties.
  21046. * This method must not get confused with createInstance().
  21047. * The parameter `name` is a string, the name given to the new mesh.
  21048. * The optional parameter `newParent` can be any Node object (default `null`).
  21049. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21050. * 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.
  21051. */
  21052. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21053. /**
  21054. * Releases resources associated with this mesh.
  21055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21057. */
  21058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21059. /**
  21060. * Modifies the mesh geometry according to a displacement map.
  21061. * 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.
  21062. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21063. * This method returns nothing.
  21064. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21065. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21066. * 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.
  21067. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21068. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21069. *
  21070. * Returns the Mesh.
  21071. */
  21072. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21073. /**
  21074. * Modifies the mesh geometry according to a displacementMap buffer.
  21075. * 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.
  21076. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21077. * This method returns nothing.
  21078. * 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.
  21079. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21080. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21081. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21082. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21083. *
  21084. * Returns the Mesh.
  21085. */
  21086. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21087. /**
  21088. * Modify the mesh to get a flat shading rendering.
  21089. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21090. * This method returns the Mesh.
  21091. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21092. */
  21093. convertToFlatShadedMesh(): Mesh;
  21094. /**
  21095. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21096. * In other words, more vertices, no more indices and a single bigger VBO.
  21097. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21098. * Returns the Mesh.
  21099. */
  21100. convertToUnIndexedMesh(): Mesh;
  21101. /**
  21102. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21103. * This method returns the Mesh.
  21104. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21105. */
  21106. flipFaces(flipNormals?: boolean): Mesh;
  21107. /**
  21108. * Creates a new InstancedMesh object from the mesh model.
  21109. * An instance shares the same properties and the same material than its model.
  21110. * Only these properties of each instance can then be set individually :
  21111. * - position
  21112. * - rotation
  21113. * - rotationQuaternion
  21114. * - setPivotMatrix
  21115. * - scaling
  21116. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21117. * Warning : this method is not supported for Line mesh and LineSystem
  21118. */
  21119. createInstance(name: string): InstancedMesh;
  21120. /**
  21121. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21122. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21123. * This method returns the Mesh.
  21124. */
  21125. synchronizeInstances(): Mesh;
  21126. /**
  21127. * Simplify the mesh according to the given array of settings.
  21128. * Function will return immediately and will simplify async. It returns the Mesh.
  21129. * @param settings a collection of simplification settings.
  21130. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21131. * @param type the type of simplification to run.
  21132. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21133. */
  21134. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21135. /**
  21136. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21137. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21138. * This should be used together with the simplification to avoid disappearing triangles.
  21139. * Returns the Mesh.
  21140. * @param successCallback an optional success callback to be called after the optimization finished.
  21141. */
  21142. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21143. serialize(serializationObject: any): void;
  21144. _syncGeometryWithMorphTargetManager(): void;
  21145. /**
  21146. * Returns a new Mesh object parsed from the source provided.
  21147. * The parameter `parsedMesh` is the source.
  21148. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21149. */
  21150. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21151. /**
  21152. * Creates a ribbon mesh.
  21153. * Please consider using the same method from the MeshBuilder class instead.
  21154. * 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.
  21155. *
  21156. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21157. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21158. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21159. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21160. * 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.
  21161. * 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.
  21162. * 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
  21163. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21164. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21165. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21166. */
  21167. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21168. /**
  21169. * Creates a plane polygonal mesh. By default, this is a disc.
  21170. * Please consider using the same method from the MeshBuilder class instead.
  21171. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21172. * 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.
  21173. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21174. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21175. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21176. */
  21177. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21178. /**
  21179. * Creates a box mesh.
  21180. * Please consider using the same method from the MeshBuilder class instead.
  21181. * The parameter `size` sets the size (float) of each box side (default 1).
  21182. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21183. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21184. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21185. */
  21186. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21187. /**
  21188. * Creates a sphere mesh.
  21189. * Please consider using the same method from the MeshBuilder class instead.
  21190. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21191. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21192. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21193. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21194. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21195. */
  21196. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21197. /**
  21198. * Creates a cylinder or a cone mesh.
  21199. * Please consider using the same method from the MeshBuilder class instead.
  21200. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21201. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21202. * 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.
  21203. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21204. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21205. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21206. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21207. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21208. */
  21209. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21210. /**
  21211. * Creates a torus mesh.
  21212. * Please consider using the same method from the MeshBuilder class instead.
  21213. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21214. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21215. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21216. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21217. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21218. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21219. */
  21220. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21221. /**
  21222. * Creates a torus knot mesh.
  21223. * Please consider using the same method from the MeshBuilder class instead.
  21224. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21225. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21226. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21227. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21228. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21229. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21230. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21231. */
  21232. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21233. /**
  21234. * Creates a line mesh.
  21235. * Please consider using the same method from the MeshBuilder class instead.
  21236. * 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.
  21237. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21238. * The parameter `points` is an array successive Vector3.
  21239. * 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
  21240. * When updating an instance, remember that only point positions can change, not the number of points.
  21241. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21242. */
  21243. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21244. /**
  21245. * Creates a dashed line mesh.
  21246. * Please consider using the same method from the MeshBuilder class instead.
  21247. * 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.
  21248. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21249. * The parameter `points` is an array successive Vector3.
  21250. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21251. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21252. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21253. * 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
  21254. * When updating an instance, remember that only point positions can change, not the number of points.
  21255. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21256. */
  21257. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21258. /**
  21259. * Creates a polygon mesh.
  21260. * Please consider using the same method from the MeshBuilder class instead.
  21261. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21262. * 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.
  21263. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21264. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21265. * Remember you can only change the shape positions, not their number when updating a polygon.
  21266. */
  21267. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21268. /**
  21269. * Creates an extruded polygon mesh, with depth in the Y direction.
  21270. * Please consider using the same method from the MeshBuilder class instead.
  21271. */
  21272. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21273. /**
  21274. * Creates an extruded shape mesh.
  21275. * 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.
  21276. * Please consider using the same method from the MeshBuilder class instead.
  21277. *
  21278. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21279. * 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
  21280. * extruded along the Z axis.
  21281. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21282. * 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.
  21283. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21284. * 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
  21285. * 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
  21286. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21287. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21288. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21289. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21290. */
  21291. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21292. /**
  21293. * Creates an custom extruded shape mesh.
  21294. * 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.
  21295. * Please consider using the same method from the MeshBuilder class instead.
  21296. *
  21297. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21298. * 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
  21299. * extruded along the Z axis.
  21300. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21301. * 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
  21302. * and the distance of this point from the begining of the path :
  21303. * ```javascript
  21304. * var rotationFunction = function(i, distance) {
  21305. * // do things
  21306. * return rotationValue; }
  21307. * ```
  21308. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21309. * 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
  21310. * and the distance of this point from the begining of the path :
  21311. * ```javascript
  21312. * var scaleFunction = function(i, distance) {
  21313. * // do things
  21314. * return scaleValue;}
  21315. * ```
  21316. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21317. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21318. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21319. * 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
  21320. * 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
  21321. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21322. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21323. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21324. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21325. */
  21326. 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;
  21327. /**
  21328. * Creates lathe mesh.
  21329. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21330. * Please consider using the same method from the MeshBuilder class instead.
  21331. * 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
  21332. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21333. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21334. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21335. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21336. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21337. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21338. */
  21339. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21340. /**
  21341. * Creates a plane mesh.
  21342. * Please consider using the same method from the MeshBuilder class instead.
  21343. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21344. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21345. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21346. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21347. */
  21348. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21349. /**
  21350. * Creates a ground mesh.
  21351. * Please consider using the same method from the MeshBuilder class instead.
  21352. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21353. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21354. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21355. */
  21356. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21357. /**
  21358. * Creates a tiled ground mesh.
  21359. * Please consider using the same method from the MeshBuilder class instead.
  21360. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21361. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21362. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21363. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21364. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21365. * numbers of subdivisions on the ground width and height of each tile.
  21366. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21367. */
  21368. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21369. w: number;
  21370. h: number;
  21371. }, precision: {
  21372. w: number;
  21373. h: number;
  21374. }, scene: Scene, updatable?: boolean): Mesh;
  21375. /**
  21376. * Creates a ground mesh from a height map.
  21377. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21378. * Please consider using the same method from the MeshBuilder class instead.
  21379. * The parameter `url` sets the URL of the height map image resource.
  21380. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21381. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21382. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21383. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21384. * 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).
  21385. * This function is passed the newly built mesh :
  21386. * ```javascript
  21387. * function(mesh) { // do things
  21388. * return; }
  21389. * ```
  21390. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21391. */
  21392. 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;
  21393. /**
  21394. * Creates a tube mesh.
  21395. * 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.
  21396. * Please consider using the same method from the MeshBuilder class instead.
  21397. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21398. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21399. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21400. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21401. * 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.
  21402. * It must return a radius value (positive float) :
  21403. * ```javascript
  21404. * var radiusFunction = function(i, distance) {
  21405. * // do things
  21406. * return radius; }
  21407. * ```
  21408. * 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
  21409. * 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
  21410. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21411. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21412. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21413. */
  21414. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21415. (i: number, distance: number): number;
  21416. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21417. /**
  21418. * Creates a polyhedron mesh.
  21419. * Please consider using the same method from the MeshBuilder class instead.
  21420. * 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
  21421. * to choose the wanted type.
  21422. * The parameter `size` (positive float, default 1) sets the polygon size.
  21423. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21424. * 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`.
  21425. * 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
  21426. * 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)`).
  21427. * 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
  21428. * 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.
  21429. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21430. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21431. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21432. */
  21433. static CreatePolyhedron(name: string, options: {
  21434. type?: number;
  21435. size?: number;
  21436. sizeX?: number;
  21437. sizeY?: number;
  21438. sizeZ?: number;
  21439. custom?: any;
  21440. faceUV?: Vector4[];
  21441. faceColors?: Color4[];
  21442. updatable?: boolean;
  21443. sideOrientation?: number;
  21444. }, scene: Scene): Mesh;
  21445. /**
  21446. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21447. * Please consider using the same method from the MeshBuilder class instead.
  21448. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21449. * 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`).
  21450. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21451. * 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.
  21452. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21453. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21454. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21455. */
  21456. static CreateIcoSphere(name: string, options: {
  21457. radius?: number;
  21458. flat?: boolean;
  21459. subdivisions?: number;
  21460. sideOrientation?: number;
  21461. updatable?: boolean;
  21462. }, scene: Scene): Mesh;
  21463. /**
  21464. * Creates a decal mesh.
  21465. * Please consider using the same method from the MeshBuilder class instead.
  21466. * 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.
  21467. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21468. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21469. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21470. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21471. */
  21472. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21473. /**
  21474. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21475. */
  21476. setPositionsForCPUSkinning(): Float32Array;
  21477. /**
  21478. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21479. */
  21480. setNormalsForCPUSkinning(): Float32Array;
  21481. /**
  21482. * Updates the vertex buffer by applying transformation from the bones.
  21483. * Returns the Mesh.
  21484. *
  21485. * @param {skeleton} skeleton to apply
  21486. */
  21487. applySkeleton(skeleton: Skeleton): Mesh;
  21488. /**
  21489. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21490. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21491. */
  21492. static MinMax(meshes: AbstractMesh[]): {
  21493. min: Vector3;
  21494. max: Vector3;
  21495. };
  21496. /**
  21497. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21498. */
  21499. static Center(meshesOrMinMaxVector: {
  21500. min: Vector3;
  21501. max: Vector3;
  21502. } | AbstractMesh[]): Vector3;
  21503. /**
  21504. * Merge the array of meshes into a single mesh for performance reasons.
  21505. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21506. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21507. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21508. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21509. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21510. */
  21511. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21512. }
  21513. }
  21514. declare module BABYLON {
  21515. /**
  21516. * Define an interface for all classes that will get and set the data on vertices
  21517. */
  21518. interface IGetSetVerticesData {
  21519. isVerticesDataPresent(kind: string): boolean;
  21520. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21521. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21522. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21523. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21524. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21525. }
  21526. /**
  21527. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21528. */
  21529. class VertexData {
  21530. /**
  21531. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21532. */
  21533. positions: Nullable<FloatArray>;
  21534. /**
  21535. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21536. */
  21537. normals: Nullable<FloatArray>;
  21538. /**
  21539. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21540. */
  21541. tangents: Nullable<FloatArray>;
  21542. /**
  21543. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21544. */
  21545. uvs: Nullable<FloatArray>;
  21546. /**
  21547. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21548. */
  21549. uvs2: Nullable<FloatArray>;
  21550. /**
  21551. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21552. */
  21553. uvs3: Nullable<FloatArray>;
  21554. /**
  21555. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21556. */
  21557. uvs4: Nullable<FloatArray>;
  21558. /**
  21559. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21560. */
  21561. uvs5: Nullable<FloatArray>;
  21562. /**
  21563. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21564. */
  21565. uvs6: Nullable<FloatArray>;
  21566. /**
  21567. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21568. */
  21569. colors: Nullable<FloatArray>;
  21570. /**
  21571. * 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).
  21572. */
  21573. matricesIndices: Nullable<FloatArray>;
  21574. /**
  21575. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21576. */
  21577. matricesWeights: Nullable<FloatArray>;
  21578. /**
  21579. * An array extending the number of possible indices
  21580. */
  21581. matricesIndicesExtra: Nullable<FloatArray>;
  21582. /**
  21583. * An array extending the number of possible weights when the number of indices is extended
  21584. */
  21585. matricesWeightsExtra: Nullable<FloatArray>;
  21586. /**
  21587. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21588. */
  21589. indices: Nullable<IndicesArray>;
  21590. /**
  21591. * Uses the passed data array to set the set the values for the specified kind of data
  21592. * @param data a linear array of floating numbers
  21593. * @param kind the type of data that is being set, eg positions, colors etc
  21594. */
  21595. set(data: FloatArray, kind: string): void;
  21596. /**
  21597. * Associates the vertexData to the passed Mesh.
  21598. * Sets it as updatable or not (default `false`)
  21599. * @param mesh the mesh the vertexData is applied to
  21600. * @param updatable when used and having the value true allows new data to update the vertexData
  21601. * @returns the VertexData
  21602. */
  21603. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21604. /**
  21605. * Associates the vertexData to the passed Geometry.
  21606. * Sets it as updatable or not (default `false`)
  21607. * @param geometry the geometry the vertexData is applied to
  21608. * @param updatable when used and having the value true allows new data to update the vertexData
  21609. * @returns VertexData
  21610. */
  21611. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21612. /**
  21613. * Updates the associated mesh
  21614. * @param mesh the mesh to be updated
  21615. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21616. * @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
  21617. * @returns VertexData
  21618. */
  21619. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21620. /**
  21621. * Updates the associated geometry
  21622. * @param geometry the geometry to be updated
  21623. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21624. * @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
  21625. * @returns VertexData.
  21626. */
  21627. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21628. private _applyTo(meshOrGeometry, updatable?);
  21629. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21630. /**
  21631. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21632. * @param matrix the transforming matrix
  21633. * @returns the VertexData
  21634. */
  21635. transform(matrix: Matrix): VertexData;
  21636. /**
  21637. * Merges the passed VertexData into the current one
  21638. * @param other the VertexData to be merged into the current one
  21639. * @returns the modified VertexData
  21640. */
  21641. merge(other: VertexData): VertexData;
  21642. private _mergeElement(source, other);
  21643. private _validate();
  21644. /**
  21645. * Serializes the VertexData
  21646. * @returns a serialized object
  21647. */
  21648. serialize(): any;
  21649. /**
  21650. * Extracts the vertexData from a mesh
  21651. * @param mesh the mesh from which to extract the VertexData
  21652. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21653. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21654. * @returns the object VertexData associated to the passed mesh
  21655. */
  21656. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21657. /**
  21658. * Extracts the vertexData from the geometry
  21659. * @param geometry the geometry from which to extract the VertexData
  21660. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21661. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21662. * @returns the object VertexData associated to the passed mesh
  21663. */
  21664. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21665. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21666. /**
  21667. * Creates the VertexData for a Ribbon
  21668. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21669. * * pathArray array of paths, each of which an array of successive Vector3
  21670. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21671. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21672. * * 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
  21673. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21674. * * 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)
  21675. * * 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)
  21676. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21677. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21678. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21679. * @returns the VertexData of the ribbon
  21680. */
  21681. static CreateRibbon(options: {
  21682. pathArray: Vector3[][];
  21683. closeArray?: boolean;
  21684. closePath?: boolean;
  21685. offset?: number;
  21686. sideOrientation?: number;
  21687. frontUVs?: Vector4;
  21688. backUVs?: Vector4;
  21689. invertUV?: boolean;
  21690. uvs?: Vector2[];
  21691. colors?: Color4[];
  21692. }): VertexData;
  21693. /**
  21694. * Creates the VertexData for a box
  21695. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21696. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21697. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21698. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21699. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21700. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21701. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21702. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21703. * * 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)
  21704. * * 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)
  21705. * @returns the VertexData of the box
  21706. */
  21707. static CreateBox(options: {
  21708. size?: number;
  21709. width?: number;
  21710. height?: number;
  21711. depth?: number;
  21712. faceUV?: Vector4[];
  21713. faceColors?: Color4[];
  21714. sideOrientation?: number;
  21715. frontUVs?: Vector4;
  21716. backUVs?: Vector4;
  21717. }): VertexData;
  21718. /**
  21719. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21720. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21721. * * segments sets the number of horizontal strips optional, default 32
  21722. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21723. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21724. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21725. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21726. * * 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
  21727. * * 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
  21728. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21729. * * 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)
  21730. * * 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)
  21731. * @returns the VertexData of the ellipsoid
  21732. */
  21733. static CreateSphere(options: {
  21734. segments?: number;
  21735. diameter?: number;
  21736. diameterX?: number;
  21737. diameterY?: number;
  21738. diameterZ?: number;
  21739. arc?: number;
  21740. slice?: number;
  21741. sideOrientation?: number;
  21742. frontUVs?: Vector4;
  21743. backUVs?: Vector4;
  21744. }): VertexData;
  21745. /**
  21746. * Creates the VertexData for a cylinder, cone or prism
  21747. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21748. * * height sets the height (y direction) of the cylinder, optional, default 2
  21749. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21750. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21751. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21752. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21753. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21754. * * 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
  21755. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21756. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21757. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21758. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21759. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21760. * * 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)
  21761. * * 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)
  21762. * @returns the VertexData of the cylinder, cone or prism
  21763. */
  21764. static CreateCylinder(options: {
  21765. height?: number;
  21766. diameterTop?: number;
  21767. diameterBottom?: number;
  21768. diameter?: number;
  21769. tessellation?: number;
  21770. subdivisions?: number;
  21771. arc?: number;
  21772. faceColors?: Color4[];
  21773. faceUV?: Vector4[];
  21774. hasRings?: boolean;
  21775. enclose?: boolean;
  21776. sideOrientation?: number;
  21777. frontUVs?: Vector4;
  21778. backUVs?: Vector4;
  21779. }): VertexData;
  21780. /**
  21781. * Creates the VertexData for a torus
  21782. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21783. * * diameter the diameter of the torus, optional default 1
  21784. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21785. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21786. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21787. * * 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)
  21788. * * 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)
  21789. * @returns the VertexData of the torus
  21790. */
  21791. static CreateTorus(options: {
  21792. diameter?: number;
  21793. thickness?: number;
  21794. tessellation?: number;
  21795. sideOrientation?: number;
  21796. frontUVs?: Vector4;
  21797. backUVs?: Vector4;
  21798. }): VertexData;
  21799. /**
  21800. * Creates the VertexData of the LineSystem
  21801. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21802. * - lines an array of lines, each line being an array of successive Vector3
  21803. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21804. * @returns the VertexData of the LineSystem
  21805. */
  21806. static CreateLineSystem(options: {
  21807. lines: Vector3[][];
  21808. colors?: Nullable<Color4[][]>;
  21809. }): VertexData;
  21810. /**
  21811. * Create the VertexData for a DashedLines
  21812. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21813. * - points an array successive Vector3
  21814. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21815. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21816. * - dashNb the intended total number of dashes, optional, default 200
  21817. * @returns the VertexData for the DashedLines
  21818. */
  21819. static CreateDashedLines(options: {
  21820. points: Vector3[];
  21821. dashSize?: number;
  21822. gapSize?: number;
  21823. dashNb?: number;
  21824. }): VertexData;
  21825. /**
  21826. * Creates the VertexData for a Ground
  21827. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21828. * - width the width (x direction) of the ground, optional, default 1
  21829. * - height the height (z direction) of the ground, optional, default 1
  21830. * - subdivisions the number of subdivisions per side, optional, default 1
  21831. * @returns the VertexData of the Ground
  21832. */
  21833. static CreateGround(options: {
  21834. width?: number;
  21835. height?: number;
  21836. subdivisions?: number;
  21837. subdivisionsX?: number;
  21838. subdivisionsY?: number;
  21839. }): VertexData;
  21840. /**
  21841. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21842. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21843. * * xmin the ground minimum X coordinate, optional, default -1
  21844. * * zmin the ground minimum Z coordinate, optional, default -1
  21845. * * xmax the ground maximum X coordinate, optional, default 1
  21846. * * zmax the ground maximum Z coordinate, optional, default 1
  21847. * * 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}
  21848. * * 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}
  21849. * @returns the VertexData of the TiledGround
  21850. */
  21851. static CreateTiledGround(options: {
  21852. xmin: number;
  21853. zmin: number;
  21854. xmax: number;
  21855. zmax: number;
  21856. subdivisions?: {
  21857. w: number;
  21858. h: number;
  21859. };
  21860. precision?: {
  21861. w: number;
  21862. h: number;
  21863. };
  21864. }): VertexData;
  21865. /**
  21866. * Creates the VertexData of the Ground designed from a heightmap
  21867. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21868. * * width the width (x direction) of the ground
  21869. * * height the height (z direction) of the ground
  21870. * * subdivisions the number of subdivisions per side
  21871. * * minHeight the minimum altitude on the ground, optional, default 0
  21872. * * maxHeight the maximum altitude on the ground, optional default 1
  21873. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21874. * * buffer the array holding the image color data
  21875. * * bufferWidth the width of image
  21876. * * bufferHeight the height of image
  21877. * @returns the VertexData of the Ground designed from a heightmap
  21878. */
  21879. static CreateGroundFromHeightMap(options: {
  21880. width: number;
  21881. height: number;
  21882. subdivisions: number;
  21883. minHeight: number;
  21884. maxHeight: number;
  21885. colorFilter: Color3;
  21886. buffer: Uint8Array;
  21887. bufferWidth: number;
  21888. bufferHeight: number;
  21889. }): VertexData;
  21890. /**
  21891. * Creates the VertexData for a Plane
  21892. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21893. * * size sets the width and height of the plane to the value of size, optional default 1
  21894. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21895. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21896. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21897. * * 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)
  21898. * * 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)
  21899. * @returns the VertexData of the box
  21900. */
  21901. static CreatePlane(options: {
  21902. size?: number;
  21903. width?: number;
  21904. height?: number;
  21905. sideOrientation?: number;
  21906. frontUVs?: Vector4;
  21907. backUVs?: Vector4;
  21908. }): VertexData;
  21909. /**
  21910. * Creates the VertexData of the Disc or regular Polygon
  21911. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21912. * * radius the radius of the disc, optional default 0.5
  21913. * * tessellation the number of polygon sides, optional, default 64
  21914. * * 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
  21915. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21916. * * 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)
  21917. * * 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)
  21918. * @returns the VertexData of the box
  21919. */
  21920. static CreateDisc(options: {
  21921. radius?: number;
  21922. tessellation?: number;
  21923. arc?: number;
  21924. sideOrientation?: number;
  21925. frontUVs?: Vector4;
  21926. backUVs?: Vector4;
  21927. }): VertexData;
  21928. /**
  21929. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21930. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21931. * @param polygon a mesh built from polygonTriangulation.build()
  21932. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21933. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21934. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21935. * @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)
  21936. * @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)
  21937. * @returns the VertexData of the Polygon
  21938. */
  21939. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21940. /**
  21941. * Creates the VertexData of the IcoSphere
  21942. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21943. * * radius the radius of the IcoSphere, optional default 1
  21944. * * radiusX allows stretching in the x direction, optional, default radius
  21945. * * radiusY allows stretching in the y direction, optional, default radius
  21946. * * radiusZ allows stretching in the z direction, optional, default radius
  21947. * * flat when true creates a flat shaded mesh, optional, default true
  21948. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21949. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21950. * * 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)
  21951. * * 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)
  21952. * @returns the VertexData of the IcoSphere
  21953. */
  21954. static CreateIcoSphere(options: {
  21955. radius?: number;
  21956. radiusX?: number;
  21957. radiusY?: number;
  21958. radiusZ?: number;
  21959. flat?: boolean;
  21960. subdivisions?: number;
  21961. sideOrientation?: number;
  21962. frontUVs?: Vector4;
  21963. backUVs?: Vector4;
  21964. }): VertexData;
  21965. /**
  21966. * Creates the VertexData for a Polyhedron
  21967. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21968. * * type provided types are:
  21969. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21970. * * 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)
  21971. * * size the size of the IcoSphere, optional default 1
  21972. * * sizeX allows stretching in the x direction, optional, default size
  21973. * * sizeY allows stretching in the y direction, optional, default size
  21974. * * sizeZ allows stretching in the z direction, optional, default size
  21975. * * 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
  21976. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21977. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21978. * * flat when true creates a flat shaded mesh, optional, default true
  21979. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21980. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21981. * * 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)
  21982. * * 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)
  21983. * @returns the VertexData of the Polyhedron
  21984. */
  21985. static CreatePolyhedron(options: {
  21986. type?: number;
  21987. size?: number;
  21988. sizeX?: number;
  21989. sizeY?: number;
  21990. sizeZ?: number;
  21991. custom?: any;
  21992. faceUV?: Vector4[];
  21993. faceColors?: Color4[];
  21994. flat?: boolean;
  21995. sideOrientation?: number;
  21996. frontUVs?: Vector4;
  21997. backUVs?: Vector4;
  21998. }): VertexData;
  21999. /**
  22000. * Creates the VertexData for a TorusKnot
  22001. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22002. * * radius the radius of the torus knot, optional, default 2
  22003. * * tube the thickness of the tube, optional, default 0.5
  22004. * * radialSegments the number of sides on each tube segments, optional, default 32
  22005. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22006. * * p the number of windings around the z axis, optional, default 2
  22007. * * q the number of windings around the x axis, optional, default 3
  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 Torus Knot
  22012. */
  22013. static CreateTorusKnot(options: {
  22014. radius?: number;
  22015. tube?: number;
  22016. radialSegments?: number;
  22017. tubularSegments?: number;
  22018. p?: number;
  22019. q?: number;
  22020. sideOrientation?: number;
  22021. frontUVs?: Vector4;
  22022. backUVs?: Vector4;
  22023. }): VertexData;
  22024. /**
  22025. * Compute normals for given positions and indices
  22026. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22027. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22028. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22029. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22030. * * facetNormals : optional array of facet normals (vector3)
  22031. * * facetPositions : optional array of facet positions (vector3)
  22032. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22033. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22034. * * bInfo : optional bounding info, required for facetPartitioning computation
  22035. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22036. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22037. * * useRightHandedSystem: optional boolean to for right handed system computation
  22038. * * depthSort : optional boolean to enable the facet depth sort computation
  22039. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22040. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22041. */
  22042. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22043. facetNormals?: any;
  22044. facetPositions?: any;
  22045. facetPartitioning?: any;
  22046. ratio?: number;
  22047. bInfo?: any;
  22048. bbSize?: Vector3;
  22049. subDiv?: any;
  22050. useRightHandedSystem?: boolean;
  22051. depthSort?: boolean;
  22052. distanceTo?: Vector3;
  22053. depthSortedFacets?: any;
  22054. }): void;
  22055. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22056. /**
  22057. * Applies VertexData created from the imported parameters to the geometry
  22058. * @param parsedVertexData the parsed data from an imported file
  22059. * @param geometry the geometry to apply the VertexData to
  22060. */
  22061. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22062. }
  22063. }
  22064. declare module BABYLON {
  22065. /**
  22066. * Class containing static functions to help procedurally build meshes
  22067. */
  22068. class MeshBuilder {
  22069. private static updateSideOrientation(orientation?);
  22070. /**
  22071. * Creates a box mesh
  22072. * * The parameter `size` sets the size (float) of each box side (default 1)
  22073. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22074. * * 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)
  22075. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22079. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22080. * @param name defines the name of the mesh
  22081. * @param options defines the options used to create the mesh
  22082. * @param scene defines the hosting scene
  22083. * @returns the box mesh
  22084. */
  22085. static CreateBox(name: string, options: {
  22086. size?: number;
  22087. width?: number;
  22088. height?: number;
  22089. depth?: number;
  22090. faceUV?: Vector4[];
  22091. faceColors?: Color4[];
  22092. sideOrientation?: number;
  22093. frontUVs?: Vector4;
  22094. backUVs?: Vector4;
  22095. updatable?: boolean;
  22096. }, scene?: Nullable<Scene>): Mesh;
  22097. /**
  22098. * Creates a sphere mesh
  22099. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22100. * * 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`)
  22101. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22102. * * 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
  22103. * * 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)
  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/babylon101/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. * @param name defines the name of the mesh
  22108. * @param options defines the options used to create the mesh
  22109. * @param scene defines the hosting scene
  22110. * @returns the sphere mesh
  22111. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22112. */
  22113. static CreateSphere(name: string, options: {
  22114. segments?: number;
  22115. diameter?: number;
  22116. diameterX?: number;
  22117. diameterY?: number;
  22118. diameterZ?: number;
  22119. arc?: number;
  22120. slice?: number;
  22121. sideOrientation?: number;
  22122. frontUVs?: Vector4;
  22123. backUVs?: Vector4;
  22124. updatable?: boolean;
  22125. }, scene: any): Mesh;
  22126. /**
  22127. * Creates a plane polygonal mesh. By default, this is a disc
  22128. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22129. * * 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
  22130. * * 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
  22131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22134. * @param name defines the name of the mesh
  22135. * @param options defines the options used to create the mesh
  22136. * @param scene defines the hosting scene
  22137. * @returns the plane polygonal mesh
  22138. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22139. */
  22140. static CreateDisc(name: string, options: {
  22141. radius?: number;
  22142. tessellation?: number;
  22143. arc?: number;
  22144. updatable?: boolean;
  22145. sideOrientation?: number;
  22146. frontUVs?: Vector4;
  22147. backUVs?: Vector4;
  22148. }, scene?: Nullable<Scene>): Mesh;
  22149. /**
  22150. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22151. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22152. * * 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`)
  22153. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22154. * * 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
  22155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22158. * @param name defines the name of the mesh
  22159. * @param options defines the options used to create the mesh
  22160. * @param scene defines the hosting scene
  22161. * @returns the icosahedron mesh
  22162. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22163. */
  22164. static CreateIcoSphere(name: string, options: {
  22165. radius?: number;
  22166. radiusX?: number;
  22167. radiusY?: number;
  22168. radiusZ?: number;
  22169. flat?: boolean;
  22170. subdivisions?: number;
  22171. sideOrientation?: number;
  22172. frontUVs?: Vector4;
  22173. backUVs?: Vector4;
  22174. updatable?: boolean;
  22175. }, scene: Scene): Mesh;
  22176. /**
  22177. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22178. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22179. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22180. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22181. * * 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
  22182. * * 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
  22183. * * 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
  22184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22187. * * 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
  22188. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22189. * * 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
  22190. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22192. * @param name defines the name of the mesh
  22193. * @param options defines the options used to create the mesh
  22194. * @param scene defines the hosting scene
  22195. * @returns the ribbon mesh
  22196. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22197. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22198. */
  22199. static CreateRibbon(name: string, options: {
  22200. pathArray: Vector3[][];
  22201. closeArray?: boolean;
  22202. closePath?: boolean;
  22203. offset?: number;
  22204. updatable?: boolean;
  22205. sideOrientation?: number;
  22206. frontUVs?: Vector4;
  22207. backUVs?: Vector4;
  22208. instance?: Mesh;
  22209. invertUV?: boolean;
  22210. uvs?: Vector2[];
  22211. colors?: Color4[];
  22212. }, scene?: Nullable<Scene>): Mesh;
  22213. /**
  22214. * Creates a cylinder or a cone mesh
  22215. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22216. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22217. * * 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.
  22218. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22219. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22220. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22221. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22222. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22223. * * 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).
  22224. * * 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
  22225. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22226. * * 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
  22227. * * 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.
  22228. * * If `enclose` is false, a ring surface is one element.
  22229. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22230. * * 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
  22231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22234. * @param name defines the name of the mesh
  22235. * @param options defines the options used to create the mesh
  22236. * @param scene defines the hosting scene
  22237. * @returns the cylinder mesh
  22238. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22239. */
  22240. static CreateCylinder(name: string, options: {
  22241. height?: number;
  22242. diameterTop?: number;
  22243. diameterBottom?: number;
  22244. diameter?: number;
  22245. tessellation?: number;
  22246. subdivisions?: number;
  22247. arc?: number;
  22248. faceColors?: Color4[];
  22249. faceUV?: Vector4[];
  22250. updatable?: boolean;
  22251. hasRings?: boolean;
  22252. enclose?: boolean;
  22253. sideOrientation?: number;
  22254. frontUVs?: Vector4;
  22255. backUVs?: Vector4;
  22256. }, scene: any): Mesh;
  22257. /**
  22258. * Creates a torus mesh
  22259. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22260. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22261. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22265. * @param name defines the name of the mesh
  22266. * @param options defines the options used to create the mesh
  22267. * @param scene defines the hosting scene
  22268. * @returns the torus mesh
  22269. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22270. */
  22271. static CreateTorus(name: string, options: {
  22272. diameter?: number;
  22273. thickness?: number;
  22274. tessellation?: number;
  22275. updatable?: boolean;
  22276. sideOrientation?: number;
  22277. frontUVs?: Vector4;
  22278. backUVs?: Vector4;
  22279. }, scene: any): Mesh;
  22280. /**
  22281. * Creates a torus knot mesh
  22282. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22283. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22284. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22285. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22289. * @param name defines the name of the mesh
  22290. * @param options defines the options used to create the mesh
  22291. * @param scene defines the hosting scene
  22292. * @returns the torus knot mesh
  22293. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22294. */
  22295. static CreateTorusKnot(name: string, options: {
  22296. radius?: number;
  22297. tube?: number;
  22298. radialSegments?: number;
  22299. tubularSegments?: number;
  22300. p?: number;
  22301. q?: number;
  22302. updatable?: boolean;
  22303. sideOrientation?: number;
  22304. frontUVs?: Vector4;
  22305. backUVs?: Vector4;
  22306. }, scene: any): Mesh;
  22307. /**
  22308. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22309. * * 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
  22310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22311. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22312. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22313. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22315. * * 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
  22316. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22318. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22319. * @param name defines the name of the new line system
  22320. * @param options defines the options used to create the line system
  22321. * @param scene defines the hosting scene
  22322. * @returns a new line system mesh
  22323. */
  22324. static CreateLineSystem(name: string, options: {
  22325. lines: Vector3[][];
  22326. updatable?: boolean;
  22327. instance?: Nullable<LinesMesh>;
  22328. colors?: Nullable<Color4[][]>;
  22329. useVertexAlpha?: boolean;
  22330. }, scene: Nullable<Scene>): LinesMesh;
  22331. /**
  22332. * Creates a line mesh
  22333. * 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
  22334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22335. * * The parameter `points` is an array successive Vector3
  22336. * * 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
  22337. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22338. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22339. * * When updating an instance, remember that only point positions can change, not the number of points
  22340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22341. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22342. * @param name defines the name of the new line system
  22343. * @param options defines the options used to create the line system
  22344. * @param scene defines the hosting scene
  22345. * @returns a new line mesh
  22346. */
  22347. static CreateLines(name: string, options: {
  22348. points: Vector3[];
  22349. updatable?: boolean;
  22350. instance?: Nullable<LinesMesh>;
  22351. colors?: Color4[];
  22352. useVertexAlpha?: boolean;
  22353. }, scene?: Nullable<Scene>): LinesMesh;
  22354. /**
  22355. * Creates a dashed line mesh
  22356. * * 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
  22357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22358. * * The parameter `points` is an array successive Vector3
  22359. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22360. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22361. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22362. * * 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
  22363. * * When updating an instance, remember that only point positions can change, not the number of points
  22364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22365. * @param name defines the name of the mesh
  22366. * @param options defines the options used to create the mesh
  22367. * @param scene defines the hosting scene
  22368. * @returns the dashed line mesh
  22369. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22370. */
  22371. static CreateDashedLines(name: string, options: {
  22372. points: Vector3[];
  22373. dashSize?: number;
  22374. gapSize?: number;
  22375. dashNb?: number;
  22376. updatable?: boolean;
  22377. instance?: LinesMesh;
  22378. }, scene?: Nullable<Scene>): LinesMesh;
  22379. /**
  22380. * 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.
  22381. * * 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.
  22382. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22383. * * 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.
  22384. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22385. * * 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
  22386. * * 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
  22387. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22392. * @param name defines the name of the mesh
  22393. * @param options defines the options used to create the mesh
  22394. * @param scene defines the hosting scene
  22395. * @returns the extruded shape mesh
  22396. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22398. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22399. */
  22400. static ExtrudeShape(name: string, options: {
  22401. shape: Vector3[];
  22402. path: Vector3[];
  22403. scale?: number;
  22404. rotation?: number;
  22405. cap?: number;
  22406. updatable?: boolean;
  22407. sideOrientation?: number;
  22408. frontUVs?: Vector4;
  22409. backUVs?: Vector4;
  22410. instance?: Mesh;
  22411. invertUV?: boolean;
  22412. }, scene?: Nullable<Scene>): Mesh;
  22413. /**
  22414. * Creates an custom extruded shape mesh.
  22415. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22416. * * 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.
  22417. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22418. * * 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
  22419. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22420. * * 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
  22421. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22422. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22423. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22424. * * 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
  22425. * * 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
  22426. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22431. * @param name defines the name of the mesh
  22432. * @param options defines the options used to create the mesh
  22433. * @param scene defines the hosting scene
  22434. * @returns the custom extruded shape mesh
  22435. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22436. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22437. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22438. */
  22439. static ExtrudeShapeCustom(name: string, options: {
  22440. shape: Vector3[];
  22441. path: Vector3[];
  22442. scaleFunction?: any;
  22443. rotationFunction?: any;
  22444. ribbonCloseArray?: boolean;
  22445. ribbonClosePath?: boolean;
  22446. cap?: number;
  22447. updatable?: boolean;
  22448. sideOrientation?: number;
  22449. frontUVs?: Vector4;
  22450. backUVs?: Vector4;
  22451. instance?: Mesh;
  22452. invertUV?: boolean;
  22453. }, scene: Scene): Mesh;
  22454. /**
  22455. * Creates lathe mesh.
  22456. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22457. * * 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
  22458. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22459. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22460. * * 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
  22461. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22462. * * 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
  22463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22467. * @param name defines the name of the mesh
  22468. * @param options defines the options used to create the mesh
  22469. * @param scene defines the hosting scene
  22470. * @returns the lathe mesh
  22471. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22472. */
  22473. static CreateLathe(name: string, options: {
  22474. shape: Vector3[];
  22475. radius?: number;
  22476. tessellation?: number;
  22477. arc?: number;
  22478. closed?: boolean;
  22479. updatable?: boolean;
  22480. sideOrientation?: number;
  22481. frontUVs?: Vector4;
  22482. backUVs?: Vector4;
  22483. cap?: number;
  22484. invertUV?: boolean;
  22485. }, scene: Scene): Mesh;
  22486. /**
  22487. * Creates a plane mesh
  22488. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22489. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22490. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  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/babylon101/discover_basic_elements#side-orientation
  22493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22494. * @param name defines the name of the mesh
  22495. * @param options defines the options used to create the mesh
  22496. * @param scene defines the hosting scene
  22497. * @returns the plane mesh
  22498. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22499. */
  22500. static CreatePlane(name: string, options: {
  22501. size?: number;
  22502. width?: number;
  22503. height?: number;
  22504. sideOrientation?: number;
  22505. frontUVs?: Vector4;
  22506. backUVs?: Vector4;
  22507. updatable?: boolean;
  22508. sourcePlane?: Plane;
  22509. }, scene: Scene): Mesh;
  22510. /**
  22511. * Creates a ground mesh
  22512. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22513. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22515. * @param name defines the name of the mesh
  22516. * @param options defines the options used to create the mesh
  22517. * @param scene defines the hosting scene
  22518. * @returns the ground mesh
  22519. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22520. */
  22521. static CreateGround(name: string, options: {
  22522. width?: number;
  22523. height?: number;
  22524. subdivisions?: number;
  22525. subdivisionsX?: number;
  22526. subdivisionsY?: number;
  22527. updatable?: boolean;
  22528. }, scene: any): Mesh;
  22529. /**
  22530. * Creates a tiled ground mesh
  22531. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22532. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22533. * * 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
  22534. * * 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
  22535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22536. * @param name defines the name of the mesh
  22537. * @param options defines the options used to create the mesh
  22538. * @param scene defines the hosting scene
  22539. * @returns the tiled ground mesh
  22540. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22541. */
  22542. static CreateTiledGround(name: string, options: {
  22543. xmin: number;
  22544. zmin: number;
  22545. xmax: number;
  22546. zmax: number;
  22547. subdivisions?: {
  22548. w: number;
  22549. h: number;
  22550. };
  22551. precision?: {
  22552. w: number;
  22553. h: number;
  22554. };
  22555. updatable?: boolean;
  22556. }, scene: Scene): Mesh;
  22557. /**
  22558. * Creates a ground mesh from a height map
  22559. * * The parameter `url` sets the URL of the height map image resource.
  22560. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22561. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22562. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22563. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22564. * * 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.
  22565. * * 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).
  22566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22567. * @param name defines the name of the mesh
  22568. * @param url defines the url to the height map
  22569. * @param options defines the options used to create the mesh
  22570. * @param scene defines the hosting scene
  22571. * @returns the ground mesh
  22572. * @see http://doc.babylonjs.com/babylon101/height_map
  22573. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22574. */
  22575. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22576. width?: number;
  22577. height?: number;
  22578. subdivisions?: number;
  22579. minHeight?: number;
  22580. maxHeight?: number;
  22581. colorFilter?: Color3;
  22582. updatable?: boolean;
  22583. onReady?: (mesh: GroundMesh) => void;
  22584. }, scene: Scene): GroundMesh;
  22585. /**
  22586. * Creates a polygon mesh
  22587. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22588. * * 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
  22589. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22591. * * 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)
  22592. * * Remember you can only change the shape positions, not their number when updating a polygon
  22593. * @param name defines the name of the mesh
  22594. * @param options defines the options used to create the mesh
  22595. * @param scene defines the hosting scene
  22596. * @returns the polygon mesh
  22597. */
  22598. static CreatePolygon(name: string, options: {
  22599. shape: Vector3[];
  22600. holes?: Vector3[][];
  22601. depth?: number;
  22602. faceUV?: Vector4[];
  22603. faceColors?: Color4[];
  22604. updatable?: boolean;
  22605. sideOrientation?: number;
  22606. frontUVs?: Vector4;
  22607. backUVs?: Vector4;
  22608. }, scene: Scene): Mesh;
  22609. /**
  22610. * Creates an extruded polygon mesh, with depth in the Y direction.
  22611. * * 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)
  22612. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22613. * @param name defines the name of the mesh
  22614. * @param options defines the options used to create the mesh
  22615. * @param scene defines the hosting scene
  22616. * @returns the polygon mesh
  22617. */
  22618. static ExtrudePolygon(name: string, options: {
  22619. shape: Vector3[];
  22620. holes?: Vector3[][];
  22621. depth?: number;
  22622. faceUV?: Vector4[];
  22623. faceColors?: Color4[];
  22624. updatable?: boolean;
  22625. sideOrientation?: number;
  22626. frontUVs?: Vector4;
  22627. backUVs?: Vector4;
  22628. }, scene: Scene): Mesh;
  22629. /**
  22630. * Creates a tube mesh.
  22631. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22632. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22633. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22634. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22635. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22636. * * 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)
  22637. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22638. * * 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
  22639. * * 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
  22640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22644. * @param name defines the name of the mesh
  22645. * @param options defines the options used to create the mesh
  22646. * @param scene defines the hosting scene
  22647. * @returns the tube mesh
  22648. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22649. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22650. */
  22651. static CreateTube(name: string, options: {
  22652. path: Vector3[];
  22653. radius?: number;
  22654. tessellation?: number;
  22655. radiusFunction?: {
  22656. (i: number, distance: number): number;
  22657. };
  22658. cap?: number;
  22659. arc?: number;
  22660. updatable?: boolean;
  22661. sideOrientation?: number;
  22662. frontUVs?: Vector4;
  22663. backUVs?: Vector4;
  22664. instance?: Mesh;
  22665. invertUV?: boolean;
  22666. }, scene: Scene): Mesh;
  22667. /**
  22668. * Creates a polyhedron mesh
  22669. * * 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
  22670. * * The parameter `size` (positive float, default 1) sets the polygon size
  22671. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22672. * * 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`
  22673. * * 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
  22674. * * 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)`)
  22675. * * 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
  22676. * * 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
  22677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22680. * @param name defines the name of the mesh
  22681. * @param options defines the options used to create the mesh
  22682. * @param scene defines the hosting scene
  22683. * @returns the polyhedron mesh
  22684. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22685. */
  22686. static CreatePolyhedron(name: string, options: {
  22687. type?: number;
  22688. size?: number;
  22689. sizeX?: number;
  22690. sizeY?: number;
  22691. sizeZ?: number;
  22692. custom?: any;
  22693. faceUV?: Vector4[];
  22694. faceColors?: Color4[];
  22695. flat?: boolean;
  22696. updatable?: boolean;
  22697. sideOrientation?: number;
  22698. frontUVs?: Vector4;
  22699. backUVs?: Vector4;
  22700. }, scene: Scene): Mesh;
  22701. /**
  22702. * Creates a decal mesh.
  22703. * 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
  22704. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22705. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22706. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22707. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22708. * @param name defines the name of the mesh
  22709. * @param sourceMesh defines the mesh where the decal must be applied
  22710. * @param options defines the options used to create the mesh
  22711. * @param scene defines the hosting scene
  22712. * @returns the decal mesh
  22713. * @see http://doc.babylonjs.com/how_to/decals
  22714. */
  22715. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22716. position?: Vector3;
  22717. normal?: Vector3;
  22718. size?: Vector3;
  22719. angle?: number;
  22720. }): Mesh;
  22721. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22722. }
  22723. }
  22724. declare module BABYLON {
  22725. class MeshLODLevel {
  22726. distance: number;
  22727. mesh: Nullable<Mesh>;
  22728. constructor(distance: number, mesh: Nullable<Mesh>);
  22729. }
  22730. }
  22731. declare module BABYLON {
  22732. /**
  22733. * A simplifier interface for future simplification implementations.
  22734. */
  22735. interface ISimplifier {
  22736. /**
  22737. * Simplification of a given mesh according to the given settings.
  22738. * Since this requires computation, it is assumed that the function runs async.
  22739. * @param settings The settings of the simplification, including quality and distance
  22740. * @param successCallback A callback that will be called after the mesh was simplified.
  22741. * @param errorCallback in case of an error, this callback will be called. optional.
  22742. */
  22743. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22744. }
  22745. /**
  22746. * Expected simplification settings.
  22747. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22748. */
  22749. interface ISimplificationSettings {
  22750. quality: number;
  22751. distance: number;
  22752. optimizeMesh?: boolean;
  22753. }
  22754. class SimplificationSettings implements ISimplificationSettings {
  22755. quality: number;
  22756. distance: number;
  22757. optimizeMesh: boolean | undefined;
  22758. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22759. }
  22760. interface ISimplificationTask {
  22761. settings: Array<ISimplificationSettings>;
  22762. simplificationType: SimplificationType;
  22763. mesh: Mesh;
  22764. successCallback?: () => void;
  22765. parallelProcessing: boolean;
  22766. }
  22767. class SimplificationQueue {
  22768. private _simplificationArray;
  22769. running: boolean;
  22770. constructor();
  22771. addTask(task: ISimplificationTask): void;
  22772. executeNext(): void;
  22773. runSimplification(task: ISimplificationTask): void;
  22774. private getSimplifier(task);
  22775. }
  22776. /**
  22777. * The implemented types of simplification
  22778. * At the moment only Quadratic Error Decimation is implemented
  22779. */
  22780. enum SimplificationType {
  22781. /** Quadratic error decimation */
  22782. QUADRATIC = 0,
  22783. }
  22784. class DecimationTriangle {
  22785. vertices: Array<DecimationVertex>;
  22786. normal: Vector3;
  22787. error: Array<number>;
  22788. deleted: boolean;
  22789. isDirty: boolean;
  22790. borderFactor: number;
  22791. deletePending: boolean;
  22792. originalOffset: number;
  22793. constructor(vertices: Array<DecimationVertex>);
  22794. }
  22795. class DecimationVertex {
  22796. position: Vector3;
  22797. id: number;
  22798. q: QuadraticMatrix;
  22799. isBorder: boolean;
  22800. triangleStart: number;
  22801. triangleCount: number;
  22802. originalOffsets: Array<number>;
  22803. constructor(position: Vector3, id: number);
  22804. updatePosition(newPosition: Vector3): void;
  22805. }
  22806. class QuadraticMatrix {
  22807. data: Array<number>;
  22808. constructor(data?: Array<number>);
  22809. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22810. addInPlace(matrix: QuadraticMatrix): void;
  22811. addArrayInPlace(data: Array<number>): void;
  22812. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22813. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22814. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22815. }
  22816. class Reference {
  22817. vertexId: number;
  22818. triangleId: number;
  22819. constructor(vertexId: number, triangleId: number);
  22820. }
  22821. /**
  22822. * An implementation of the Quadratic Error simplification algorithm.
  22823. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22824. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22825. * @author RaananW
  22826. */
  22827. class QuadraticErrorSimplification implements ISimplifier {
  22828. private _mesh;
  22829. private triangles;
  22830. private vertices;
  22831. private references;
  22832. private _reconstructedMesh;
  22833. syncIterations: number;
  22834. aggressiveness: number;
  22835. decimationIterations: number;
  22836. boundingBoxEpsilon: number;
  22837. constructor(_mesh: Mesh);
  22838. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22839. private runDecimation(settings, submeshIndex, successCallback);
  22840. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22841. private init(callback);
  22842. private reconstructMesh(submeshIndex);
  22843. private initDecimatedMesh();
  22844. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22845. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22846. private identifyBorder();
  22847. private updateMesh(identifyBorders?);
  22848. private vertexError(q, point);
  22849. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22850. }
  22851. }
  22852. declare module BABYLON {
  22853. class Polygon {
  22854. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22855. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22856. static Parse(input: string): Vector2[];
  22857. static StartingAt(x: number, y: number): Path2;
  22858. }
  22859. class PolygonMeshBuilder {
  22860. private _points;
  22861. private _outlinepoints;
  22862. private _holes;
  22863. private _name;
  22864. private _scene;
  22865. private _epoints;
  22866. private _eholes;
  22867. private _addToepoint(points);
  22868. constructor(name: string, contours: Path2, scene: Scene);
  22869. constructor(name: string, contours: Vector2[], scene: Scene);
  22870. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22871. build(updatable?: boolean, depth?: number): Mesh;
  22872. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22873. }
  22874. }
  22875. declare module BABYLON {
  22876. class BaseSubMesh {
  22877. _materialDefines: Nullable<MaterialDefines>;
  22878. _materialEffect: Nullable<Effect>;
  22879. readonly effect: Nullable<Effect>;
  22880. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22881. }
  22882. class SubMesh extends BaseSubMesh implements ICullable {
  22883. materialIndex: number;
  22884. verticesStart: number;
  22885. verticesCount: number;
  22886. indexStart: number;
  22887. indexCount: number;
  22888. linesIndexCount: number;
  22889. private _mesh;
  22890. private _renderingMesh;
  22891. private _boundingInfo;
  22892. private _linesIndexBuffer;
  22893. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22894. _trianglePlanes: Plane[];
  22895. _lastColliderTransformMatrix: Matrix;
  22896. _renderId: number;
  22897. _alphaIndex: number;
  22898. _distanceToCamera: number;
  22899. _id: number;
  22900. private _currentMaterial;
  22901. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22902. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22903. readonly IsGlobal: boolean;
  22904. /**
  22905. * Returns the submesh BoudingInfo object.
  22906. */
  22907. getBoundingInfo(): BoundingInfo;
  22908. /**
  22909. * Sets the submesh BoundingInfo.
  22910. * Return the SubMesh.
  22911. */
  22912. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22913. /**
  22914. * Returns the mesh of the current submesh.
  22915. */
  22916. getMesh(): AbstractMesh;
  22917. /**
  22918. * Returns the rendering mesh of the submesh.
  22919. */
  22920. getRenderingMesh(): Mesh;
  22921. /**
  22922. * Returns the submesh material.
  22923. */
  22924. getMaterial(): Nullable<Material>;
  22925. /**
  22926. * Sets a new updated BoundingInfo object to the submesh.
  22927. * Returns the SubMesh.
  22928. */
  22929. refreshBoundingInfo(): SubMesh;
  22930. _checkCollision(collider: Collider): boolean;
  22931. /**
  22932. * Updates the submesh BoundingInfo.
  22933. * Returns the Submesh.
  22934. */
  22935. updateBoundingInfo(world: Matrix): SubMesh;
  22936. /**
  22937. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22938. * Boolean returned.
  22939. */
  22940. isInFrustum(frustumPlanes: Plane[]): boolean;
  22941. /**
  22942. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22943. * Boolean returned.
  22944. */
  22945. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22946. /**
  22947. * Renders the submesh.
  22948. * Returns it.
  22949. */
  22950. render(enableAlphaMode: boolean): SubMesh;
  22951. /**
  22952. * Returns a new Index Buffer.
  22953. * Type returned : WebGLBuffer.
  22954. */
  22955. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22956. /**
  22957. * True is the passed Ray intersects the submesh bounding box.
  22958. * Boolean returned.
  22959. */
  22960. canIntersects(ray: Ray): boolean;
  22961. /**
  22962. * Returns an object IntersectionInfo.
  22963. */
  22964. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22965. _rebuild(): void;
  22966. /**
  22967. * Creates a new Submesh from the passed Mesh.
  22968. */
  22969. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22970. /**
  22971. * Disposes the Submesh.
  22972. * Returns nothing.
  22973. */
  22974. dispose(): void;
  22975. /**
  22976. * Creates a new Submesh from the passed parameters :
  22977. * - materialIndex (integer) : the index of the main mesh material.
  22978. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22979. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22980. * - mesh (Mesh) : the main mesh to create the submesh from.
  22981. * - renderingMesh (optional Mesh) : rendering mesh.
  22982. */
  22983. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22984. }
  22985. }
  22986. declare module BABYLON {
  22987. class TransformNode extends Node {
  22988. static BILLBOARDMODE_NONE: number;
  22989. static BILLBOARDMODE_X: number;
  22990. static BILLBOARDMODE_Y: number;
  22991. static BILLBOARDMODE_Z: number;
  22992. static BILLBOARDMODE_ALL: number;
  22993. private _forward;
  22994. private _forwardInverted;
  22995. private _up;
  22996. private _right;
  22997. private _rightInverted;
  22998. private _rotation;
  22999. private _rotationQuaternion;
  23000. protected _scaling: Vector3;
  23001. protected _isDirty: boolean;
  23002. private _transformToBoneReferal;
  23003. /**
  23004. * Set the billboard mode. Default is 0.
  23005. *
  23006. * | Value | Type | Description |
  23007. * | --- | --- | --- |
  23008. * | 0 | BILLBOARDMODE_NONE | |
  23009. * | 1 | BILLBOARDMODE_X | |
  23010. * | 2 | BILLBOARDMODE_Y | |
  23011. * | 4 | BILLBOARDMODE_Z | |
  23012. * | 7 | BILLBOARDMODE_ALL | |
  23013. *
  23014. */
  23015. billboardMode: number;
  23016. scalingDeterminant: number;
  23017. infiniteDistance: boolean;
  23018. /**
  23019. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23020. * By default the system will update normals to compensate
  23021. */
  23022. ignoreNonUniformScaling: boolean;
  23023. position: Vector3;
  23024. _poseMatrix: Matrix;
  23025. private _localWorld;
  23026. _worldMatrix: Matrix;
  23027. _worldMatrixDeterminant: number;
  23028. private _absolutePosition;
  23029. private _pivotMatrix;
  23030. private _pivotMatrixInverse;
  23031. private _postMultiplyPivotMatrix;
  23032. protected _isWorldMatrixFrozen: boolean;
  23033. /**
  23034. * An event triggered after the world matrix is updated
  23035. */
  23036. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23037. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23038. /**
  23039. * Gets a string idenfifying the name of the class
  23040. * @returns "TransformNode" string
  23041. */
  23042. getClassName(): string;
  23043. /**
  23044. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23045. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23046. * Default : (0.0, 0.0, 0.0)
  23047. */
  23048. rotation: Vector3;
  23049. /**
  23050. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23051. * Default : (1.0, 1.0, 1.0)
  23052. */
  23053. /**
  23054. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23055. * Default : (1.0, 1.0, 1.0)
  23056. */
  23057. scaling: Vector3;
  23058. /**
  23059. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23060. * It's null by default.
  23061. * 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)
  23062. */
  23063. rotationQuaternion: Nullable<Quaternion>;
  23064. /**
  23065. * The forward direction of that transform in world space.
  23066. */
  23067. readonly forward: Vector3;
  23068. /**
  23069. * The up direction of that transform in world space.
  23070. */
  23071. readonly up: Vector3;
  23072. /**
  23073. * The right direction of that transform in world space.
  23074. */
  23075. readonly right: Vector3;
  23076. /**
  23077. * Returns the latest update of the World matrix
  23078. * Returns a Matrix.
  23079. */
  23080. getWorldMatrix(): Matrix;
  23081. /** @hidden */
  23082. _getWorldMatrixDeterminant(): number;
  23083. /**
  23084. * Returns directly the latest state of the mesh World matrix.
  23085. * A Matrix is returned.
  23086. */
  23087. readonly worldMatrixFromCache: Matrix;
  23088. /**
  23089. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23090. * Returns the TransformNode.
  23091. */
  23092. updatePoseMatrix(matrix: Matrix): TransformNode;
  23093. /**
  23094. * Returns the mesh Pose matrix.
  23095. * Returned object : Matrix
  23096. */
  23097. getPoseMatrix(): Matrix;
  23098. _isSynchronized(): boolean;
  23099. _initCache(): void;
  23100. markAsDirty(property: string): TransformNode;
  23101. /**
  23102. * Returns the current mesh absolute position.
  23103. * Retuns a Vector3.
  23104. */
  23105. readonly absolutePosition: Vector3;
  23106. /**
  23107. * Sets a new matrix to apply before all other transformation
  23108. * @param matrix defines the transform matrix
  23109. * @returns the current TransformNode
  23110. */
  23111. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23112. /**
  23113. * Sets a new pivot matrix to the current node
  23114. * @param matrix defines the new pivot matrix to use
  23115. * @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
  23116. * @returns the current TransformNode
  23117. */
  23118. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23119. /**
  23120. * Returns the mesh pivot matrix.
  23121. * Default : Identity.
  23122. * A Matrix is returned.
  23123. */
  23124. getPivotMatrix(): Matrix;
  23125. /**
  23126. * Prevents the World matrix to be computed any longer.
  23127. * Returns the TransformNode.
  23128. */
  23129. freezeWorldMatrix(): TransformNode;
  23130. /**
  23131. * Allows back the World matrix computation.
  23132. * Returns the TransformNode.
  23133. */
  23134. unfreezeWorldMatrix(): this;
  23135. /**
  23136. * True if the World matrix has been frozen.
  23137. * Returns a boolean.
  23138. */
  23139. readonly isWorldMatrixFrozen: boolean;
  23140. /**
  23141. * Retuns the mesh absolute position in the World.
  23142. * Returns a Vector3.
  23143. */
  23144. getAbsolutePosition(): Vector3;
  23145. /**
  23146. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23147. * Returns the TransformNode.
  23148. */
  23149. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23150. /**
  23151. * Sets the mesh position in its local space.
  23152. * Returns the TransformNode.
  23153. */
  23154. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23155. /**
  23156. * Returns the mesh position in the local space from the current World matrix values.
  23157. * Returns a new Vector3.
  23158. */
  23159. getPositionExpressedInLocalSpace(): Vector3;
  23160. /**
  23161. * Translates the mesh along the passed Vector3 in its local space.
  23162. * Returns the TransformNode.
  23163. */
  23164. locallyTranslate(vector3: Vector3): TransformNode;
  23165. private static _lookAtVectorCache;
  23166. /**
  23167. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23168. * @param targetPoint the position (must be in same space as current mesh) to look at
  23169. * @param yawCor optional yaw (y-axis) correction in radians
  23170. * @param pitchCor optional pitch (x-axis) correction in radians
  23171. * @param rollCor optional roll (z-axis) correction in radians
  23172. * @param space the choosen space of the target
  23173. * @returns the TransformNode.
  23174. */
  23175. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23176. /**
  23177. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23178. * This Vector3 is expressed in the World space.
  23179. */
  23180. getDirection(localAxis: Vector3): Vector3;
  23181. /**
  23182. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23183. * localAxis is expressed in the mesh local space.
  23184. * result is computed in the Wordl space from the mesh World matrix.
  23185. * Returns the TransformNode.
  23186. */
  23187. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23188. /**
  23189. * Sets a new pivot point to the current node
  23190. * @param point defines the new pivot point to use
  23191. * @param space defines if the point is in world or local space (local by default)
  23192. * @returns the current TransformNode
  23193. */
  23194. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23195. /**
  23196. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23197. */
  23198. getPivotPoint(): Vector3;
  23199. /**
  23200. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23201. * Returns the TransformNode.
  23202. */
  23203. getPivotPointToRef(result: Vector3): TransformNode;
  23204. /**
  23205. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23206. */
  23207. getAbsolutePivotPoint(): Vector3;
  23208. /**
  23209. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23210. * Returns the TransformNode.
  23211. */
  23212. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23213. /**
  23214. * Defines the passed node as the parent of the current node.
  23215. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23216. * Returns the TransformNode.
  23217. */
  23218. setParent(node: Nullable<Node>): TransformNode;
  23219. private _nonUniformScaling;
  23220. readonly nonUniformScaling: boolean;
  23221. _updateNonUniformScalingState(value: boolean): boolean;
  23222. /**
  23223. * Attach the current TransformNode to another TransformNode associated with a bone
  23224. * @param bone Bone affecting the TransformNode
  23225. * @param affectedTransformNode TransformNode associated with the bone
  23226. */
  23227. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23228. detachFromBone(): TransformNode;
  23229. private static _rotationAxisCache;
  23230. /**
  23231. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23232. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23233. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23234. * The passed axis is also normalized.
  23235. * Returns the TransformNode.
  23236. */
  23237. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23238. /**
  23239. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23240. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23241. * The passed axis is also normalized.
  23242. * Returns the TransformNode.
  23243. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23244. */
  23245. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23246. /**
  23247. * Translates the mesh along the axis vector for the passed distance in the given space.
  23248. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23249. * Returns the TransformNode.
  23250. */
  23251. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23252. /**
  23253. * Adds a rotation step to the mesh current rotation.
  23254. * x, y, z are Euler angles expressed in radians.
  23255. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23256. * This means this rotation is made in the mesh local space only.
  23257. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23258. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23259. * ```javascript
  23260. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23261. * ```
  23262. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23263. * 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.
  23264. * Returns the TransformNode.
  23265. */
  23266. addRotation(x: number, y: number, z: number): TransformNode;
  23267. /**
  23268. * Computes the mesh World matrix and returns it.
  23269. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23270. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23271. * If the parameter `force`is set to `true`, the actual computation is done.
  23272. * Returns the mesh World Matrix.
  23273. */
  23274. computeWorldMatrix(force?: boolean): Matrix;
  23275. protected _afterComputeWorldMatrix(): void;
  23276. /**
  23277. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23278. * @param func: callback function to add
  23279. *
  23280. * Returns the TransformNode.
  23281. */
  23282. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23283. /**
  23284. * Removes a registered callback function.
  23285. * Returns the TransformNode.
  23286. */
  23287. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23288. /**
  23289. * Clone the current transform node
  23290. * Returns the new transform node
  23291. * @param name Name of the new clone
  23292. * @param newParent New parent for the clone
  23293. * @param doNotCloneChildren Do not clone children hierarchy
  23294. */
  23295. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23296. serialize(currentSerializationObject?: any): any;
  23297. /**
  23298. * Returns a new TransformNode object parsed from the source provided.
  23299. * The parameter `parsedMesh` is the source.
  23300. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23301. */
  23302. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23303. /**
  23304. * Releases resources associated with this transform node.
  23305. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23306. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23307. */
  23308. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23309. }
  23310. }
  23311. declare module BABYLON {
  23312. class VertexBuffer {
  23313. /** @hidden */
  23314. _buffer: Buffer;
  23315. private _kind;
  23316. private _size;
  23317. private _ownsBuffer;
  23318. private _instanced;
  23319. private _instanceDivisor;
  23320. /**
  23321. * The byte type.
  23322. */
  23323. static readonly BYTE: number;
  23324. /**
  23325. * The unsigned byte type.
  23326. */
  23327. static readonly UNSIGNED_BYTE: number;
  23328. /**
  23329. * The short type.
  23330. */
  23331. static readonly SHORT: number;
  23332. /**
  23333. * The unsigned short type.
  23334. */
  23335. static readonly UNSIGNED_SHORT: number;
  23336. /**
  23337. * The integer type.
  23338. */
  23339. static readonly INT: number;
  23340. /**
  23341. * The unsigned integer type.
  23342. */
  23343. static readonly UNSIGNED_INT: number;
  23344. /**
  23345. * The float type.
  23346. */
  23347. static readonly FLOAT: number;
  23348. /**
  23349. * Gets or sets the instance divisor when in instanced mode
  23350. */
  23351. instanceDivisor: number;
  23352. /**
  23353. * Gets the byte stride.
  23354. */
  23355. readonly byteStride: number;
  23356. /**
  23357. * Gets the byte offset.
  23358. */
  23359. readonly byteOffset: number;
  23360. /**
  23361. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23362. */
  23363. readonly normalized: boolean;
  23364. /**
  23365. * Gets the data type of each component in the array.
  23366. */
  23367. readonly type: number;
  23368. /**
  23369. * Constructor
  23370. * @param engine the engine
  23371. * @param data the data to use for this vertex buffer
  23372. * @param kind the vertex buffer kind
  23373. * @param updatable whether the data is updatable
  23374. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23375. * @param stride the stride (optional)
  23376. * @param instanced whether the buffer is instanced (optional)
  23377. * @param offset the offset of the data (optional)
  23378. * @param size the number of components (optional)
  23379. * @param type the type of the component (optional)
  23380. * @param normalized whether the data contains normalized data (optional)
  23381. * @param useBytes set to true if stride and offset are in bytes (optional)
  23382. */
  23383. 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);
  23384. _rebuild(): void;
  23385. /**
  23386. * Returns the kind of the VertexBuffer (string).
  23387. */
  23388. getKind(): string;
  23389. /**
  23390. * Boolean : is the VertexBuffer updatable ?
  23391. */
  23392. isUpdatable(): boolean;
  23393. /**
  23394. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23395. */
  23396. getData(): Nullable<DataArray>;
  23397. /**
  23398. * Returns the WebGLBuffer associated to the VertexBuffer.
  23399. */
  23400. getBuffer(): Nullable<WebGLBuffer>;
  23401. /**
  23402. * Returns the stride as a multiple of the type byte length.
  23403. * DEPRECATED. Use byteStride instead.
  23404. */
  23405. getStrideSize(): number;
  23406. /**
  23407. * Returns the offset as a multiple of the type byte length.
  23408. * DEPRECATED. Use byteOffset instead.
  23409. */
  23410. getOffset(): number;
  23411. /**
  23412. * Returns the number of components per vertex attribute (integer).
  23413. */
  23414. getSize(): number;
  23415. /**
  23416. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23417. */
  23418. getIsInstanced(): boolean;
  23419. /**
  23420. * Returns the instancing divisor, zero for non-instanced (integer).
  23421. */
  23422. getInstanceDivisor(): number;
  23423. /**
  23424. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23425. * Returns the created WebGLBuffer.
  23426. */
  23427. create(data?: DataArray): void;
  23428. /**
  23429. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23430. * This function will create a new buffer if the current one is not updatable
  23431. * Returns the updated WebGLBuffer.
  23432. */
  23433. update(data: DataArray): void;
  23434. /**
  23435. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23436. * Returns the directly updated WebGLBuffer.
  23437. * @param data the new data
  23438. * @param offset the new offset
  23439. * @param useBytes set to true if the offset is in bytes
  23440. */
  23441. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23442. /**
  23443. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23444. */
  23445. dispose(): void;
  23446. /**
  23447. * Enumerates each value of this vertex buffer as numbers.
  23448. * @param count the number of values to enumerate
  23449. * @param callback the callback function called for each value
  23450. */
  23451. forEach(count: number, callback: (value: number, index: number) => void): void;
  23452. private static _PositionKind;
  23453. private static _NormalKind;
  23454. private static _TangentKind;
  23455. private static _UVKind;
  23456. private static _UV2Kind;
  23457. private static _UV3Kind;
  23458. private static _UV4Kind;
  23459. private static _UV5Kind;
  23460. private static _UV6Kind;
  23461. private static _ColorKind;
  23462. private static _MatricesIndicesKind;
  23463. private static _MatricesWeightsKind;
  23464. private static _MatricesIndicesExtraKind;
  23465. private static _MatricesWeightsExtraKind;
  23466. static readonly PositionKind: string;
  23467. static readonly NormalKind: string;
  23468. static readonly TangentKind: string;
  23469. static readonly UVKind: string;
  23470. static readonly UV2Kind: string;
  23471. static readonly UV3Kind: string;
  23472. static readonly UV4Kind: string;
  23473. static readonly UV5Kind: string;
  23474. static readonly UV6Kind: string;
  23475. static readonly ColorKind: string;
  23476. static readonly MatricesIndicesKind: string;
  23477. static readonly MatricesWeightsKind: string;
  23478. static readonly MatricesIndicesExtraKind: string;
  23479. static readonly MatricesWeightsExtraKind: string;
  23480. /**
  23481. * Deduces the stride given a kind.
  23482. * @param kind The kind string to deduce
  23483. * @returns The deduced stride
  23484. */
  23485. static DeduceStride(kind: string): number;
  23486. /**
  23487. * Gets the byte length of the given type.
  23488. * @param type the type
  23489. * @returns the number of bytes
  23490. */
  23491. static GetTypeByteLength(type: number): number;
  23492. /**
  23493. * Enumerates each value of the given parameters as numbers.
  23494. * @param data the data to enumerate
  23495. * @param byteOffset the byte offset of the data
  23496. * @param byteStride the byte stride of the data
  23497. * @param componentCount the number of components per element
  23498. * @param componentType the type of the component
  23499. * @param count the total number of components
  23500. * @param normalized whether the data is normalized
  23501. * @param callback the callback function called for each value
  23502. */
  23503. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23504. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23505. }
  23506. }
  23507. declare module BABYLON {
  23508. /**
  23509. * This represents a GPU particle system in Babylon
  23510. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23511. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23512. */
  23513. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23514. /**
  23515. * The id of the Particle system.
  23516. */
  23517. id: string;
  23518. /**
  23519. * The friendly name of the Particle system.
  23520. */
  23521. name: string;
  23522. /**
  23523. * The emitter represents the Mesh or position we are attaching the particle system to.
  23524. */
  23525. emitter: Nullable<AbstractMesh | Vector3>;
  23526. /**
  23527. * The rendering group used by the Particle system to chose when to render.
  23528. */
  23529. renderingGroupId: number;
  23530. /**
  23531. * The layer mask we are rendering the particles through.
  23532. */
  23533. layerMask: number;
  23534. private _capacity;
  23535. private _activeCount;
  23536. private _currentActiveCount;
  23537. private _accumulatedCount;
  23538. private _renderEffect;
  23539. private _updateEffect;
  23540. private _buffer0;
  23541. private _buffer1;
  23542. private _spriteBuffer;
  23543. private _updateVAO;
  23544. private _renderVAO;
  23545. private _targetIndex;
  23546. private _sourceBuffer;
  23547. private _targetBuffer;
  23548. private _scene;
  23549. private _engine;
  23550. private _currentRenderId;
  23551. private _started;
  23552. private _stopped;
  23553. private _timeDelta;
  23554. private _randomTexture;
  23555. private _randomTexture2;
  23556. private _attributesStrideSize;
  23557. private _updateEffectOptions;
  23558. private _randomTextureSize;
  23559. private _actualFrame;
  23560. /**
  23561. * List of animations used by the particle system.
  23562. */
  23563. animations: Animation[];
  23564. /**
  23565. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23566. */
  23567. static readonly IsSupported: boolean;
  23568. /**
  23569. * An event triggered when the system is disposed.
  23570. */
  23571. onDisposeObservable: Observable<GPUParticleSystem>;
  23572. /**
  23573. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23574. */
  23575. updateSpeed: number;
  23576. /**
  23577. * The amount of time the particle system is running (depends of the overall update speed).
  23578. */
  23579. targetStopDuration: number;
  23580. /**
  23581. * The texture used to render each particle. (this can be a spritesheet)
  23582. */
  23583. particleTexture: Nullable<Texture>;
  23584. /**
  23585. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23586. */
  23587. blendMode: number;
  23588. /**
  23589. * Minimum life time of emitting particles.
  23590. */
  23591. minLifeTime: number;
  23592. /**
  23593. * Maximum life time of emitting particles.
  23594. */
  23595. maxLifeTime: number;
  23596. /**
  23597. * Minimum Size of emitting particles.
  23598. */
  23599. minSize: number;
  23600. /**
  23601. * Maximum Size of emitting particles.
  23602. */
  23603. maxSize: number;
  23604. /**
  23605. * Minimum scale of emitting particles on X axis.
  23606. */
  23607. minScaleX: number;
  23608. /**
  23609. * Maximum scale of emitting particles on X axis.
  23610. */
  23611. maxScaleX: number;
  23612. /**
  23613. * Minimum scale of emitting particles on Y axis.
  23614. */
  23615. minScaleY: number;
  23616. /**
  23617. * Maximum scale of emitting particles on Y axis.
  23618. */
  23619. maxScaleY: number;
  23620. /**
  23621. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23622. */
  23623. color1: Color4;
  23624. /**
  23625. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23626. */
  23627. color2: Color4;
  23628. /**
  23629. * Color the particle will have at the end of its lifetime.
  23630. */
  23631. colorDead: Color4;
  23632. /**
  23633. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23634. */
  23635. emitRate: number;
  23636. /**
  23637. * You can use gravity if you want to give an orientation to your particles.
  23638. */
  23639. gravity: Vector3;
  23640. /**
  23641. * Minimum power of emitting particles.
  23642. */
  23643. minEmitPower: number;
  23644. /**
  23645. * Maximum power of emitting particles.
  23646. */
  23647. maxEmitPower: number;
  23648. /**
  23649. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23650. */
  23651. minAngularSpeed: number;
  23652. /**
  23653. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23654. */
  23655. maxAngularSpeed: number;
  23656. /**
  23657. * The particle emitter type defines the emitter used by the particle system.
  23658. * It can be for example box, sphere, or cone...
  23659. */
  23660. particleEmitterType: Nullable<IParticleEmitterType>;
  23661. /**
  23662. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23663. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23664. */
  23665. direction1: Vector3;
  23666. /**
  23667. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23668. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23669. */
  23670. direction2: Vector3;
  23671. /**
  23672. * 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.
  23673. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23674. */
  23675. minEmitBox: Vector3;
  23676. /**
  23677. * 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.
  23678. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23679. */
  23680. maxEmitBox: Vector3;
  23681. /**
  23682. * Gets the maximum number of particles active at the same time.
  23683. * @returns The max number of active particles.
  23684. */
  23685. getCapacity(): number;
  23686. /**
  23687. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23688. * to override the particles.
  23689. */
  23690. forceDepthWrite: boolean;
  23691. /**
  23692. * Gets or set the number of active particles
  23693. */
  23694. activeParticleCount: number;
  23695. private _preWarmDone;
  23696. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  23697. preWarmCycles: number;
  23698. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  23699. preWarmStepOffset: number;
  23700. /**
  23701. * Gets or sets the minimal initial rotation in radians.
  23702. */
  23703. minInitialRotation: number;
  23704. /**
  23705. * Gets or sets the maximal initial rotation in radians.
  23706. */
  23707. maxInitialRotation: number;
  23708. /**
  23709. * Is this system ready to be used/rendered
  23710. * @return true if the system is ready
  23711. */
  23712. isReady(): boolean;
  23713. /**
  23714. * Gets Wether the system has been started.
  23715. * @returns True if it has been started, otherwise false.
  23716. */
  23717. isStarted(): boolean;
  23718. /**
  23719. * Starts the particle system and begins to emit.
  23720. */
  23721. start(): void;
  23722. /**
  23723. * Stops the particle system.
  23724. */
  23725. stop(): void;
  23726. /**
  23727. * Remove all active particles
  23728. */
  23729. reset(): void;
  23730. /**
  23731. * Returns the string "GPUParticleSystem"
  23732. * @returns a string containing the class name
  23733. */
  23734. getClassName(): string;
  23735. private _isBillboardBased;
  23736. /**
  23737. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  23738. */
  23739. isBillboardBased: boolean;
  23740. private _colorGradients;
  23741. private _colorGradientsTexture;
  23742. /**
  23743. * Gets the current list of color gradients.
  23744. * You must use addColorGradient and removeColorGradient to udpate this list
  23745. * @returns the list of color gradients
  23746. */
  23747. getColorGradients(): Nullable<Array<ColorGradient>>;
  23748. /**
  23749. * Gets the current list of size gradients.
  23750. * You must use addSizeGradient and removeSizeGradient to udpate this list
  23751. * @returns the list of size gradients
  23752. */
  23753. getSizeGradients(): Nullable<Array<FactorGradient>>;
  23754. /**
  23755. * Adds a new color gradient
  23756. * @param gradient defines the gradient to use (between 0 and 1)
  23757. * @param color defines the color to affect to the specified gradient
  23758. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  23759. */
  23760. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  23761. /**
  23762. * Remove a specific color gradient
  23763. * @param gradient defines the gradient to remove
  23764. */
  23765. removeColorGradient(gradient: number): GPUParticleSystem;
  23766. private _sizeGradients;
  23767. private _sizeGradientsTexture;
  23768. /**
  23769. * Adds a new size gradient
  23770. * @param gradient defines the gradient to use (between 0 and 1)
  23771. * @param factor defines the size factor to affect to the specified gradient
  23772. */
  23773. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  23774. /**
  23775. * Remove a specific size gradient
  23776. * @param gradient defines the gradient to remove
  23777. */
  23778. removeSizeGradient(gradient: number): GPUParticleSystem;
  23779. /**
  23780. * Instantiates a GPU particle system.
  23781. * 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.
  23782. * @param name The name of the particle system
  23783. * @param capacity The max number of particles alive at the same time
  23784. * @param scene The scene the particle system belongs to
  23785. */
  23786. constructor(name: string, options: Partial<{
  23787. capacity: number;
  23788. randomTextureSize: number;
  23789. }>, scene: Scene);
  23790. private _createUpdateVAO(source);
  23791. private _createRenderVAO(source, spriteSource);
  23792. private _initialize(force?);
  23793. /** @hidden */
  23794. _recreateUpdateEffect(): void;
  23795. /** @hidden */
  23796. _recreateRenderEffect(): void;
  23797. /**
  23798. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23799. * @param preWarm defines if we are in the pre-warmimg phase
  23800. */
  23801. animate(preWarm?: boolean): void;
  23802. private _createSizeGradientTexture();
  23803. private _createColorGradientTexture();
  23804. /**
  23805. * Renders the particle system in its current state
  23806. * @param preWarm defines if the system should only update the particles but not render them
  23807. * @returns the current number of particles
  23808. */
  23809. render(preWarm?: boolean): number;
  23810. /**
  23811. * Rebuilds the particle system
  23812. */
  23813. rebuild(): void;
  23814. private _releaseBuffers();
  23815. private _releaseVAOs();
  23816. /**
  23817. * Disposes the particle system and free the associated resources
  23818. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23819. */
  23820. dispose(disposeTexture?: boolean): void;
  23821. /**
  23822. * Clones the particle system.
  23823. * @param name The name of the cloned object
  23824. * @param newEmitter The new emitter to use
  23825. * @returns the cloned particle system
  23826. */
  23827. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  23828. /**
  23829. * Serializes the particle system to a JSON object.
  23830. * @returns the JSON object
  23831. */
  23832. serialize(): any;
  23833. /**
  23834. * Parses a JSON object to create a GPU particle system.
  23835. * @param parsedParticleSystem The JSON object to parse
  23836. * @param scene The scene to create the particle system in
  23837. * @param rootUrl The root url to use to load external dependencies like texture
  23838. * @returns the parsed GPU particle system
  23839. */
  23840. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  23841. }
  23842. }
  23843. declare module BABYLON {
  23844. /**
  23845. * Interface representing a particle system in Babylon.
  23846. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  23847. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  23848. */
  23849. interface IParticleSystem {
  23850. /**
  23851. * List of animations used by the particle system.
  23852. */
  23853. animations: Animation[];
  23854. /**
  23855. * The id of the Particle system.
  23856. */
  23857. id: string;
  23858. /**
  23859. * The name of the Particle system.
  23860. */
  23861. name: string;
  23862. /**
  23863. * The emitter represents the Mesh or position we are attaching the particle system to.
  23864. */
  23865. emitter: Nullable<AbstractMesh | Vector3>;
  23866. /**
  23867. * The rendering group used by the Particle system to chose when to render.
  23868. */
  23869. renderingGroupId: number;
  23870. /**
  23871. * The layer mask we are rendering the particles through.
  23872. */
  23873. layerMask: number;
  23874. /**
  23875. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23876. */
  23877. updateSpeed: number;
  23878. /**
  23879. * The amount of time the particle system is running (depends of the overall update speed).
  23880. */
  23881. targetStopDuration: number;
  23882. /**
  23883. * The texture used to render each particle. (this can be a spritesheet)
  23884. */
  23885. particleTexture: Nullable<Texture>;
  23886. /**
  23887. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23888. */
  23889. blendMode: number;
  23890. /**
  23891. * Minimum life time of emitting particles.
  23892. */
  23893. minLifeTime: number;
  23894. /**
  23895. * Maximum life time of emitting particles.
  23896. */
  23897. maxLifeTime: number;
  23898. /**
  23899. * Minimum Size of emitting particles.
  23900. */
  23901. minSize: number;
  23902. /**
  23903. * Maximum Size of emitting particles.
  23904. */
  23905. maxSize: number;
  23906. /**
  23907. * Minimum scale of emitting particles on X axis.
  23908. */
  23909. minScaleX: number;
  23910. /**
  23911. * Maximum scale of emitting particles on X axis.
  23912. */
  23913. maxScaleX: number;
  23914. /**
  23915. * Minimum scale of emitting particles on Y axis.
  23916. */
  23917. minScaleY: number;
  23918. /**
  23919. * Maximum scale of emitting particles on Y axis.
  23920. */
  23921. maxScaleY: number;
  23922. /**
  23923. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23924. */
  23925. color1: Color4;
  23926. /**
  23927. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23928. */
  23929. color2: Color4;
  23930. /**
  23931. * Color the particle will have at the end of its lifetime.
  23932. */
  23933. colorDead: Color4;
  23934. /**
  23935. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23936. */
  23937. emitRate: number;
  23938. /**
  23939. * You can use gravity if you want to give an orientation to your particles.
  23940. */
  23941. gravity: Vector3;
  23942. /**
  23943. * Minimum power of emitting particles.
  23944. */
  23945. minEmitPower: number;
  23946. /**
  23947. * Maximum power of emitting particles.
  23948. */
  23949. maxEmitPower: number;
  23950. /**
  23951. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23952. */
  23953. minAngularSpeed: number;
  23954. /**
  23955. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23956. */
  23957. maxAngularSpeed: number;
  23958. /**
  23959. * Gets or sets the minimal initial rotation in radians.
  23960. */
  23961. minInitialRotation: number;
  23962. /**
  23963. * Gets or sets the maximal initial rotation in radians.
  23964. */
  23965. maxInitialRotation: number;
  23966. /**
  23967. * The particle emitter type defines the emitter used by the particle system.
  23968. * It can be for example box, sphere, or cone...
  23969. */
  23970. particleEmitterType: Nullable<IParticleEmitterType>;
  23971. /**
  23972. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  23973. */
  23974. preWarmCycles: number;
  23975. /**
  23976. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  23977. */
  23978. preWarmStepOffset: number;
  23979. /**
  23980. * Gets the maximum number of particles active at the same time.
  23981. * @returns The max number of active particles.
  23982. */
  23983. getCapacity(): number;
  23984. /**
  23985. * Gets Wether the system has been started.
  23986. * @returns True if it has been started, otherwise false.
  23987. */
  23988. isStarted(): boolean;
  23989. /**
  23990. * Gets if the particle system has been started.
  23991. * @return true if the system has been started, otherwise false.
  23992. */
  23993. isStarted(): boolean;
  23994. /**
  23995. * Animates the particle system for this frame.
  23996. */
  23997. animate(): void;
  23998. /**
  23999. * Renders the particle system in its current state.
  24000. * @returns the current number of particles
  24001. */
  24002. render(): number;
  24003. /**
  24004. * Dispose the particle system and frees its associated resources.
  24005. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24006. */
  24007. dispose(disposeTexture?: boolean): void;
  24008. /**
  24009. * Clones the particle system.
  24010. * @param name The name of the cloned object
  24011. * @param newEmitter The new emitter to use
  24012. * @returns the cloned particle system
  24013. */
  24014. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  24015. /**
  24016. * Serializes the particle system to a JSON object.
  24017. * @returns the JSON object
  24018. */
  24019. serialize(): any;
  24020. /**
  24021. * Rebuild the particle system
  24022. */
  24023. rebuild(): void;
  24024. /**
  24025. * Starts the particle system and begins to emit.
  24026. */
  24027. start(): void;
  24028. /**
  24029. * Stops the particle system.
  24030. */
  24031. stop(): void;
  24032. /**
  24033. * Remove all active particles
  24034. */
  24035. reset(): void;
  24036. /**
  24037. * Is this system ready to be used/rendered
  24038. * @return true if the system is ready
  24039. */
  24040. isReady(): boolean;
  24041. /**
  24042. * Adds a new color gradient
  24043. * @param gradient defines the gradient to use (between 0 and 1)
  24044. * @param color defines the color to affect to the specified gradient
  24045. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24046. */
  24047. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  24048. /**
  24049. * Remove a specific color gradient
  24050. * @param gradient defines the gradient to remove
  24051. */
  24052. removeColorGradient(gradient: number): IParticleSystem;
  24053. /**
  24054. * Adds a new size gradient
  24055. * @param gradient defines the gradient to use (between 0 and 1)
  24056. * @param factor defines the size factor to affect to the specified gradient
  24057. */
  24058. addSizeGradient(gradient: number, factor: number): IParticleSystem;
  24059. /**
  24060. * Remove a specific size gradient
  24061. * @param gradient defines the gradient to remove
  24062. */
  24063. removeSizeGradient(gradient: number): IParticleSystem;
  24064. /**
  24065. * Gets the current list of color gradients.
  24066. * You must use addColorGradient and removeColorGradient to udpate this list
  24067. * @returns the list of color gradients
  24068. */
  24069. getColorGradients(): Nullable<Array<ColorGradient>>;
  24070. /**
  24071. * Gets the current list of size gradients.
  24072. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24073. * @returns the list of size gradients
  24074. */
  24075. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24076. }
  24077. }
  24078. declare module BABYLON {
  24079. /**
  24080. * A particle represents one of the element emitted by a particle system.
  24081. * This is mainly define by its coordinates, direction, velocity and age.
  24082. */
  24083. class Particle {
  24084. /**
  24085. * particleSystem the particle system the particle belongs to.
  24086. */
  24087. particleSystem: ParticleSystem;
  24088. /**
  24089. * The world position of the particle in the scene.
  24090. */
  24091. position: Vector3;
  24092. /**
  24093. * The world direction of the particle in the scene.
  24094. */
  24095. direction: Vector3;
  24096. /**
  24097. * The color of the particle.
  24098. */
  24099. color: Color4;
  24100. /**
  24101. * The color change of the particle per step.
  24102. */
  24103. colorStep: Color4;
  24104. /**
  24105. * Defines how long will the life of the particle be.
  24106. */
  24107. lifeTime: number;
  24108. /**
  24109. * The current age of the particle.
  24110. */
  24111. age: number;
  24112. /**
  24113. * The current size of the particle.
  24114. */
  24115. size: number;
  24116. /**
  24117. * The current scale of the particle.
  24118. */
  24119. scale: Vector2;
  24120. /**
  24121. * The current angle of the particle.
  24122. */
  24123. angle: number;
  24124. /**
  24125. * Defines how fast is the angle changing.
  24126. */
  24127. angularSpeed: number;
  24128. /**
  24129. * Defines the cell index used by the particle to be rendered from a sprite.
  24130. */
  24131. cellIndex: number;
  24132. private _currentFrameCounter;
  24133. /** @hidden */
  24134. _initialDirection: Nullable<Vector3>;
  24135. /** @hidden */
  24136. _initialSize: number;
  24137. /**
  24138. * Creates a new instance Particle
  24139. * @param particleSystem the particle system the particle belongs to
  24140. */
  24141. constructor(
  24142. /**
  24143. * particleSystem the particle system the particle belongs to.
  24144. */
  24145. particleSystem: ParticleSystem);
  24146. private updateCellInfoFromSystem();
  24147. /**
  24148. * Defines how the sprite cell index is updated for the particle. This is
  24149. * defined as a callback.
  24150. */
  24151. updateCellIndex: (scaledUpdateSpeed: number) => void;
  24152. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  24153. private _updateCellIndexWithCustomSpeed();
  24154. /**
  24155. * Copy the properties of particle to another one.
  24156. * @param other the particle to copy the information to.
  24157. */
  24158. copyTo(other: Particle): void;
  24159. }
  24160. }
  24161. declare module BABYLON {
  24162. /**
  24163. * This represents a particle system in Babylon.
  24164. * 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.
  24165. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24166. * @example https://doc.babylonjs.com/babylon101/particles
  24167. */
  24168. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  24169. /**
  24170. * Source color is added to the destination color without alpha affecting the result.
  24171. */
  24172. static BLENDMODE_ONEONE: number;
  24173. /**
  24174. * Blend current color and particle color using particle’s alpha.
  24175. */
  24176. static BLENDMODE_STANDARD: number;
  24177. /**
  24178. * Add current color and particle color multiplied by particle’s alpha.
  24179. */
  24180. static BLENDMODE_ADD: number;
  24181. /**
  24182. * List of animations used by the particle system.
  24183. */
  24184. animations: Animation[];
  24185. /**
  24186. * The id of the Particle system.
  24187. */
  24188. id: string;
  24189. /**
  24190. * The friendly name of the Particle system.
  24191. */
  24192. name: string;
  24193. /**
  24194. * The rendering group used by the Particle system to chose when to render.
  24195. */
  24196. renderingGroupId: number;
  24197. /**
  24198. * The emitter represents the Mesh or position we are attaching the particle system to.
  24199. */
  24200. emitter: Nullable<AbstractMesh | Vector3>;
  24201. /**
  24202. * The maximum number of particles to emit per frame
  24203. */
  24204. emitRate: number;
  24205. /**
  24206. * If you want to launch only a few particles at once, that can be done, as well.
  24207. */
  24208. manualEmitCount: number;
  24209. /**
  24210. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24211. */
  24212. updateSpeed: number;
  24213. /**
  24214. * The amount of time the particle system is running (depends of the overall update speed).
  24215. */
  24216. targetStopDuration: number;
  24217. /**
  24218. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24219. */
  24220. disposeOnStop: boolean;
  24221. /**
  24222. * Minimum power of emitting particles.
  24223. */
  24224. minEmitPower: number;
  24225. /**
  24226. * Maximum power of emitting particles.
  24227. */
  24228. maxEmitPower: number;
  24229. /**
  24230. * Minimum life time of emitting particles.
  24231. */
  24232. minLifeTime: number;
  24233. /**
  24234. * Maximum life time of emitting particles.
  24235. */
  24236. maxLifeTime: number;
  24237. /**
  24238. * Minimum Size of emitting particles.
  24239. */
  24240. minSize: number;
  24241. /**
  24242. * Maximum Size of emitting particles.
  24243. */
  24244. maxSize: number;
  24245. /**
  24246. * Minimum scale of emitting particles on X axis.
  24247. */
  24248. minScaleX: number;
  24249. /**
  24250. * Maximum scale of emitting particles on X axis.
  24251. */
  24252. maxScaleX: number;
  24253. /**
  24254. * Minimum scale of emitting particles on Y axis.
  24255. */
  24256. minScaleY: number;
  24257. /**
  24258. * Maximum scale of emitting particles on Y axis.
  24259. */
  24260. maxScaleY: number;
  24261. /**
  24262. * Gets or sets the minimal initial rotation in radians.
  24263. */
  24264. minInitialRotation: number;
  24265. /**
  24266. * Gets or sets the maximal initial rotation in radians.
  24267. */
  24268. maxInitialRotation: number;
  24269. /**
  24270. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24271. */
  24272. minAngularSpeed: number;
  24273. /**
  24274. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24275. */
  24276. maxAngularSpeed: number;
  24277. /**
  24278. * The texture used to render each particle. (this can be a spritesheet)
  24279. */
  24280. particleTexture: Nullable<Texture>;
  24281. /**
  24282. * The layer mask we are rendering the particles through.
  24283. */
  24284. layerMask: number;
  24285. /**
  24286. * This can help using your own shader to render the particle system.
  24287. * The according effect will be created
  24288. */
  24289. customShader: any;
  24290. /**
  24291. * By default particle system starts as soon as they are created. This prevents the
  24292. * automatic start to happen and let you decide when to start emitting particles.
  24293. */
  24294. preventAutoStart: boolean;
  24295. /**
  24296. * This function can be defined to provide custom update for active particles.
  24297. * This function will be called instead of regular update (age, position, color, etc.).
  24298. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  24299. */
  24300. updateFunction: (particles: Particle[]) => void;
  24301. /**
  24302. * Callback triggered when the particle animation is ending.
  24303. */
  24304. onAnimationEnd: Nullable<() => void>;
  24305. /**
  24306. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24307. */
  24308. blendMode: number;
  24309. /**
  24310. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24311. * to override the particles.
  24312. */
  24313. forceDepthWrite: boolean;
  24314. /**
  24315. * You can use gravity if you want to give an orientation to your particles.
  24316. */
  24317. gravity: Vector3;
  24318. private _colorGradients;
  24319. private _sizeGradients;
  24320. /**
  24321. * Gets the current list of color gradients.
  24322. * You must use addColorGradient and removeColorGradient to udpate this list
  24323. * @returns the list of color gradients
  24324. */
  24325. getColorGradients(): Nullable<Array<ColorGradient>>;
  24326. /**
  24327. * Gets the current list of size gradients.
  24328. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24329. * @returns the list of size gradients
  24330. */
  24331. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24332. /**
  24333. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24334. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24335. */
  24336. direction1: Vector3;
  24337. /**
  24338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24339. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24340. */
  24341. direction2: Vector3;
  24342. /**
  24343. * 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.
  24344. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24345. */
  24346. minEmitBox: Vector3;
  24347. /**
  24348. * 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.
  24349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24350. */
  24351. maxEmitBox: Vector3;
  24352. /**
  24353. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24354. */
  24355. color1: Color4;
  24356. /**
  24357. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24358. */
  24359. color2: Color4;
  24360. /**
  24361. * Color the particle will have at the end of its lifetime
  24362. */
  24363. colorDead: Color4;
  24364. /**
  24365. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24366. */
  24367. textureMask: Color4;
  24368. /**
  24369. * The particle emitter type defines the emitter used by the particle system.
  24370. * It can be for example box, sphere, or cone...
  24371. */
  24372. particleEmitterType: IParticleEmitterType;
  24373. /**
  24374. * This function can be defined to specify initial direction for every new particle.
  24375. * It by default use the emitterType defined function
  24376. */
  24377. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  24378. /**
  24379. * This function can be defined to specify initial position for every new particle.
  24380. * It by default use the emitterType defined function
  24381. */
  24382. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  24383. /**
  24384. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not
  24385. */
  24386. spriteCellLoop: boolean;
  24387. /**
  24388. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop
  24389. */
  24390. spriteCellChangeSpeed: number;
  24391. /**
  24392. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display
  24393. */
  24394. startSpriteCellID: number;
  24395. /**
  24396. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display
  24397. */
  24398. endSpriteCellID: number;
  24399. /**
  24400. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24401. */
  24402. spriteCellWidth: number;
  24403. /**
  24404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24405. */
  24406. spriteCellHeight: number;
  24407. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24408. preWarmCycles: number;
  24409. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24410. preWarmStepOffset: number;
  24411. /**
  24412. * An event triggered when the system is disposed
  24413. */
  24414. onDisposeObservable: Observable<ParticleSystem>;
  24415. private _onDisposeObserver;
  24416. /**
  24417. * Sets a callback that will be triggered when the system is disposed
  24418. */
  24419. onDispose: () => void;
  24420. /**
  24421. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24422. */
  24423. readonly isAnimationSheetEnabled: boolean;
  24424. /**
  24425. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24426. */
  24427. isBillboardBased: boolean;
  24428. private _particles;
  24429. private _epsilon;
  24430. private _capacity;
  24431. private _scene;
  24432. private _stockParticles;
  24433. private _newPartsExcess;
  24434. private _vertexData;
  24435. private _vertexBuffer;
  24436. private _vertexBuffers;
  24437. private _spriteBuffer;
  24438. private _indexBuffer;
  24439. private _effect;
  24440. private _customEffect;
  24441. private _cachedDefines;
  24442. private _scaledColorStep;
  24443. private _colorDiff;
  24444. private _scaledDirection;
  24445. private _scaledGravity;
  24446. private _currentRenderId;
  24447. private _alive;
  24448. private _useInstancing;
  24449. private _started;
  24450. private _stopped;
  24451. private _actualFrame;
  24452. private _scaledUpdateSpeed;
  24453. private _vertexBufferSize;
  24454. private _isAnimationSheetEnabled;
  24455. private _isBillboardBased;
  24456. /**
  24457. * 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.
  24458. */
  24459. subEmitters: ParticleSystem[];
  24460. /**
  24461. * The current active Sub-systems, this property is used by the root particle system only.
  24462. */
  24463. activeSubSystems: Array<ParticleSystem>;
  24464. private _rootParticleSystem;
  24465. /**
  24466. * Gets the current list of active particles
  24467. */
  24468. readonly particles: Particle[];
  24469. /**
  24470. * Returns the string "ParticleSystem"
  24471. * @returns a string containing the class name
  24472. */
  24473. getClassName(): string;
  24474. /**
  24475. * Instantiates a particle system.
  24476. * 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.
  24477. * @param name The name of the particle system
  24478. * @param capacity The max number of particles alive at the same time
  24479. * @param scene The scene the particle system belongs to
  24480. * @param customEffect a custom effect used to change the way particles are rendered by default
  24481. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24482. * @param epsilon Offset used to render the particles
  24483. */
  24484. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  24485. /**
  24486. * Adds a new size gradient
  24487. * @param gradient defines the gradient to use (between 0 and 1)
  24488. * @param factor defines the size factor to affect to the specified gradient
  24489. */
  24490. addSizeGradient(gradient: number, factor: number): ParticleSystem;
  24491. /**
  24492. * Remove a specific size gradient
  24493. * @param gradient defines the gradient to remove
  24494. */
  24495. removeSizeGradient(gradient: number): ParticleSystem;
  24496. /**
  24497. * Adds a new color gradient
  24498. * @param gradient defines the gradient to use (between 0 and 1)
  24499. * @param color defines the color to affect to the specified gradient
  24500. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24501. */
  24502. addColorGradient(gradient: number, color: Color4, color2?: Color4): ParticleSystem;
  24503. /**
  24504. * Remove a specific color gradient
  24505. * @param gradient defines the gradient to remove
  24506. */
  24507. removeColorGradient(gradient: number): ParticleSystem;
  24508. private _resetEffect();
  24509. private _createVertexBuffers();
  24510. private _createIndexBuffer();
  24511. /**
  24512. * Gets the maximum number of particles active at the same time.
  24513. * @returns The max number of active particles.
  24514. */
  24515. getCapacity(): number;
  24516. /**
  24517. * Gets Wether there are still active particles in the system.
  24518. * @returns True if it is alive, otherwise false.
  24519. */
  24520. isAlive(): boolean;
  24521. /**
  24522. * Gets Wether the system has been started.
  24523. * @returns True if it has been started, otherwise false.
  24524. */
  24525. isStarted(): boolean;
  24526. /**
  24527. * Starts the particle system and begins to emit.
  24528. */
  24529. start(): void;
  24530. /**
  24531. * Stops the particle system.
  24532. * @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.
  24533. */
  24534. stop(stopSubEmitters?: boolean): void;
  24535. /**
  24536. * Remove all active particles
  24537. */
  24538. reset(): void;
  24539. /**
  24540. * @hidden (for internal use only)
  24541. */
  24542. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  24543. /**
  24544. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  24545. * Its lifetime will start back at 0.
  24546. */
  24547. recycleParticle: (particle: Particle) => void;
  24548. private _stopSubEmitters();
  24549. private _createParticle;
  24550. private _removeFromRoot();
  24551. private _emitFromParticle;
  24552. private _update(newParticles);
  24553. /** @hidden */
  24554. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  24555. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  24556. private _getEffect();
  24557. /**
  24558. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24559. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  24560. */
  24561. animate(preWarmOnly?: boolean): void;
  24562. private _appendParticleVertices(offset, particle);
  24563. /**
  24564. * Rebuilds the particle system.
  24565. */
  24566. rebuild(): void;
  24567. /**
  24568. * Is this system ready to be used/rendered
  24569. * @return true if the system is ready
  24570. */
  24571. isReady(): boolean;
  24572. /**
  24573. * Renders the particle system in its current state.
  24574. * @returns the current number of particles
  24575. */
  24576. render(): number;
  24577. /**
  24578. * Disposes the particle system and free the associated resources
  24579. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24580. */
  24581. dispose(disposeTexture?: boolean): void;
  24582. /**
  24583. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  24584. * @param radius The radius of the sphere to emit from
  24585. * @returns the emitter
  24586. */
  24587. createSphereEmitter(radius?: number): SphereParticleEmitter;
  24588. /**
  24589. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  24590. * @param radius The radius of the sphere to emit from
  24591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24593. * @returns the emitter
  24594. */
  24595. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24596. /**
  24597. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  24598. * @param radius The radius of the cone to emit from
  24599. * @param angle The base angle of the cone
  24600. * @returns the emitter
  24601. */
  24602. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24603. /**
  24604. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24607. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24608. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24609. * @returns the emitter
  24610. */
  24611. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24612. /**
  24613. * Clones the particle system.
  24614. * @param name The name of the cloned object
  24615. * @param newEmitter The new emitter to use
  24616. * @returns the cloned particle system
  24617. */
  24618. clone(name: string, newEmitter: any): ParticleSystem;
  24619. /**
  24620. * Serializes the particle system to a JSON object.
  24621. * @returns the JSON object
  24622. */
  24623. serialize(): any;
  24624. /** @hidden */
  24625. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  24626. /** @hidden */
  24627. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  24628. /**
  24629. * Parses a JSON object to create a particle system.
  24630. * @param parsedParticleSystem The JSON object to parse
  24631. * @param scene The scene to create the particle system in
  24632. * @param rootUrl The root url to use to load external dependencies like texture
  24633. * @returns the Parsed particle system
  24634. */
  24635. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  24636. }
  24637. }
  24638. declare module BABYLON {
  24639. /**
  24640. * Represents one particle of a solid particle system.
  24641. */
  24642. class SolidParticle {
  24643. /**
  24644. * particle global index
  24645. */
  24646. idx: number;
  24647. /**
  24648. * The color of the particle
  24649. */
  24650. color: Nullable<Color4>;
  24651. /**
  24652. * The world space position of the particle.
  24653. */
  24654. position: Vector3;
  24655. /**
  24656. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24657. */
  24658. rotation: Vector3;
  24659. /**
  24660. * The world space rotation quaternion of the particle.
  24661. */
  24662. rotationQuaternion: Nullable<Quaternion>;
  24663. /**
  24664. * The scaling of the particle.
  24665. */
  24666. scaling: Vector3;
  24667. /**
  24668. * The uvs of the particle.
  24669. */
  24670. uvs: Vector4;
  24671. /**
  24672. * The current speed of the particle.
  24673. */
  24674. velocity: Vector3;
  24675. /**
  24676. * The pivot point in the particle local space.
  24677. */
  24678. pivot: Vector3;
  24679. /**
  24680. * Must the particle be translated from its pivot point in its local space ?
  24681. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24682. * Default : false
  24683. */
  24684. translateFromPivot: boolean;
  24685. /**
  24686. * Is the particle active or not ?
  24687. */
  24688. alive: boolean;
  24689. /**
  24690. * Is the particle visible or not ?
  24691. */
  24692. isVisible: boolean;
  24693. /**
  24694. * Index of this particle in the global "positions" array (Internal use)
  24695. */
  24696. _pos: number;
  24697. /**
  24698. * Index of this particle in the global "indices" array (Internal use)
  24699. */
  24700. _ind: number;
  24701. /**
  24702. * ModelShape of this particle (Internal use)
  24703. */
  24704. _model: ModelShape;
  24705. /**
  24706. * ModelShape id of this particle
  24707. */
  24708. shapeId: number;
  24709. /**
  24710. * Index of the particle in its shape id (Internal use)
  24711. */
  24712. idxInShape: number;
  24713. /**
  24714. * Reference to the shape model BoundingInfo object (Internal use)
  24715. */
  24716. _modelBoundingInfo: BoundingInfo;
  24717. /**
  24718. * Particle BoundingInfo object (Internal use)
  24719. */
  24720. _boundingInfo: BoundingInfo;
  24721. /**
  24722. * Reference to the SPS what the particle belongs to (Internal use)
  24723. */
  24724. _sps: SolidParticleSystem;
  24725. /**
  24726. * Still set as invisible in order to skip useless computations (Internal use)
  24727. */
  24728. _stillInvisible: boolean;
  24729. /**
  24730. * Last computed particle rotation matrix
  24731. */
  24732. _rotationMatrix: number[];
  24733. /**
  24734. * Parent particle Id, if any.
  24735. * Default null.
  24736. */
  24737. parentId: Nullable<number>;
  24738. /**
  24739. * Internal global position in the SPS.
  24740. */
  24741. _globalPosition: Vector3;
  24742. /**
  24743. * Creates a Solid Particle object.
  24744. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24745. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24746. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24747. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24748. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24749. * @param shapeId (integer) is the model shape identifier in the SPS.
  24750. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24751. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24752. */
  24753. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24754. /**
  24755. * Legacy support, changed scale to scaling
  24756. */
  24757. /**
  24758. * Legacy support, changed scale to scaling
  24759. */
  24760. scale: Vector3;
  24761. /**
  24762. * Legacy support, changed quaternion to rotationQuaternion
  24763. */
  24764. /**
  24765. * Legacy support, changed quaternion to rotationQuaternion
  24766. */
  24767. quaternion: Nullable<Quaternion>;
  24768. /**
  24769. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24770. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24771. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24772. * @returns true if it intersects
  24773. */
  24774. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24775. }
  24776. /**
  24777. * Represents the shape of the model used by one particle of a solid particle system.
  24778. * SPS internal tool, don't use it manually.
  24779. */
  24780. class ModelShape {
  24781. /**
  24782. * The shape id.
  24783. */
  24784. shapeID: number;
  24785. /**
  24786. * flat array of model positions (internal use)
  24787. */
  24788. _shape: Vector3[];
  24789. /**
  24790. * flat array of model UVs (internal use)
  24791. */
  24792. _shapeUV: number[];
  24793. /**
  24794. * length of the shape in the model indices array (internal use)
  24795. */
  24796. _indicesLength: number;
  24797. /**
  24798. * Custom position function (internal use)
  24799. */
  24800. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24801. /**
  24802. * Custom vertex function (internal use)
  24803. */
  24804. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24805. /**
  24806. * 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.
  24807. * SPS internal tool, don't use it manually.
  24808. * @hidden
  24809. */
  24810. 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>);
  24811. }
  24812. /**
  24813. * Represents a Depth Sorted Particle in the solid particle system.
  24814. */
  24815. class DepthSortedParticle {
  24816. /**
  24817. * Index of the particle in the "indices" array
  24818. */
  24819. ind: number;
  24820. /**
  24821. * Length of the particle shape in the "indices" array
  24822. */
  24823. indicesLength: number;
  24824. /**
  24825. * Squared distance from the particle to the camera
  24826. */
  24827. sqDistance: number;
  24828. }
  24829. }
  24830. declare module BABYLON {
  24831. /**
  24832. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24833. *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.
  24834. * The SPS is also a particle system. It provides some methods to manage the particles.
  24835. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24836. *
  24837. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24838. */
  24839. class SolidParticleSystem implements IDisposable {
  24840. /**
  24841. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24842. * Example : var p = SPS.particles[i];
  24843. */
  24844. particles: SolidParticle[];
  24845. /**
  24846. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24847. */
  24848. nbParticles: number;
  24849. /**
  24850. * If the particles must ever face the camera (default false). Useful for planar particles.
  24851. */
  24852. billboard: boolean;
  24853. /**
  24854. * Recompute normals when adding a shape
  24855. */
  24856. recomputeNormals: boolean;
  24857. /**
  24858. * This a counter ofr your own usage. It's not set by any SPS functions.
  24859. */
  24860. counter: number;
  24861. /**
  24862. * The SPS name. This name is also given to the underlying mesh.
  24863. */
  24864. name: string;
  24865. /**
  24866. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24867. */
  24868. mesh: Mesh;
  24869. /**
  24870. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24871. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24872. */
  24873. vars: any;
  24874. /**
  24875. * This array is populated when the SPS is set as 'pickable'.
  24876. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24877. * Each element of this array is an object `{idx: int, faceId: int}`.
  24878. * `idx` is the picked particle index in the `SPS.particles` array
  24879. * `faceId` is the picked face index counted within this particle.
  24880. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24881. */
  24882. pickedParticles: {
  24883. idx: number;
  24884. faceId: number;
  24885. }[];
  24886. /**
  24887. * This array is populated when `enableDepthSort` is set to true.
  24888. * Each element of this array is an instance of the class DepthSortedParticle.
  24889. */
  24890. depthSortedParticles: DepthSortedParticle[];
  24891. /**
  24892. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24893. */
  24894. _bSphereOnly: boolean;
  24895. /**
  24896. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24897. */
  24898. _bSphereRadiusFactor: number;
  24899. private _scene;
  24900. private _positions;
  24901. private _indices;
  24902. private _normals;
  24903. private _colors;
  24904. private _uvs;
  24905. private _indices32;
  24906. private _positions32;
  24907. private _normals32;
  24908. private _fixedNormal32;
  24909. private _colors32;
  24910. private _uvs32;
  24911. private _index;
  24912. private _updatable;
  24913. private _pickable;
  24914. private _isVisibilityBoxLocked;
  24915. private _alwaysVisible;
  24916. private _depthSort;
  24917. private _shapeCounter;
  24918. private _copy;
  24919. private _shape;
  24920. private _shapeUV;
  24921. private _color;
  24922. private _computeParticleColor;
  24923. private _computeParticleTexture;
  24924. private _computeParticleRotation;
  24925. private _computeParticleVertex;
  24926. private _computeBoundingBox;
  24927. private _depthSortParticles;
  24928. private _cam_axisZ;
  24929. private _cam_axisY;
  24930. private _cam_axisX;
  24931. private _axisZ;
  24932. private _camera;
  24933. private _particle;
  24934. private _camDir;
  24935. private _camInvertedPosition;
  24936. private _rotMatrix;
  24937. private _invertMatrix;
  24938. private _rotated;
  24939. private _quaternion;
  24940. private _vertex;
  24941. private _normal;
  24942. private _yaw;
  24943. private _pitch;
  24944. private _roll;
  24945. private _halfroll;
  24946. private _halfpitch;
  24947. private _halfyaw;
  24948. private _sinRoll;
  24949. private _cosRoll;
  24950. private _sinPitch;
  24951. private _cosPitch;
  24952. private _sinYaw;
  24953. private _cosYaw;
  24954. private _mustUnrotateFixedNormals;
  24955. private _minimum;
  24956. private _maximum;
  24957. private _minBbox;
  24958. private _maxBbox;
  24959. private _particlesIntersect;
  24960. private _depthSortFunction;
  24961. private _needs32Bits;
  24962. private _pivotBackTranslation;
  24963. private _scaledPivot;
  24964. private _particleHasParent;
  24965. private _parent;
  24966. /**
  24967. * Creates a SPS (Solid Particle System) object.
  24968. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24969. * @param scene (Scene) is the scene in which the SPS is added.
  24970. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24971. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24972. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24973. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24974. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24975. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24976. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24977. */
  24978. constructor(name: string, scene: Scene, options?: {
  24979. updatable?: boolean;
  24980. isPickable?: boolean;
  24981. enableDepthSort?: boolean;
  24982. particleIntersection?: boolean;
  24983. boundingSphereOnly?: boolean;
  24984. bSphereRadiusFactor?: number;
  24985. });
  24986. /**
  24987. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24988. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24989. * @returns the created mesh
  24990. */
  24991. buildMesh(): Mesh;
  24992. /**
  24993. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24994. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24995. * Thus the particles generated from `digest()` have their property `position` set yet.
  24996. * @param mesh ( Mesh ) is the mesh to be digested
  24997. * @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
  24998. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24999. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25000. * @returns the current SPS
  25001. */
  25002. digest(mesh: Mesh, options?: {
  25003. facetNb?: number;
  25004. number?: number;
  25005. delta?: number;
  25006. }): SolidParticleSystem;
  25007. private _unrotateFixedNormals();
  25008. private _resetCopy();
  25009. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  25010. private _posToShape(positions);
  25011. private _uvsToShapeUV(uvs);
  25012. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  25013. /**
  25014. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25015. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25016. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25017. * @param nb (positive integer) the number of particles to be created from this model
  25018. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25019. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25020. * @returns the number of shapes in the system
  25021. */
  25022. addShape(mesh: Mesh, nb: number, options?: {
  25023. positionFunction?: any;
  25024. vertexFunction?: any;
  25025. }): number;
  25026. private _rebuildParticle(particle);
  25027. /**
  25028. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25029. * @returns the SPS.
  25030. */
  25031. rebuildMesh(): SolidParticleSystem;
  25032. /**
  25033. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25034. * This method calls `updateParticle()` for each particle of the SPS.
  25035. * For an animated SPS, it is usually called within the render loop.
  25036. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25037. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25038. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25039. * @returns the SPS.
  25040. */
  25041. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25042. private _quaternionRotationYPR();
  25043. private _quaternionToRotationMatrix();
  25044. /**
  25045. * Disposes the SPS.
  25046. */
  25047. dispose(): void;
  25048. /**
  25049. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25050. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25051. * @returns the SPS.
  25052. */
  25053. refreshVisibleSize(): SolidParticleSystem;
  25054. /**
  25055. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25056. * @param size the size (float) of the visibility box
  25057. * note : this doesn't lock the SPS mesh bounding box.
  25058. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25059. */
  25060. setVisibilityBox(size: number): void;
  25061. /**
  25062. * Gets whether the SPS as always visible or not
  25063. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25064. */
  25065. /**
  25066. * Sets the SPS as always visible or not
  25067. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25068. */
  25069. isAlwaysVisible: boolean;
  25070. /**
  25071. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25072. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25073. */
  25074. /**
  25075. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25076. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25077. */
  25078. isVisibilityBoxLocked: boolean;
  25079. /**
  25080. * Gets if `setParticles()` computes the particle rotations or not.
  25081. * Default value : true. The SPS is faster when it's set to false.
  25082. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25083. */
  25084. /**
  25085. * Tells to `setParticles()` to compute the particle rotations or not.
  25086. * Default value : true. The SPS is faster when it's set to false.
  25087. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25088. */
  25089. computeParticleRotation: boolean;
  25090. /**
  25091. * Gets if `setParticles()` computes the particle colors or not.
  25092. * Default value : true. The SPS is faster when it's set to false.
  25093. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25094. */
  25095. /**
  25096. * Tells to `setParticles()` to compute the particle colors or not.
  25097. * Default value : true. The SPS is faster when it's set to false.
  25098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25099. */
  25100. computeParticleColor: boolean;
  25101. /**
  25102. * Gets if `setParticles()` computes the particle textures or not.
  25103. * Default value : true. The SPS is faster when it's set to false.
  25104. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25105. */
  25106. computeParticleTexture: boolean;
  25107. /**
  25108. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25109. * Default value : false. The SPS is faster when it's set to false.
  25110. * Note : the particle custom vertex positions aren't stored values.
  25111. */
  25112. /**
  25113. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25114. * Default value : false. The SPS is faster when it's set to false.
  25115. * Note : the particle custom vertex positions aren't stored values.
  25116. */
  25117. computeParticleVertex: boolean;
  25118. /**
  25119. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25120. */
  25121. /**
  25122. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25123. */
  25124. computeBoundingBox: boolean;
  25125. /**
  25126. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25127. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25128. * Default : `true`
  25129. */
  25130. /**
  25131. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25132. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25133. * Default : `true`
  25134. */
  25135. depthSortParticles: boolean;
  25136. /**
  25137. * This function does nothing. It may be overwritten to set all the particle first values.
  25138. * The SPS doesn't call this function, you may have to call it by your own.
  25139. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25140. */
  25141. initParticles(): void;
  25142. /**
  25143. * This function does nothing. It may be overwritten to recycle a particle.
  25144. * The SPS doesn't call this function, you may have to call it by your own.
  25145. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25146. * @param particle The particle to recycle
  25147. * @returns the recycled particle
  25148. */
  25149. recycleParticle(particle: SolidParticle): SolidParticle;
  25150. /**
  25151. * Updates a particle : this function should be overwritten by the user.
  25152. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25153. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25154. * @example : just set a particle position or velocity and recycle conditions
  25155. * @param particle The particle to update
  25156. * @returns the updated particle
  25157. */
  25158. updateParticle(particle: SolidParticle): SolidParticle;
  25159. /**
  25160. * Updates a vertex of a particle : it can be overwritten by the user.
  25161. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25162. * @param particle the current particle
  25163. * @param vertex the current index of the current particle
  25164. * @param pt the index of the current vertex in the particle shape
  25165. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25166. * @example : just set a vertex particle position
  25167. * @returns the updated vertex
  25168. */
  25169. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25170. /**
  25171. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25172. * This does nothing and may be overwritten by the user.
  25173. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25174. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25175. * @param update the boolean update value actually passed to setParticles()
  25176. */
  25177. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25178. /**
  25179. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25180. * This will be passed three parameters.
  25181. * This does nothing and may be overwritten by the user.
  25182. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25183. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25184. * @param update the boolean update value actually passed to setParticles()
  25185. */
  25186. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25187. }
  25188. }
  25189. declare module BABYLON {
  25190. interface PhysicsImpostorJoint {
  25191. mainImpostor: PhysicsImpostor;
  25192. connectedImpostor: PhysicsImpostor;
  25193. joint: PhysicsJoint;
  25194. }
  25195. class PhysicsEngine {
  25196. private _physicsPlugin;
  25197. gravity: Vector3;
  25198. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  25199. setGravity(gravity: Vector3): void;
  25200. /**
  25201. * Set the time step of the physics engine.
  25202. * default is 1/60.
  25203. * To slow it down, enter 1/600 for example.
  25204. * To speed it up, 1/30
  25205. * @param {number} newTimeStep the new timestep to apply to this world.
  25206. */
  25207. setTimeStep(newTimeStep?: number): void;
  25208. /**
  25209. * Get the time step of the physics engine.
  25210. */
  25211. getTimeStep(): number;
  25212. dispose(): void;
  25213. getPhysicsPluginName(): string;
  25214. static Epsilon: number;
  25215. private _impostors;
  25216. private _joints;
  25217. /**
  25218. * Adding a new impostor for the impostor tracking.
  25219. * This will be done by the impostor itself.
  25220. * @param {PhysicsImpostor} impostor the impostor to add
  25221. */
  25222. addImpostor(impostor: PhysicsImpostor): void;
  25223. /**
  25224. * Remove an impostor from the engine.
  25225. * This impostor and its mesh will not longer be updated by the physics engine.
  25226. * @param {PhysicsImpostor} impostor the impostor to remove
  25227. */
  25228. removeImpostor(impostor: PhysicsImpostor): void;
  25229. /**
  25230. * Add a joint to the physics engine
  25231. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  25232. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  25233. * @param {PhysicsJoint} the joint that will connect both impostors.
  25234. */
  25235. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25236. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25237. /**
  25238. * Called by the scene. no need to call it.
  25239. */
  25240. _step(delta: number): void;
  25241. getPhysicsPlugin(): IPhysicsEnginePlugin;
  25242. getImpostors(): Array<PhysicsImpostor>;
  25243. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25244. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  25245. }
  25246. interface IPhysicsEnginePlugin {
  25247. world: any;
  25248. name: string;
  25249. setGravity(gravity: Vector3): void;
  25250. setTimeStep(timeStep: number): void;
  25251. getTimeStep(): number;
  25252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  25253. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25254. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25255. generatePhysicsBody(impostor: PhysicsImpostor): void;
  25256. removePhysicsBody(impostor: PhysicsImpostor): void;
  25257. generateJoint(joint: PhysicsImpostorJoint): void;
  25258. removeJoint(joint: PhysicsImpostorJoint): void;
  25259. isSupported(): boolean;
  25260. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  25261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  25262. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25263. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25264. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25265. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25266. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  25267. getBodyMass(impostor: PhysicsImpostor): number;
  25268. getBodyFriction(impostor: PhysicsImpostor): number;
  25269. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  25270. getBodyRestitution(impostor: PhysicsImpostor): number;
  25271. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  25272. sleepBody(impostor: PhysicsImpostor): void;
  25273. wakeUpBody(impostor: PhysicsImpostor): void;
  25274. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  25275. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  25276. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25277. getRadius(impostor: PhysicsImpostor): number;
  25278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  25279. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  25280. dispose(): void;
  25281. }
  25282. }
  25283. declare module BABYLON {
  25284. class PhysicsHelper {
  25285. private _scene;
  25286. private _physicsEngine;
  25287. constructor(scene: Scene);
  25288. /**
  25289. * @param {Vector3} origin the origin of the explosion
  25290. * @param {number} radius the explosion radius
  25291. * @param {number} strength the explosion strength
  25292. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25293. */
  25294. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25295. /**
  25296. * @param {Vector3} origin the origin of the explosion
  25297. * @param {number} radius the explosion radius
  25298. * @param {number} strength the explosion strength
  25299. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25300. */
  25301. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25302. /**
  25303. * @param {Vector3} origin the origin of the explosion
  25304. * @param {number} radius the explosion radius
  25305. * @param {number} strength the explosion strength
  25306. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25307. */
  25308. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25309. /**
  25310. * @param {Vector3} origin the origin of the updraft
  25311. * @param {number} radius the radius of the updraft
  25312. * @param {number} strength the strength of the updraft
  25313. * @param {number} height the height of the updraft
  25314. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  25315. */
  25316. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  25317. /**
  25318. * @param {Vector3} origin the of the vortex
  25319. * @param {number} radius the radius of the vortex
  25320. * @param {number} strength the strength of the vortex
  25321. * @param {number} height the height of the vortex
  25322. */
  25323. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  25324. }
  25325. /***** Radial explosion *****/
  25326. class PhysicsRadialExplosionEvent {
  25327. private _scene;
  25328. private _sphere;
  25329. private _sphereOptions;
  25330. private _rays;
  25331. private _dataFetched;
  25332. constructor(scene: Scene);
  25333. /**
  25334. * Returns the data related to the radial explosion event (sphere & rays).
  25335. * @returns {PhysicsRadialExplosionEventData}
  25336. */
  25337. getData(): PhysicsRadialExplosionEventData;
  25338. /**
  25339. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  25340. * @param impostor
  25341. * @param {Vector3} origin the origin of the explosion
  25342. * @param {number} radius the explosion radius
  25343. * @param {number} strength the explosion strength
  25344. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  25345. * @returns {Nullable<PhysicsForceAndContactPoint>}
  25346. */
  25347. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  25348. /**
  25349. * Disposes the sphere.
  25350. * @param {bolean} force
  25351. */
  25352. dispose(force?: boolean): void;
  25353. /*** Helpers ***/
  25354. private _prepareSphere();
  25355. private _intersectsWithSphere(impostor, origin, radius);
  25356. }
  25357. /***** Gravitational Field *****/
  25358. class PhysicsGravitationalFieldEvent {
  25359. private _physicsHelper;
  25360. private _scene;
  25361. private _origin;
  25362. private _radius;
  25363. private _strength;
  25364. private _falloff;
  25365. private _tickCallback;
  25366. private _sphere;
  25367. private _dataFetched;
  25368. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  25369. /**
  25370. * Returns the data related to the gravitational field event (sphere).
  25371. * @returns {PhysicsGravitationalFieldEventData}
  25372. */
  25373. getData(): PhysicsGravitationalFieldEventData;
  25374. /**
  25375. * Enables the gravitational field.
  25376. */
  25377. enable(): void;
  25378. /**
  25379. * Disables the gravitational field.
  25380. */
  25381. disable(): void;
  25382. /**
  25383. * Disposes the sphere.
  25384. * @param {bolean} force
  25385. */
  25386. dispose(force?: boolean): void;
  25387. private _tick();
  25388. }
  25389. /***** Updraft *****/
  25390. class PhysicsUpdraftEvent {
  25391. private _scene;
  25392. private _origin;
  25393. private _radius;
  25394. private _strength;
  25395. private _height;
  25396. private _updraftMode;
  25397. private _physicsEngine;
  25398. private _originTop;
  25399. private _originDirection;
  25400. private _tickCallback;
  25401. private _cylinder;
  25402. private _cylinderPosition;
  25403. private _dataFetched;
  25404. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  25405. /**
  25406. * Returns the data related to the updraft event (cylinder).
  25407. * @returns {PhysicsUpdraftEventData}
  25408. */
  25409. getData(): PhysicsUpdraftEventData;
  25410. /**
  25411. * Enables the updraft.
  25412. */
  25413. enable(): void;
  25414. /**
  25415. * Disables the cortex.
  25416. */
  25417. disable(): void;
  25418. /**
  25419. * Disposes the sphere.
  25420. * @param {bolean} force
  25421. */
  25422. dispose(force?: boolean): void;
  25423. private getImpostorForceAndContactPoint(impostor);
  25424. private _tick();
  25425. /*** Helpers ***/
  25426. private _prepareCylinder();
  25427. private _intersectsWithCylinder(impostor);
  25428. }
  25429. /***** Vortex *****/
  25430. class PhysicsVortexEvent {
  25431. private _scene;
  25432. private _origin;
  25433. private _radius;
  25434. private _strength;
  25435. private _height;
  25436. private _physicsEngine;
  25437. private _originTop;
  25438. private _centripetalForceThreshold;
  25439. private _updraftMultiplier;
  25440. private _tickCallback;
  25441. private _cylinder;
  25442. private _cylinderPosition;
  25443. private _dataFetched;
  25444. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  25445. /**
  25446. * Returns the data related to the vortex event (cylinder).
  25447. * @returns {PhysicsVortexEventData}
  25448. */
  25449. getData(): PhysicsVortexEventData;
  25450. /**
  25451. * Enables the vortex.
  25452. */
  25453. enable(): void;
  25454. /**
  25455. * Disables the cortex.
  25456. */
  25457. disable(): void;
  25458. /**
  25459. * Disposes the sphere.
  25460. * @param {bolean} force
  25461. */
  25462. dispose(force?: boolean): void;
  25463. private getImpostorForceAndContactPoint(impostor);
  25464. private _tick();
  25465. /*** Helpers ***/
  25466. private _prepareCylinder();
  25467. private _intersectsWithCylinder(impostor);
  25468. }
  25469. /***** Enums *****/
  25470. /**
  25471. * The strenght of the force in correspondence to the distance of the affected object
  25472. */
  25473. enum PhysicsRadialImpulseFalloff {
  25474. /** Defines that impulse is constant in strength across it's whole radius */
  25475. Constant = 0,
  25476. /** DEfines that impulse gets weaker if it's further from the origin */
  25477. Linear = 1,
  25478. }
  25479. /**
  25480. * The strenght of the force in correspondence to the distance of the affected object
  25481. */
  25482. enum PhysicsUpdraftMode {
  25483. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  25484. Center = 0,
  25485. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  25486. Perpendicular = 1,
  25487. }
  25488. /***** Data interfaces *****/
  25489. interface PhysicsForceAndContactPoint {
  25490. force: Vector3;
  25491. contactPoint: Vector3;
  25492. }
  25493. interface PhysicsRadialExplosionEventData {
  25494. sphere: Mesh;
  25495. rays: Array<Ray>;
  25496. }
  25497. interface PhysicsGravitationalFieldEventData {
  25498. sphere: Mesh;
  25499. }
  25500. interface PhysicsUpdraftEventData {
  25501. cylinder: Mesh;
  25502. }
  25503. interface PhysicsVortexEventData {
  25504. cylinder: Mesh;
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. interface PhysicsImpostorParameters {
  25509. mass: number;
  25510. friction?: number;
  25511. restitution?: number;
  25512. nativeOptions?: any;
  25513. ignoreParent?: boolean;
  25514. disableBidirectionalTransformation?: boolean;
  25515. }
  25516. interface IPhysicsEnabledObject {
  25517. position: Vector3;
  25518. rotationQuaternion: Nullable<Quaternion>;
  25519. scaling: Vector3;
  25520. rotation?: Vector3;
  25521. parent?: any;
  25522. getBoundingInfo(): BoundingInfo;
  25523. computeWorldMatrix(force: boolean): Matrix;
  25524. getWorldMatrix?(): Matrix;
  25525. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  25526. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  25527. getIndices?(): Nullable<IndicesArray>;
  25528. getScene?(): Scene;
  25529. getAbsolutePosition(): Vector3;
  25530. getAbsolutePivotPoint(): Vector3;
  25531. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  25532. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  25533. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25534. getClassName(): string;
  25535. }
  25536. class PhysicsImpostor {
  25537. object: IPhysicsEnabledObject;
  25538. type: number;
  25539. private _options;
  25540. private _scene;
  25541. static DEFAULT_OBJECT_SIZE: Vector3;
  25542. static IDENTITY_QUATERNION: Quaternion;
  25543. private _physicsEngine;
  25544. private _physicsBody;
  25545. private _bodyUpdateRequired;
  25546. private _onBeforePhysicsStepCallbacks;
  25547. private _onAfterPhysicsStepCallbacks;
  25548. private _onPhysicsCollideCallbacks;
  25549. private _deltaPosition;
  25550. private _deltaRotation;
  25551. private _deltaRotationConjugated;
  25552. private _parent;
  25553. private _isDisposed;
  25554. private static _tmpVecs;
  25555. private static _tmpQuat;
  25556. readonly isDisposed: boolean;
  25557. mass: number;
  25558. friction: number;
  25559. restitution: number;
  25560. uniqueId: number;
  25561. private _joints;
  25562. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25563. /**
  25564. * This function will completly initialize this impostor.
  25565. * It will create a new body - but only if this mesh has no parent.
  25566. * If it has, this impostor will not be used other than to define the impostor
  25567. * of the child mesh.
  25568. */
  25569. _init(): void;
  25570. private _getPhysicsParent();
  25571. /**
  25572. * Should a new body be generated.
  25573. */
  25574. isBodyInitRequired(): boolean;
  25575. setScalingUpdated(updated: boolean): void;
  25576. /**
  25577. * Force a regeneration of this or the parent's impostor's body.
  25578. * Use under cautious - This will remove all joints already implemented.
  25579. */
  25580. forceUpdate(): void;
  25581. /**
  25582. * Gets the body that holds this impostor. Either its own, or its parent.
  25583. */
  25584. /**
  25585. * Set the physics body. Used mainly by the physics engine/plugin
  25586. */
  25587. physicsBody: any;
  25588. parent: Nullable<PhysicsImpostor>;
  25589. resetUpdateFlags(): void;
  25590. getObjectExtendSize(): Vector3;
  25591. getObjectCenter(): Vector3;
  25592. /**
  25593. * Get a specific parametes from the options parameter.
  25594. */
  25595. getParam(paramName: string): any;
  25596. /**
  25597. * Sets a specific parameter in the options given to the physics plugin
  25598. */
  25599. setParam(paramName: string, value: number): void;
  25600. /**
  25601. * Specifically change the body's mass option. Won't recreate the physics body object
  25602. */
  25603. setMass(mass: number): void;
  25604. getLinearVelocity(): Nullable<Vector3>;
  25605. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25606. getAngularVelocity(): Nullable<Vector3>;
  25607. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25608. /**
  25609. * Execute a function with the physics plugin native code.
  25610. * Provide a function the will have two variables - the world object and the physics body object.
  25611. */
  25612. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25613. /**
  25614. * Register a function that will be executed before the physics world is stepping forward.
  25615. */
  25616. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25617. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25618. /**
  25619. * Register a function that will be executed after the physics step
  25620. */
  25621. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25622. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25623. /**
  25624. * register a function that will be executed when this impostor collides against a different body.
  25625. */
  25626. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25627. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25628. private _tmpQuat;
  25629. private _tmpQuat2;
  25630. getParentsRotation(): Quaternion;
  25631. /**
  25632. * this function is executed by the physics engine.
  25633. */
  25634. beforeStep: () => void;
  25635. /**
  25636. * this function is executed by the physics engine.
  25637. */
  25638. afterStep: () => void;
  25639. /**
  25640. * Legacy collision detection event support
  25641. */
  25642. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25643. onCollide: (e: {
  25644. body: any;
  25645. }) => void;
  25646. /**
  25647. * Apply a force
  25648. */
  25649. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25650. /**
  25651. * Apply an impulse
  25652. */
  25653. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25654. /**
  25655. * A help function to create a joint.
  25656. */
  25657. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25658. /**
  25659. * Add a joint to this impostor with a different impostor.
  25660. */
  25661. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25662. /**
  25663. * Will keep this body still, in a sleep mode.
  25664. */
  25665. sleep(): PhysicsImpostor;
  25666. /**
  25667. * Wake the body up.
  25668. */
  25669. wakeUp(): PhysicsImpostor;
  25670. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25671. dispose(): void;
  25672. setDeltaPosition(position: Vector3): void;
  25673. setDeltaRotation(rotation: Quaternion): void;
  25674. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25675. getRadius(): number;
  25676. /**
  25677. * Sync a bone with this impostor
  25678. * @param bone The bone to sync to the impostor.
  25679. * @param boneMesh The mesh that the bone is influencing.
  25680. * @param jointPivot The pivot of the joint / bone in local space.
  25681. * @param distToJoint Optional distance from the impostor to the joint.
  25682. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25683. */
  25684. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25685. /**
  25686. * Sync impostor to a bone
  25687. * @param bone The bone that the impostor will be synced to.
  25688. * @param boneMesh The mesh that the bone is influencing.
  25689. * @param jointPivot The pivot of the joint / bone in local space.
  25690. * @param distToJoint Optional distance from the impostor to the joint.
  25691. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25692. * @param boneAxis Optional vector3 axis the bone is aligned with
  25693. */
  25694. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25695. static NoImpostor: number;
  25696. static SphereImpostor: number;
  25697. static BoxImpostor: number;
  25698. static PlaneImpostor: number;
  25699. static MeshImpostor: number;
  25700. static CylinderImpostor: number;
  25701. static ParticleImpostor: number;
  25702. static HeightmapImpostor: number;
  25703. }
  25704. }
  25705. declare module BABYLON {
  25706. interface PhysicsJointData {
  25707. mainPivot?: Vector3;
  25708. connectedPivot?: Vector3;
  25709. mainAxis?: Vector3;
  25710. connectedAxis?: Vector3;
  25711. collision?: boolean;
  25712. nativeParams?: any;
  25713. }
  25714. /**
  25715. * This is a holder class for the physics joint created by the physics plugin.
  25716. * It holds a set of functions to control the underlying joint.
  25717. */
  25718. class PhysicsJoint {
  25719. type: number;
  25720. jointData: PhysicsJointData;
  25721. private _physicsJoint;
  25722. protected _physicsPlugin: IPhysicsEnginePlugin;
  25723. constructor(type: number, jointData: PhysicsJointData);
  25724. physicsJoint: any;
  25725. physicsPlugin: IPhysicsEnginePlugin;
  25726. /**
  25727. * Execute a function that is physics-plugin specific.
  25728. * @param {Function} func the function that will be executed.
  25729. * It accepts two parameters: the physics world and the physics joint.
  25730. */
  25731. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25732. static DistanceJoint: number;
  25733. static HingeJoint: number;
  25734. static BallAndSocketJoint: number;
  25735. static WheelJoint: number;
  25736. static SliderJoint: number;
  25737. static PrismaticJoint: number;
  25738. static UniversalJoint: number;
  25739. static Hinge2Joint: number;
  25740. static PointToPointJoint: number;
  25741. static SpringJoint: number;
  25742. static LockJoint: number;
  25743. }
  25744. /**
  25745. * A class representing a physics distance joint.
  25746. */
  25747. class DistanceJoint extends PhysicsJoint {
  25748. constructor(jointData: DistanceJointData);
  25749. /**
  25750. * Update the predefined distance.
  25751. */
  25752. updateDistance(maxDistance: number, minDistance?: number): void;
  25753. }
  25754. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25755. constructor(type: number, jointData: PhysicsJointData);
  25756. /**
  25757. * Set the motor values.
  25758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25759. * @param {number} force the force to apply
  25760. * @param {number} maxForce max force for this motor.
  25761. */
  25762. setMotor(force?: number, maxForce?: number): void;
  25763. /**
  25764. * Set the motor's limits.
  25765. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25766. */
  25767. setLimit(upperLimit: number, lowerLimit?: number): void;
  25768. }
  25769. /**
  25770. * This class represents a single hinge physics joint
  25771. */
  25772. class HingeJoint extends MotorEnabledJoint {
  25773. constructor(jointData: PhysicsJointData);
  25774. /**
  25775. * Set the motor values.
  25776. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25777. * @param {number} force the force to apply
  25778. * @param {number} maxForce max force for this motor.
  25779. */
  25780. setMotor(force?: number, maxForce?: number): void;
  25781. /**
  25782. * Set the motor's limits.
  25783. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25784. */
  25785. setLimit(upperLimit: number, lowerLimit?: number): void;
  25786. }
  25787. /**
  25788. * This class represents a dual hinge physics joint (same as wheel joint)
  25789. */
  25790. class Hinge2Joint extends MotorEnabledJoint {
  25791. constructor(jointData: PhysicsJointData);
  25792. /**
  25793. * Set the motor values.
  25794. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25795. * @param {number} force the force to apply
  25796. * @param {number} maxForce max force for this motor.
  25797. * @param {motorIndex} the motor's index, 0 or 1.
  25798. */
  25799. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25800. /**
  25801. * Set the motor limits.
  25802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25803. * @param {number} upperLimit the upper limit
  25804. * @param {number} lowerLimit lower limit
  25805. * @param {motorIndex} the motor's index, 0 or 1.
  25806. */
  25807. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25808. }
  25809. interface IMotorEnabledJoint {
  25810. physicsJoint: any;
  25811. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25812. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25813. }
  25814. interface DistanceJointData extends PhysicsJointData {
  25815. maxDistance: number;
  25816. }
  25817. interface SpringJointData extends PhysicsJointData {
  25818. length: number;
  25819. stiffness: number;
  25820. damping: number;
  25821. }
  25822. }
  25823. declare module BABYLON {
  25824. class ReflectionProbe {
  25825. name: string;
  25826. private _scene;
  25827. private _renderTargetTexture;
  25828. private _projectionMatrix;
  25829. private _viewMatrix;
  25830. private _target;
  25831. private _add;
  25832. private _attachedMesh;
  25833. private _invertYAxis;
  25834. position: Vector3;
  25835. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25836. samples: number;
  25837. refreshRate: number;
  25838. getScene(): Scene;
  25839. readonly cubeTexture: RenderTargetTexture;
  25840. readonly renderList: Nullable<AbstractMesh[]>;
  25841. attachToMesh(mesh: AbstractMesh): void;
  25842. /**
  25843. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25844. *
  25845. * @param renderingGroupId The rendering group id corresponding to its index
  25846. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25847. */
  25848. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25849. dispose(): void;
  25850. }
  25851. }
  25852. declare module BABYLON {
  25853. class BoundingBoxRenderer {
  25854. frontColor: Color3;
  25855. backColor: Color3;
  25856. showBackLines: boolean;
  25857. renderList: SmartArray<BoundingBox>;
  25858. private _scene;
  25859. private _colorShader;
  25860. private _vertexBuffers;
  25861. private _indexBuffer;
  25862. constructor(scene: Scene);
  25863. private _prepareRessources();
  25864. private _createIndexBuffer();
  25865. _rebuild(): void;
  25866. reset(): void;
  25867. render(): void;
  25868. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  25869. dispose(): void;
  25870. }
  25871. }
  25872. declare module BABYLON {
  25873. /**
  25874. * This represents a depth renderer in Babylon.
  25875. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  25876. */
  25877. class DepthRenderer {
  25878. private _scene;
  25879. private _depthMap;
  25880. private _effect;
  25881. private _cachedDefines;
  25882. private _camera;
  25883. /**
  25884. * Instantiates a depth renderer
  25885. * @param scene The scene the renderer belongs to
  25886. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  25887. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  25888. */
  25889. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  25890. /**
  25891. * Creates the depth rendering effect and checks if the effect is ready.
  25892. * @param subMesh The submesh to be used to render the depth map of
  25893. * @param useInstances If multiple world instances should be used
  25894. * @returns if the depth renderer is ready to render the depth map
  25895. */
  25896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25897. /**
  25898. * Gets the texture which the depth map will be written to.
  25899. * @returns The depth map texture
  25900. */
  25901. getDepthMap(): RenderTargetTexture;
  25902. /**
  25903. * Disposes of the depth renderer.
  25904. */
  25905. dispose(): void;
  25906. }
  25907. }
  25908. declare module BABYLON {
  25909. class EdgesRenderer {
  25910. edgesWidthScalerForOrthographic: number;
  25911. edgesWidthScalerForPerspective: number;
  25912. private _source;
  25913. private _linesPositions;
  25914. private _linesNormals;
  25915. private _linesIndices;
  25916. private _epsilon;
  25917. private _indicesCount;
  25918. private _lineShader;
  25919. private _ib;
  25920. private _buffers;
  25921. private _checkVerticesInsteadOfIndices;
  25922. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  25923. isEnabled: boolean;
  25924. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  25925. private _prepareRessources();
  25926. _rebuild(): void;
  25927. dispose(): void;
  25928. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  25929. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  25930. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  25931. _generateEdgesLines(): void;
  25932. render(): void;
  25933. }
  25934. }
  25935. declare module BABYLON {
  25936. /**
  25937. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  25938. */
  25939. class GeometryBufferRenderer {
  25940. private _scene;
  25941. private _multiRenderTarget;
  25942. private _ratio;
  25943. private _enablePosition;
  25944. protected _effect: Effect;
  25945. protected _cachedDefines: string;
  25946. /**
  25947. * Set the render list (meshes to be rendered) used in the G buffer.
  25948. */
  25949. renderList: Mesh[];
  25950. /**
  25951. * Gets wether or not G buffer are supported by the running hardware.
  25952. * This requires draw buffer supports
  25953. */
  25954. readonly isSupported: boolean;
  25955. /**
  25956. * Gets wether or not position are enabled for the G buffer.
  25957. */
  25958. /**
  25959. * Sets wether or not position are enabled for the G buffer.
  25960. */
  25961. enablePosition: boolean;
  25962. /**
  25963. * Gets the scene associated with the buffer.
  25964. */
  25965. readonly scene: Scene;
  25966. /**
  25967. * Gets the ratio used by the buffer during its creation.
  25968. * How big is the buffer related to the main canvas.
  25969. */
  25970. readonly ratio: number;
  25971. /**
  25972. * Creates a new G Buffer for the scene
  25973. * @param scene The scene the buffer belongs to
  25974. * @param ratio How big is the buffer related to the main canvas.
  25975. */
  25976. constructor(scene: Scene, ratio?: number);
  25977. /**
  25978. * Checks wether everything is ready to render a submesh to the G buffer.
  25979. * @param subMesh the submesh to check readiness for
  25980. * @param useInstances is the mesh drawn using instance or not
  25981. * @returns true if ready otherwise false
  25982. */
  25983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25984. /**
  25985. * Gets the current underlying G Buffer.
  25986. * @returns the buffer
  25987. */
  25988. getGBuffer(): MultiRenderTarget;
  25989. /**
  25990. * Gets the number of samples used to render the buffer (anti aliasing).
  25991. */
  25992. /**
  25993. * Sets the number of samples used to render the buffer (anti aliasing).
  25994. */
  25995. samples: number;
  25996. /**
  25997. * Disposes the renderer and frees up associated resources.
  25998. */
  25999. dispose(): void;
  26000. protected _createRenderTargets(): void;
  26001. }
  26002. }
  26003. declare module BABYLON {
  26004. class OutlineRenderer {
  26005. private _scene;
  26006. private _effect;
  26007. private _cachedDefines;
  26008. zOffset: number;
  26009. constructor(scene: Scene);
  26010. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26012. }
  26013. }
  26014. declare module BABYLON {
  26015. class RenderingGroup {
  26016. index: number;
  26017. private _scene;
  26018. private _opaqueSubMeshes;
  26019. private _transparentSubMeshes;
  26020. private _alphaTestSubMeshes;
  26021. private _depthOnlySubMeshes;
  26022. private _particleSystems;
  26023. private _spriteManagers;
  26024. private _opaqueSortCompareFn;
  26025. private _alphaTestSortCompareFn;
  26026. private _transparentSortCompareFn;
  26027. private _renderOpaque;
  26028. private _renderAlphaTest;
  26029. private _renderTransparent;
  26030. private _edgesRenderers;
  26031. onBeforeTransparentRendering: () => void;
  26032. /**
  26033. * Set the opaque sort comparison function.
  26034. * If null the sub meshes will be render in the order they were created
  26035. */
  26036. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26037. /**
  26038. * Set the alpha test sort comparison function.
  26039. * If null the sub meshes will be render in the order they were created
  26040. */
  26041. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26042. /**
  26043. * Set the transparent sort comparison function.
  26044. * If null the sub meshes will be render in the order they were created
  26045. */
  26046. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26047. /**
  26048. * Creates a new rendering group.
  26049. * @param index The rendering group index
  26050. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26051. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26052. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26053. */
  26054. 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>);
  26055. /**
  26056. * Render all the sub meshes contained in the group.
  26057. * @param customRenderFunction Used to override the default render behaviour of the group.
  26058. * @returns true if rendered some submeshes.
  26059. */
  26060. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26061. /**
  26062. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26063. * @param subMeshes The submeshes to render
  26064. */
  26065. private renderOpaqueSorted(subMeshes);
  26066. /**
  26067. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26068. * @param subMeshes The submeshes to render
  26069. */
  26070. private renderAlphaTestSorted(subMeshes);
  26071. /**
  26072. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26073. * @param subMeshes The submeshes to render
  26074. */
  26075. private renderTransparentSorted(subMeshes);
  26076. /**
  26077. * Renders the submeshes in a specified order.
  26078. * @param subMeshes The submeshes to sort before render
  26079. * @param sortCompareFn The comparison function use to sort
  26080. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26081. * @param transparent Specifies to activate blending if true
  26082. */
  26083. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26084. /**
  26085. * Renders the submeshes in the order they were dispatched (no sort applied).
  26086. * @param subMeshes The submeshes to render
  26087. */
  26088. private static renderUnsorted(subMeshes);
  26089. /**
  26090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26091. * are rendered back to front if in the same alpha index.
  26092. *
  26093. * @param a The first submesh
  26094. * @param b The second submesh
  26095. * @returns The result of the comparison
  26096. */
  26097. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26098. /**
  26099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26100. * are rendered back to front.
  26101. *
  26102. * @param a The first submesh
  26103. * @param b The second submesh
  26104. * @returns The result of the comparison
  26105. */
  26106. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26107. /**
  26108. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26109. * are rendered front to back (prevent overdraw).
  26110. *
  26111. * @param a The first submesh
  26112. * @param b The second submesh
  26113. * @returns The result of the comparison
  26114. */
  26115. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26116. /**
  26117. * Resets the different lists of submeshes to prepare a new frame.
  26118. */
  26119. prepare(): void;
  26120. dispose(): void;
  26121. /**
  26122. * Inserts the submesh in its correct queue depending on its material.
  26123. * @param subMesh The submesh to dispatch
  26124. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26125. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26126. */
  26127. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26128. dispatchSprites(spriteManager: SpriteManager): void;
  26129. dispatchParticles(particleSystem: IParticleSystem): void;
  26130. private _renderParticles(activeMeshes);
  26131. private _renderSprites();
  26132. }
  26133. }
  26134. declare module BABYLON {
  26135. class RenderingManager {
  26136. /**
  26137. * The max id used for rendering groups (not included)
  26138. */
  26139. static MAX_RENDERINGGROUPS: number;
  26140. /**
  26141. * The min id used for rendering groups (included)
  26142. */
  26143. static MIN_RENDERINGGROUPS: number;
  26144. /**
  26145. * Used to globally prevent autoclearing scenes.
  26146. */
  26147. static AUTOCLEAR: boolean;
  26148. private _scene;
  26149. private _renderingGroups;
  26150. private _depthStencilBufferAlreadyCleaned;
  26151. private _autoClearDepthStencil;
  26152. private _customOpaqueSortCompareFn;
  26153. private _customAlphaTestSortCompareFn;
  26154. private _customTransparentSortCompareFn;
  26155. private _renderinGroupInfo;
  26156. constructor(scene: Scene);
  26157. private _clearDepthStencilBuffer(depth?, stencil?);
  26158. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26159. reset(): void;
  26160. dispose(): void;
  26161. /**
  26162. * Clear the info related to rendering groups preventing retention points during dispose.
  26163. */
  26164. freeRenderingGroups(): void;
  26165. private _prepareRenderingGroup(renderingGroupId);
  26166. dispatchSprites(spriteManager: SpriteManager): void;
  26167. dispatchParticles(particleSystem: IParticleSystem): void;
  26168. /**
  26169. * @param subMesh The submesh to dispatch
  26170. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26171. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26172. */
  26173. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26174. /**
  26175. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26176. * This allowed control for front to back rendering or reversly depending of the special needs.
  26177. *
  26178. * @param renderingGroupId The rendering group id corresponding to its index
  26179. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26180. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26181. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26182. */
  26183. 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;
  26184. /**
  26185. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26186. *
  26187. * @param renderingGroupId The rendering group id corresponding to its index
  26188. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26189. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26190. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26191. */
  26192. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26193. }
  26194. }
  26195. declare module BABYLON {
  26196. /**
  26197. * Renders a layer on top of an existing scene
  26198. */
  26199. class UtilityLayerRenderer implements IDisposable {
  26200. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26201. private _pointerCaptures;
  26202. private _lastPointerEvents;
  26203. /**
  26204. * The scene that is rendered on top of the original scene
  26205. */
  26206. utilityLayerScene: Scene;
  26207. /**
  26208. * If the utility layer should automatically be rendered on top of existing scene
  26209. */
  26210. shouldRender: boolean;
  26211. /**
  26212. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  26213. */
  26214. onlyCheckPointerDownEvents: boolean;
  26215. /**
  26216. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  26217. */
  26218. processAllEvents: boolean;
  26219. /**
  26220. * Observable raised when the pointer move from the utility layer scene to the main scene
  26221. */
  26222. onPointerOutObservable: Observable<number>;
  26223. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  26224. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  26225. private _afterRenderObserver;
  26226. private _sceneDisposeObserver;
  26227. private _originalPointerObserver;
  26228. /**
  26229. * Instantiates a UtilityLayerRenderer
  26230. * @param originalScene the original scene that will be rendered on top of
  26231. */
  26232. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26233. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  26234. /**
  26235. * Renders the utility layers scene on top of the original scene
  26236. */
  26237. render(): void;
  26238. /**
  26239. * Disposes of the renderer
  26240. */
  26241. dispose(): void;
  26242. private _updateCamera();
  26243. }
  26244. }
  26245. declare module BABYLON {
  26246. class Sprite {
  26247. name: string;
  26248. position: Vector3;
  26249. color: Color4;
  26250. width: number;
  26251. height: number;
  26252. angle: number;
  26253. cellIndex: number;
  26254. invertU: number;
  26255. invertV: number;
  26256. disposeWhenFinishedAnimating: boolean;
  26257. animations: Animation[];
  26258. isPickable: boolean;
  26259. actionManager: ActionManager;
  26260. private _animationStarted;
  26261. private _loopAnimation;
  26262. private _fromIndex;
  26263. private _toIndex;
  26264. private _delay;
  26265. private _direction;
  26266. private _manager;
  26267. private _time;
  26268. private _onAnimationEnd;
  26269. /**
  26270. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  26271. */
  26272. isVisible: boolean;
  26273. size: number;
  26274. constructor(name: string, manager: SpriteManager);
  26275. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26276. stopAnimation(): void;
  26277. _animate(deltaTime: number): void;
  26278. dispose(): void;
  26279. }
  26280. }
  26281. declare module BABYLON {
  26282. class SpriteManager {
  26283. name: string;
  26284. sprites: Sprite[];
  26285. renderingGroupId: number;
  26286. layerMask: number;
  26287. fogEnabled: boolean;
  26288. isPickable: boolean;
  26289. cellWidth: number;
  26290. cellHeight: number;
  26291. /**
  26292. * An event triggered when the manager is disposed.
  26293. */
  26294. onDisposeObservable: Observable<SpriteManager>;
  26295. private _onDisposeObserver;
  26296. onDispose: () => void;
  26297. private _capacity;
  26298. private _spriteTexture;
  26299. private _epsilon;
  26300. private _scene;
  26301. private _vertexData;
  26302. private _buffer;
  26303. private _vertexBuffers;
  26304. private _indexBuffer;
  26305. private _effectBase;
  26306. private _effectFog;
  26307. texture: Texture;
  26308. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26309. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26310. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26311. render(): void;
  26312. dispose(): void;
  26313. }
  26314. }
  26315. declare module BABYLON {
  26316. /**
  26317. * Postprocess used to generate anaglyphic rendering
  26318. */
  26319. class AnaglyphPostProcess extends PostProcess {
  26320. private _passedProcess;
  26321. /**
  26322. * Creates a new AnaglyphPostProcess
  26323. * @param name defines postprocess name
  26324. * @param options defines creation options or target ratio scale
  26325. * @param rigCameras defines cameras using this postprocess
  26326. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26327. * @param engine defines hosting engine
  26328. * @param reusable defines if the postprocess will be reused multiple times per frame
  26329. */
  26330. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26331. }
  26332. }
  26333. declare module BABYLON {
  26334. class BlackAndWhitePostProcess extends PostProcess {
  26335. degree: number;
  26336. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26337. }
  26338. }
  26339. declare module BABYLON {
  26340. /**
  26341. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26342. */
  26343. class BloomEffect extends PostProcessRenderEffect {
  26344. private bloomScale;
  26345. /**
  26346. * Internal
  26347. */
  26348. _effects: Array<PostProcess>;
  26349. /**
  26350. * Internal
  26351. */
  26352. _downscale: ExtractHighlightsPostProcess;
  26353. private _blurX;
  26354. private _blurY;
  26355. private _merge;
  26356. /**
  26357. * The luminance threshold to find bright areas of the image to bloom.
  26358. */
  26359. threshold: number;
  26360. /**
  26361. * The strength of the bloom.
  26362. */
  26363. weight: number;
  26364. /**
  26365. * Specifies the size of the bloom blur kernel, relative to the final output size
  26366. */
  26367. kernel: number;
  26368. /**
  26369. * Creates a new instance of @see BloomEffect
  26370. * @param scene The scene the effect belongs to.
  26371. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26372. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26373. * @param bloomWeight The the strength of bloom.
  26374. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26375. * @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)
  26376. */
  26377. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26378. /**
  26379. * Disposes each of the internal effects for a given camera.
  26380. * @param camera The camera to dispose the effect on.
  26381. */
  26382. disposeEffects(camera: Camera): void;
  26383. /**
  26384. * Internal
  26385. */
  26386. _updateEffects(): void;
  26387. /**
  26388. * Internal
  26389. * @returns if all the contained post processes are ready.
  26390. */
  26391. _isReady(): boolean;
  26392. }
  26393. }
  26394. declare module BABYLON {
  26395. /**
  26396. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26397. */
  26398. class BloomMergePostProcess extends PostProcess {
  26399. /** Weight of the bloom to be added to the original input. */ weight: number;
  26400. /**
  26401. * Creates a new instance of @see BloomMergePostProcess
  26402. * @param name The name of the effect.
  26403. * @param originalFromInput Post process which's input will be used for the merge.
  26404. * @param blurred Blurred highlights post process which's output will be used.
  26405. * @param weight Weight of the bloom to be added to the original input.
  26406. * @param options The required width/height ratio to downsize to before computing the render pass.
  26407. * @param camera The camera to apply the render pass to.
  26408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26409. * @param engine The engine which the post process will be applied. (default: current engine)
  26410. * @param reusable If the post process can be reused on the same frame. (default: false)
  26411. * @param textureType Type of textures used when performing the post process. (default: 0)
  26412. * @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)
  26413. */
  26414. 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);
  26415. }
  26416. }
  26417. declare module BABYLON {
  26418. /**
  26419. * The Blur Post Process which blurs an image based on a kernel and direction.
  26420. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26421. */
  26422. class BlurPostProcess extends PostProcess {
  26423. /** The direction in which to blur the image. */ direction: Vector2;
  26424. private blockCompilation;
  26425. protected _kernel: number;
  26426. protected _idealKernel: number;
  26427. protected _packedFloat: boolean;
  26428. private _staticDefines;
  26429. /**
  26430. * Gets the length in pixels of the blur sample region
  26431. */
  26432. /**
  26433. * Sets the length in pixels of the blur sample region
  26434. */
  26435. kernel: number;
  26436. /**
  26437. * Gets wether or not the blur is unpacking/repacking floats
  26438. */
  26439. /**
  26440. * Sets wether or not the blur needs to unpack/repack floats
  26441. */
  26442. packedFloat: boolean;
  26443. /**
  26444. * Creates a new instance BlurPostProcess
  26445. * @param name The name of the effect.
  26446. * @param direction The direction in which to blur the image.
  26447. * @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.
  26448. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26449. * @param camera The camera to apply the render pass to.
  26450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26451. * @param engine The engine which the post process will be applied. (default: current engine)
  26452. * @param reusable If the post process can be reused on the same frame. (default: false)
  26453. * @param textureType Type of textures used when performing the post process. (default: 0)
  26454. * @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)
  26455. */
  26456. 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);
  26457. /**
  26458. * Updates the effect with the current post process compile time values and recompiles the shader.
  26459. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26460. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26461. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26462. * @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
  26463. * @param onCompiled Called when the shader has been compiled.
  26464. * @param onError Called if there is an error when compiling a shader.
  26465. */
  26466. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26467. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26468. /**
  26469. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  26470. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  26471. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  26472. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  26473. * The gaps between physical kernels are compensated for in the weighting of the samples
  26474. * @param idealKernel Ideal blur kernel.
  26475. * @return Nearest best kernel.
  26476. */
  26477. protected _nearestBestKernel(idealKernel: number): number;
  26478. /**
  26479. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  26480. * @param x The point on the Gaussian distribution to sample.
  26481. * @return the value of the Gaussian function at x.
  26482. */
  26483. protected _gaussianWeight(x: number): number;
  26484. /**
  26485. * Generates a string that can be used as a floating point number in GLSL.
  26486. * @param x Value to print.
  26487. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  26488. * @return GLSL float string.
  26489. */
  26490. protected _glslFloat(x: number, decimalFigures?: number): string;
  26491. }
  26492. }
  26493. declare module BABYLON {
  26494. /**
  26495. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  26496. */
  26497. class ChromaticAberrationPostProcess extends PostProcess {
  26498. /**
  26499. * The amount of seperation of rgb channels (default: 30)
  26500. */
  26501. aberrationAmount: number;
  26502. /**
  26503. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  26504. */
  26505. radialIntensity: number;
  26506. /**
  26507. * 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))
  26508. */
  26509. direction: Vector2;
  26510. /**
  26511. * 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))
  26512. */
  26513. centerPosition: Vector2;
  26514. /**
  26515. * Creates a new instance ChromaticAberrationPostProcess
  26516. * @param name The name of the effect.
  26517. * @param screenWidth The width of the screen to apply the effect on.
  26518. * @param screenHeight The height of the screen to apply the effect on.
  26519. * @param options The required width/height ratio to downsize to before computing the render pass.
  26520. * @param camera The camera to apply the render pass to.
  26521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26522. * @param engine The engine which the post process will be applied. (default: current engine)
  26523. * @param reusable If the post process can be reused on the same frame. (default: false)
  26524. * @param textureType Type of textures used when performing the post process. (default: 0)
  26525. * @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)
  26526. */
  26527. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26528. }
  26529. }
  26530. declare module BABYLON {
  26531. /**
  26532. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  26533. */
  26534. class CircleOfConfusionPostProcess extends PostProcess {
  26535. /**
  26536. * 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.
  26537. */
  26538. lensSize: number;
  26539. /**
  26540. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26541. */
  26542. fStop: number;
  26543. /**
  26544. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26545. */
  26546. focusDistance: number;
  26547. /**
  26548. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  26549. */
  26550. focalLength: number;
  26551. private _depthTexture;
  26552. /**
  26553. * Creates a new instance CircleOfConfusionPostProcess
  26554. * @param name The name of the effect.
  26555. * @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.
  26556. * @param options The required width/height ratio to downsize to before computing the render pass.
  26557. * @param camera The camera to apply the render pass to.
  26558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26559. * @param engine The engine which the post process will be applied. (default: current engine)
  26560. * @param reusable If the post process can be reused on the same frame. (default: false)
  26561. * @param textureType Type of textures used when performing the post process. (default: 0)
  26562. * @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)
  26563. */
  26564. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26565. /**
  26566. * 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.
  26567. */
  26568. depthTexture: RenderTargetTexture;
  26569. }
  26570. }
  26571. declare module BABYLON {
  26572. class ColorCorrectionPostProcess extends PostProcess {
  26573. private _colorTableTexture;
  26574. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26575. }
  26576. }
  26577. declare module BABYLON {
  26578. /**
  26579. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  26580. * input texture to perform effects such as edge detection or sharpening
  26581. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26582. */
  26583. class ConvolutionPostProcess extends PostProcess {
  26584. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  26585. /**
  26586. * Creates a new instance ConvolutionPostProcess
  26587. * @param name The name of the effect.
  26588. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  26589. * @param options The required width/height ratio to downsize to before computing the render pass.
  26590. * @param camera The camera to apply the render pass to.
  26591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26592. * @param engine The engine which the post process will be applied. (default: current engine)
  26593. * @param reusable If the post process can be reused on the same frame. (default: false)
  26594. * @param textureType Type of textures used when performing the post process. (default: 0)
  26595. */
  26596. 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);
  26597. /**
  26598. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26599. */
  26600. static EdgeDetect0Kernel: number[];
  26601. /**
  26602. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26603. */
  26604. static EdgeDetect1Kernel: number[];
  26605. /**
  26606. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26607. */
  26608. static EdgeDetect2Kernel: number[];
  26609. /**
  26610. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26611. */
  26612. static SharpenKernel: number[];
  26613. /**
  26614. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26615. */
  26616. static EmbossKernel: number[];
  26617. /**
  26618. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26619. */
  26620. static GaussianKernel: number[];
  26621. }
  26622. }
  26623. declare module BABYLON {
  26624. /**
  26625. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  26626. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  26627. * based on samples that have a large difference in distance than the center pixel.
  26628. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  26629. */
  26630. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  26631. direction: Vector2;
  26632. /**
  26633. * Creates a new instance CircleOfConfusionPostProcess
  26634. * @param name The name of the effect.
  26635. * @param scene The scene the effect belongs to.
  26636. * @param direction The direction the blur should be applied.
  26637. * @param kernel The size of the kernel used to blur.
  26638. * @param options The required width/height ratio to downsize to before computing the render pass.
  26639. * @param camera The camera to apply the render pass to.
  26640. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  26641. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  26642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26643. * @param engine The engine which the post process will be applied. (default: current engine)
  26644. * @param reusable If the post process can be reused on the same frame. (default: false)
  26645. * @param textureType Type of textures used when performing the post process. (default: 0)
  26646. * @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)
  26647. */
  26648. 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);
  26649. }
  26650. }
  26651. declare module BABYLON {
  26652. /**
  26653. * Specifies the level of max blur that should be applied when using the depth of field effect
  26654. */
  26655. enum DepthOfFieldEffectBlurLevel {
  26656. /**
  26657. * Subtle blur
  26658. */
  26659. Low = 0,
  26660. /**
  26661. * Medium blur
  26662. */
  26663. Medium = 1,
  26664. /**
  26665. * Large blur
  26666. */
  26667. High = 2,
  26668. }
  26669. /**
  26670. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  26671. */
  26672. class DepthOfFieldEffect extends PostProcessRenderEffect {
  26673. private _circleOfConfusion;
  26674. /**
  26675. * Internal, blurs from high to low
  26676. */
  26677. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  26678. private _depthOfFieldBlurY;
  26679. private _dofMerge;
  26680. /**
  26681. * Internal post processes in depth of field effect
  26682. */
  26683. _effects: Array<PostProcess>;
  26684. /**
  26685. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  26686. */
  26687. focalLength: number;
  26688. /**
  26689. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26690. */
  26691. fStop: number;
  26692. /**
  26693. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26694. */
  26695. focusDistance: number;
  26696. /**
  26697. * 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.
  26698. */
  26699. lensSize: number;
  26700. /**
  26701. * Creates a new instance DepthOfFieldEffect
  26702. * @param scene The scene the effect belongs to.
  26703. * @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.
  26704. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26705. * @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)
  26706. */
  26707. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  26708. /**
  26709. * 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.
  26710. */
  26711. depthTexture: RenderTargetTexture;
  26712. /**
  26713. * Disposes each of the internal effects for a given camera.
  26714. * @param camera The camera to dispose the effect on.
  26715. */
  26716. disposeEffects(camera: Camera): void;
  26717. /**
  26718. * Internal
  26719. */
  26720. _updateEffects(): void;
  26721. /**
  26722. * Internal
  26723. * @returns if all the contained post processes are ready.
  26724. */
  26725. _isReady(): boolean;
  26726. }
  26727. }
  26728. declare module BABYLON {
  26729. /**
  26730. * Options to be set when merging outputs from the default pipeline.
  26731. */
  26732. class DepthOfFieldMergePostProcessOptions {
  26733. /**
  26734. * The original image to merge on top of
  26735. */
  26736. originalFromInput: PostProcess;
  26737. /**
  26738. * Parameters to perform the merge of the depth of field effect
  26739. */
  26740. depthOfField?: {
  26741. circleOfConfusion: PostProcess;
  26742. blurSteps: Array<PostProcess>;
  26743. };
  26744. /**
  26745. * Parameters to perform the merge of bloom effect
  26746. */
  26747. bloom?: {
  26748. blurred: PostProcess;
  26749. weight: number;
  26750. };
  26751. }
  26752. /**
  26753. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26754. */
  26755. class DepthOfFieldMergePostProcess extends PostProcess {
  26756. private blurSteps;
  26757. /**
  26758. * Creates a new instance of DepthOfFieldMergePostProcess
  26759. * @param name The name of the effect.
  26760. * @param originalFromInput Post process which's input will be used for the merge.
  26761. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  26762. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  26763. * @param options The required width/height ratio to downsize to before computing the render pass.
  26764. * @param camera The camera to apply the render pass to.
  26765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26766. * @param engine The engine which the post process will be applied. (default: current engine)
  26767. * @param reusable If the post process can be reused on the same frame. (default: false)
  26768. * @param textureType Type of textures used when performing the post process. (default: 0)
  26769. * @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)
  26770. */
  26771. 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);
  26772. /**
  26773. * Updates the effect with the current post process compile time values and recompiles the shader.
  26774. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26775. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26776. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26777. * @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
  26778. * @param onCompiled Called when the shader has been compiled.
  26779. * @param onError Called if there is an error when compiling a shader.
  26780. */
  26781. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26782. }
  26783. }
  26784. declare module BABYLON {
  26785. class DisplayPassPostProcess extends PostProcess {
  26786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26787. }
  26788. }
  26789. declare module BABYLON {
  26790. /**
  26791. * 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.
  26792. */
  26793. class ExtractHighlightsPostProcess extends PostProcess {
  26794. /**
  26795. * The luminance threshold, pixels below this value will be set to black.
  26796. */
  26797. threshold: number;
  26798. /**
  26799. * Internal
  26800. */
  26801. _exposure: number;
  26802. /**
  26803. * Post process which has the input texture to be used when performing highlight extraction
  26804. */
  26805. _inputPostProcess: Nullable<PostProcess>;
  26806. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26807. }
  26808. }
  26809. declare module BABYLON {
  26810. class FilterPostProcess extends PostProcess {
  26811. kernelMatrix: Matrix;
  26812. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26813. }
  26814. }
  26815. declare module BABYLON {
  26816. class FxaaPostProcess extends PostProcess {
  26817. texelWidth: number;
  26818. texelHeight: number;
  26819. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26820. private _getDefines();
  26821. }
  26822. }
  26823. declare module BABYLON {
  26824. /**
  26825. * The GrainPostProcess adds noise to the image at mid luminance levels
  26826. */
  26827. class GrainPostProcess extends PostProcess {
  26828. /**
  26829. * The intensity of the grain added (default: 30)
  26830. */
  26831. intensity: number;
  26832. /**
  26833. * If the grain should be randomized on every frame
  26834. */
  26835. animated: boolean;
  26836. /**
  26837. * Creates a new instance of @see GrainPostProcess
  26838. * @param name The name of the effect.
  26839. * @param options The required width/height ratio to downsize to before computing the render pass.
  26840. * @param camera The camera to apply the render pass to.
  26841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26842. * @param engine The engine which the post process will be applied. (default: current engine)
  26843. * @param reusable If the post process can be reused on the same frame. (default: false)
  26844. * @param textureType Type of textures used when performing the post process. (default: 0)
  26845. * @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)
  26846. */
  26847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26848. }
  26849. }
  26850. declare module BABYLON {
  26851. class HighlightsPostProcess extends PostProcess {
  26852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. class ImageProcessingPostProcess extends PostProcess {
  26857. /**
  26858. * Default configuration related to image processing available in the PBR Material.
  26859. */
  26860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26861. /**
  26862. * Gets the image processing configuration used either in this material.
  26863. */
  26864. /**
  26865. * Sets the Default image processing configuration used either in the this material.
  26866. *
  26867. * If sets to null, the scene one is in use.
  26868. */
  26869. imageProcessingConfiguration: ImageProcessingConfiguration;
  26870. /**
  26871. * Keep track of the image processing observer to allow dispose and replace.
  26872. */
  26873. private _imageProcessingObserver;
  26874. /**
  26875. * Attaches a new image processing configuration to the PBR Material.
  26876. * @param configuration
  26877. */
  26878. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  26879. /**
  26880. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26881. */
  26882. /**
  26883. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26884. */
  26885. colorCurves: Nullable<ColorCurves>;
  26886. /**
  26887. * Gets wether the color curves effect is enabled.
  26888. */
  26889. /**
  26890. * Sets wether the color curves effect is enabled.
  26891. */
  26892. colorCurvesEnabled: boolean;
  26893. /**
  26894. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26895. */
  26896. /**
  26897. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26898. */
  26899. colorGradingTexture: Nullable<BaseTexture>;
  26900. /**
  26901. * Gets wether the color grading effect is enabled.
  26902. */
  26903. /**
  26904. * Gets wether the color grading effect is enabled.
  26905. */
  26906. colorGradingEnabled: boolean;
  26907. /**
  26908. * Gets exposure used in the effect.
  26909. */
  26910. /**
  26911. * Sets exposure used in the effect.
  26912. */
  26913. exposure: number;
  26914. /**
  26915. * Gets wether tonemapping is enabled or not.
  26916. */
  26917. /**
  26918. * Sets wether tonemapping is enabled or not
  26919. */
  26920. toneMappingEnabled: boolean;
  26921. /**
  26922. * Gets contrast used in the effect.
  26923. */
  26924. /**
  26925. * Sets contrast used in the effect.
  26926. */
  26927. contrast: number;
  26928. /**
  26929. * Gets Vignette stretch size.
  26930. */
  26931. /**
  26932. * Sets Vignette stretch size.
  26933. */
  26934. vignetteStretch: number;
  26935. /**
  26936. * Gets Vignette centre X Offset.
  26937. */
  26938. /**
  26939. * Sets Vignette centre X Offset.
  26940. */
  26941. vignetteCentreX: number;
  26942. /**
  26943. * Gets Vignette centre Y Offset.
  26944. */
  26945. /**
  26946. * Sets Vignette centre Y Offset.
  26947. */
  26948. vignetteCentreY: number;
  26949. /**
  26950. * Gets Vignette weight or intensity of the vignette effect.
  26951. */
  26952. /**
  26953. * Sets Vignette weight or intensity of the vignette effect.
  26954. */
  26955. vignetteWeight: number;
  26956. /**
  26957. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26958. * if vignetteEnabled is set to true.
  26959. */
  26960. /**
  26961. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26962. * if vignetteEnabled is set to true.
  26963. */
  26964. vignetteColor: Color4;
  26965. /**
  26966. * Gets Camera field of view used by the Vignette effect.
  26967. */
  26968. /**
  26969. * Sets Camera field of view used by the Vignette effect.
  26970. */
  26971. vignetteCameraFov: number;
  26972. /**
  26973. * Gets the vignette blend mode allowing different kind of effect.
  26974. */
  26975. /**
  26976. * Sets the vignette blend mode allowing different kind of effect.
  26977. */
  26978. vignetteBlendMode: number;
  26979. /**
  26980. * Gets wether the vignette effect is enabled.
  26981. */
  26982. /**
  26983. * Sets wether the vignette effect is enabled.
  26984. */
  26985. vignetteEnabled: boolean;
  26986. private _fromLinearSpace;
  26987. /**
  26988. * Gets wether the input of the processing is in Gamma or Linear Space.
  26989. */
  26990. /**
  26991. * Sets wether the input of the processing is in Gamma or Linear Space.
  26992. */
  26993. fromLinearSpace: boolean;
  26994. /**
  26995. * Defines cache preventing GC.
  26996. */
  26997. private _defines;
  26998. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26999. getClassName(): string;
  27000. protected _updateParameters(): void;
  27001. dispose(camera?: Camera): void;
  27002. }
  27003. }
  27004. declare module BABYLON {
  27005. class PassPostProcess extends PostProcess {
  27006. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27007. }
  27008. }
  27009. declare module BABYLON {
  27010. type PostProcessOptions = {
  27011. width: number;
  27012. height: number;
  27013. };
  27014. /**
  27015. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27016. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27017. */
  27018. class PostProcess {
  27019. /** Name of the PostProcess. */ name: string;
  27020. /**
  27021. * Width of the texture to apply the post process on
  27022. */
  27023. width: number;
  27024. /**
  27025. * Height of the texture to apply the post process on
  27026. */
  27027. height: number;
  27028. /**
  27029. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27030. */
  27031. _outputTexture: Nullable<InternalTexture>;
  27032. /**
  27033. * Sampling mode used by the shader
  27034. * See https://doc.babylonjs.com/classes/3.1/texture
  27035. */
  27036. renderTargetSamplingMode: number;
  27037. /**
  27038. * Clear color to use when screen clearing
  27039. */
  27040. clearColor: Color4;
  27041. /**
  27042. * If the buffer needs to be cleared before applying the post process. (default: true)
  27043. * Should be set to false if shader will overwrite all previous pixels.
  27044. */
  27045. autoClear: boolean;
  27046. /**
  27047. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27048. */
  27049. alphaMode: number;
  27050. /**
  27051. * Sets the setAlphaBlendConstants of the babylon engine
  27052. */
  27053. alphaConstants: Color4;
  27054. /**
  27055. * Animations to be used for the post processing
  27056. */
  27057. animations: Animation[];
  27058. /**
  27059. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27060. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27061. */
  27062. enablePixelPerfectMode: boolean;
  27063. /**
  27064. * Force the postprocess to be applied without taking in account viewport
  27065. */
  27066. forceFullscreenViewport: boolean;
  27067. /**
  27068. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27069. *
  27070. * | Value | Type | Description |
  27071. * | ----- | ----------------------------------- | ----------- |
  27072. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27073. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27074. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27075. *
  27076. */
  27077. scaleMode: number;
  27078. /**
  27079. * Force textures to be a power of two (default: false)
  27080. */
  27081. alwaysForcePOT: boolean;
  27082. /**
  27083. * Number of sample textures (default: 1)
  27084. */
  27085. samples: number;
  27086. /**
  27087. * Modify the scale of the post process to be the same as the viewport (default: false)
  27088. */
  27089. adaptScaleToCurrentViewport: boolean;
  27090. private _camera;
  27091. private _scene;
  27092. private _engine;
  27093. private _options;
  27094. private _reusable;
  27095. private _textureType;
  27096. /**
  27097. * Smart array of input and output textures for the post process.
  27098. */
  27099. _textures: SmartArray<InternalTexture>;
  27100. /**
  27101. * The index in _textures that corresponds to the output texture.
  27102. */
  27103. _currentRenderTextureInd: number;
  27104. private _effect;
  27105. private _samplers;
  27106. private _fragmentUrl;
  27107. private _vertexUrl;
  27108. private _parameters;
  27109. private _scaleRatio;
  27110. protected _indexParameters: any;
  27111. private _shareOutputWithPostProcess;
  27112. private _texelSize;
  27113. private _forcedOutputTexture;
  27114. /**
  27115. * An event triggered when the postprocess is activated.
  27116. */
  27117. onActivateObservable: Observable<Camera>;
  27118. private _onActivateObserver;
  27119. /**
  27120. * A function that is added to the onActivateObservable
  27121. */
  27122. onActivate: Nullable<(camera: Camera) => void>;
  27123. /**
  27124. * An event triggered when the postprocess changes its size.
  27125. */
  27126. onSizeChangedObservable: Observable<PostProcess>;
  27127. private _onSizeChangedObserver;
  27128. /**
  27129. * A function that is added to the onSizeChangedObservable
  27130. */
  27131. onSizeChanged: (postProcess: PostProcess) => void;
  27132. /**
  27133. * An event triggered when the postprocess applies its effect.
  27134. */
  27135. onApplyObservable: Observable<Effect>;
  27136. private _onApplyObserver;
  27137. /**
  27138. * A function that is added to the onApplyObservable
  27139. */
  27140. onApply: (effect: Effect) => void;
  27141. /**
  27142. * An event triggered before rendering the postprocess
  27143. */
  27144. onBeforeRenderObservable: Observable<Effect>;
  27145. private _onBeforeRenderObserver;
  27146. /**
  27147. * A function that is added to the onBeforeRenderObservable
  27148. */
  27149. onBeforeRender: (effect: Effect) => void;
  27150. /**
  27151. * An event triggered after rendering the postprocess
  27152. */
  27153. onAfterRenderObservable: Observable<Effect>;
  27154. private _onAfterRenderObserver;
  27155. /**
  27156. * A function that is added to the onAfterRenderObservable
  27157. */
  27158. onAfterRender: (efect: Effect) => void;
  27159. /**
  27160. * 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
  27161. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27162. */
  27163. inputTexture: InternalTexture;
  27164. /**
  27165. * Gets the camera which post process is applied to.
  27166. * @returns The camera the post process is applied to.
  27167. */
  27168. getCamera(): Camera;
  27169. /**
  27170. * Gets the texel size of the postprocess.
  27171. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27172. */
  27173. readonly texelSize: Vector2;
  27174. /**
  27175. * Creates a new instance PostProcess
  27176. * @param name The name of the PostProcess.
  27177. * @param fragmentUrl The url of the fragment shader to be used.
  27178. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27179. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27180. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27181. * @param camera The camera to apply the render pass to.
  27182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27183. * @param engine The engine which the post process will be applied. (default: current engine)
  27184. * @param reusable If the post process can be reused on the same frame. (default: false)
  27185. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27186. * @param textureType Type of textures used when performing the post process. (default: 0)
  27187. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27188. * @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
  27189. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27190. */
  27191. 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);
  27192. /**
  27193. * Gets the engine which this post process belongs to.
  27194. * @returns The engine the post process was enabled with.
  27195. */
  27196. getEngine(): Engine;
  27197. /**
  27198. * The effect that is created when initializing the post process.
  27199. * @returns The created effect corrisponding the the postprocess.
  27200. */
  27201. getEffect(): Effect;
  27202. /**
  27203. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27204. * @param postProcess The post process to share the output with.
  27205. * @returns This post process.
  27206. */
  27207. shareOutputWith(postProcess: PostProcess): PostProcess;
  27208. /**
  27209. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27210. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27211. */
  27212. useOwnOutput(): void;
  27213. /**
  27214. * Updates the effect with the current post process compile time values and recompiles the shader.
  27215. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27216. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27217. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27218. * @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
  27219. * @param onCompiled Called when the shader has been compiled.
  27220. * @param onError Called if there is an error when compiling a shader.
  27221. */
  27222. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27223. /**
  27224. * The post process is reusable if it can be used multiple times within one frame.
  27225. * @returns If the post process is reusable
  27226. */
  27227. isReusable(): boolean;
  27228. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27229. markTextureDirty(): void;
  27230. /**
  27231. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27232. * 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.
  27233. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27234. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27235. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27236. * @returns The target texture that was bound to be written to.
  27237. */
  27238. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27239. /**
  27240. * If the post process is supported.
  27241. */
  27242. readonly isSupported: boolean;
  27243. /**
  27244. * The aspect ratio of the output texture.
  27245. */
  27246. readonly aspectRatio: number;
  27247. /**
  27248. * Get a value indicating if the post-process is ready to be used
  27249. * @returns true if the post-process is ready (shader is compiled)
  27250. */
  27251. isReady(): boolean;
  27252. /**
  27253. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27254. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27255. */
  27256. apply(): Nullable<Effect>;
  27257. private _disposeTextures();
  27258. /**
  27259. * Disposes the post process.
  27260. * @param camera The camera to dispose the post process on.
  27261. */
  27262. dispose(camera?: Camera): void;
  27263. }
  27264. }
  27265. declare module BABYLON {
  27266. /**
  27267. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27268. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27269. */
  27270. class PostProcessManager {
  27271. private _scene;
  27272. private _indexBuffer;
  27273. private _vertexBuffers;
  27274. /**
  27275. * Creates a new instance PostProcess
  27276. * @param scene The scene that the post process is associated with.
  27277. */
  27278. constructor(scene: Scene);
  27279. private _prepareBuffers();
  27280. private _buildIndexBuffer();
  27281. /**
  27282. * Rebuilds the vertex buffers of the manager.
  27283. */
  27284. _rebuild(): void;
  27285. /**
  27286. * Prepares a frame to be run through a post process.
  27287. * @param sourceTexture The input texture to the post procesess. (default: null)
  27288. * @param postProcesses An array of post processes to be run. (default: null)
  27289. * @returns True if the post processes were able to be run.
  27290. */
  27291. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27292. /**
  27293. * Manually render a set of post processes to a texture.
  27294. * @param postProcesses An array of post processes to be run.
  27295. * @param targetTexture The target texture to render to.
  27296. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  27297. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  27298. * @param lodLevel defines which lod of the texture to render to
  27299. */
  27300. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  27301. /**
  27302. * Finalize the result of the output of the postprocesses.
  27303. * @param doNotPresent If true the result will not be displayed to the screen.
  27304. * @param targetTexture The target texture to render to.
  27305. * @param faceIndex The index of the face to bind the target texture to.
  27306. * @param postProcesses The array of post processes to render.
  27307. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27308. */
  27309. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  27310. /**
  27311. * Disposes of the post process manager.
  27312. */
  27313. dispose(): void;
  27314. }
  27315. }
  27316. declare module BABYLON {
  27317. class RefractionPostProcess extends PostProcess {
  27318. color: Color3;
  27319. depth: number;
  27320. colorLevel: number;
  27321. private _refTexture;
  27322. private _ownRefractionTexture;
  27323. /**
  27324. * Gets or sets the refraction texture
  27325. * Please note that you are responsible for disposing the texture if you set it manually
  27326. */
  27327. refractionTexture: Texture;
  27328. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27329. dispose(camera: Camera): void;
  27330. }
  27331. }
  27332. declare module BABYLON {
  27333. /**
  27334. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27335. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27336. */
  27337. class SharpenPostProcess extends PostProcess {
  27338. /**
  27339. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27340. */
  27341. colorAmount: number;
  27342. /**
  27343. * How much sharpness should be applied (default: 0.3)
  27344. */
  27345. edgeAmount: number;
  27346. /**
  27347. * Creates a new instance ConvolutionPostProcess
  27348. * @param name The name of the effect.
  27349. * @param options The required width/height ratio to downsize to before computing the render pass.
  27350. * @param camera The camera to apply the render pass to.
  27351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27352. * @param engine The engine which the post process will be applied. (default: current engine)
  27353. * @param reusable If the post process can be reused on the same frame. (default: false)
  27354. * @param textureType Type of textures used when performing the post process. (default: 0)
  27355. * @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)
  27356. */
  27357. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27358. }
  27359. }
  27360. declare module BABYLON {
  27361. class StereoscopicInterlacePostProcess extends PostProcess {
  27362. private _stepSize;
  27363. private _passedProcess;
  27364. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27365. }
  27366. }
  27367. declare module BABYLON {
  27368. /** Defines operator used for tonemapping */
  27369. enum TonemappingOperator {
  27370. /** Hable */
  27371. Hable = 0,
  27372. /** Reinhard */
  27373. Reinhard = 1,
  27374. /** HejiDawson */
  27375. HejiDawson = 2,
  27376. /** Photographic */
  27377. Photographic = 3,
  27378. }
  27379. /**
  27380. * Defines a post process to apply tone mapping
  27381. */
  27382. class TonemapPostProcess extends PostProcess {
  27383. private _operator;
  27384. /** Defines the required exposure adjustement */
  27385. exposureAdjustment: number;
  27386. /**
  27387. * Creates a new TonemapPostProcess
  27388. * @param name defines the name of the postprocess
  27389. * @param _operator defines the operator to use
  27390. * @param exposureAdjustment defines the required exposure adjustement
  27391. * @param camera defines the camera to use (can be null)
  27392. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  27393. * @param engine defines the hosting engine (can be ignore if camera is set)
  27394. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27395. */
  27396. constructor(name: string, _operator: TonemappingOperator,
  27397. /** Defines the required exposure adjustement */
  27398. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  27399. }
  27400. }
  27401. declare module BABYLON {
  27402. class VolumetricLightScatteringPostProcess extends PostProcess {
  27403. private _volumetricLightScatteringPass;
  27404. private _volumetricLightScatteringRTT;
  27405. private _viewPort;
  27406. private _screenCoordinates;
  27407. private _cachedDefines;
  27408. /**
  27409. * If not undefined, the mesh position is computed from the attached node position
  27410. */
  27411. attachedNode: {
  27412. position: Vector3;
  27413. };
  27414. /**
  27415. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  27416. */
  27417. customMeshPosition: Vector3;
  27418. /**
  27419. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  27420. */
  27421. useCustomMeshPosition: boolean;
  27422. /**
  27423. * If the post-process should inverse the light scattering direction
  27424. */
  27425. invert: boolean;
  27426. /**
  27427. * The internal mesh used by the post-process
  27428. */
  27429. mesh: Mesh;
  27430. useDiffuseColor: boolean;
  27431. /**
  27432. * Array containing the excluded meshes not rendered in the internal pass
  27433. */
  27434. excludedMeshes: AbstractMesh[];
  27435. /**
  27436. * Controls the overall intensity of the post-process
  27437. */
  27438. exposure: number;
  27439. /**
  27440. * Dissipates each sample's contribution in range [0, 1]
  27441. */
  27442. decay: number;
  27443. /**
  27444. * Controls the overall intensity of each sample
  27445. */
  27446. weight: number;
  27447. /**
  27448. * Controls the density of each sample
  27449. */
  27450. density: number;
  27451. /**
  27452. * @constructor
  27453. * @param {string} name - The post-process name
  27454. * @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)
  27455. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  27456. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  27457. * @param {number} samples - The post-process quality, default 100
  27458. * @param {number} samplingMode - The post-process filtering mode
  27459. * @param {BABYLON.Engine} engine - The babylon engine
  27460. * @param {boolean} reusable - If the post-process is reusable
  27461. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  27462. */
  27463. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  27464. getClassName(): string;
  27465. private _isReady(subMesh, useInstances);
  27466. /**
  27467. * Sets the new light position for light scattering effect
  27468. * @param {BABYLON.Vector3} The new custom light position
  27469. */
  27470. setCustomMeshPosition(position: Vector3): void;
  27471. /**
  27472. * Returns the light position for light scattering effect
  27473. * @return {BABYLON.Vector3} The custom light position
  27474. */
  27475. getCustomMeshPosition(): Vector3;
  27476. /**
  27477. * Disposes the internal assets and detaches the post-process from the camera
  27478. */
  27479. dispose(camera: Camera): void;
  27480. /**
  27481. * Returns the render target texture used by the post-process
  27482. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  27483. */
  27484. getPass(): RenderTargetTexture;
  27485. private _meshExcluded(mesh);
  27486. private _createPass(scene, ratio);
  27487. private _updateMeshScreenCoordinates(scene);
  27488. /**
  27489. * Creates a default mesh for the Volumeric Light Scattering post-process
  27490. * @param {string} The mesh name
  27491. * @param {BABYLON.Scene} The scene where to create the mesh
  27492. * @return {BABYLON.Mesh} the default mesh
  27493. */
  27494. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  27495. }
  27496. }
  27497. declare module BABYLON {
  27498. class VRDistortionCorrectionPostProcess extends PostProcess {
  27499. private _isRightEye;
  27500. private _distortionFactors;
  27501. private _postProcessScaleFactor;
  27502. private _lensCenterOffset;
  27503. private _scaleIn;
  27504. private _scaleFactor;
  27505. private _lensCenter;
  27506. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27507. }
  27508. }
  27509. declare module BABYLON {
  27510. /**
  27511. * @hidden
  27512. **/
  27513. class _AlphaState {
  27514. private _isAlphaBlendDirty;
  27515. private _isBlendFunctionParametersDirty;
  27516. private _isBlendEquationParametersDirty;
  27517. private _isBlendConstantsDirty;
  27518. private _alphaBlend;
  27519. private _blendFunctionParameters;
  27520. private _blendEquationParameters;
  27521. private _blendConstants;
  27522. /**
  27523. * Initializes the state.
  27524. */
  27525. constructor();
  27526. readonly isDirty: boolean;
  27527. alphaBlend: boolean;
  27528. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  27529. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  27530. setAlphaEquationParameters(rgb: number, alpha: number): void;
  27531. reset(): void;
  27532. apply(gl: WebGLRenderingContext): void;
  27533. }
  27534. }
  27535. declare module BABYLON {
  27536. /**
  27537. * @hidden
  27538. **/
  27539. class _DepthCullingState {
  27540. private _isDepthTestDirty;
  27541. private _isDepthMaskDirty;
  27542. private _isDepthFuncDirty;
  27543. private _isCullFaceDirty;
  27544. private _isCullDirty;
  27545. private _isZOffsetDirty;
  27546. private _isFrontFaceDirty;
  27547. private _depthTest;
  27548. private _depthMask;
  27549. private _depthFunc;
  27550. private _cull;
  27551. private _cullFace;
  27552. private _zOffset;
  27553. private _frontFace;
  27554. /**
  27555. * Initializes the state.
  27556. */
  27557. constructor();
  27558. readonly isDirty: boolean;
  27559. zOffset: number;
  27560. cullFace: Nullable<number>;
  27561. cull: Nullable<boolean>;
  27562. depthFunc: Nullable<number>;
  27563. depthMask: boolean;
  27564. depthTest: boolean;
  27565. frontFace: Nullable<number>;
  27566. reset(): void;
  27567. apply(gl: WebGLRenderingContext): void;
  27568. }
  27569. }
  27570. declare module BABYLON {
  27571. /**
  27572. * @hidden
  27573. **/
  27574. class _StencilState {
  27575. private _isStencilTestDirty;
  27576. private _isStencilMaskDirty;
  27577. private _isStencilFuncDirty;
  27578. private _isStencilOpDirty;
  27579. private _stencilTest;
  27580. private _stencilMask;
  27581. private _stencilFunc;
  27582. private _stencilFuncRef;
  27583. private _stencilFuncMask;
  27584. private _stencilOpStencilFail;
  27585. private _stencilOpDepthFail;
  27586. private _stencilOpStencilDepthPass;
  27587. readonly isDirty: boolean;
  27588. stencilFunc: number;
  27589. stencilFuncRef: number;
  27590. stencilFuncMask: number;
  27591. stencilOpStencilFail: number;
  27592. stencilOpDepthFail: number;
  27593. stencilOpStencilDepthPass: number;
  27594. stencilMask: number;
  27595. stencilTest: boolean;
  27596. constructor();
  27597. reset(): void;
  27598. apply(gl: WebGLRenderingContext): void;
  27599. }
  27600. }
  27601. declare module BABYLON {
  27602. /**
  27603. * Class used to evalaute queries containing `and` and `or` operators
  27604. */
  27605. class AndOrNotEvaluator {
  27606. /**
  27607. * Evaluate a query
  27608. * @param query defines the query to evaluate
  27609. * @param evaluateCallback defines the callback used to filter result
  27610. * @returns true if the query matches
  27611. */
  27612. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27613. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27614. private static _SimplifyNegation(booleanString);
  27615. }
  27616. }
  27617. declare module BABYLON {
  27618. /**
  27619. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27620. */
  27621. enum AssetTaskState {
  27622. /**
  27623. * Initialization
  27624. */
  27625. INIT = 0,
  27626. /**
  27627. * Running
  27628. */
  27629. RUNNING = 1,
  27630. /**
  27631. * Done
  27632. */
  27633. DONE = 2,
  27634. /**
  27635. * Error
  27636. */
  27637. ERROR = 3,
  27638. }
  27639. /**
  27640. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27641. */
  27642. abstract class AbstractAssetTask {
  27643. /**
  27644. * Task name
  27645. */ name: string;
  27646. /**
  27647. * Callback called when the task is successful
  27648. */
  27649. onSuccess: (task: any) => void;
  27650. /**
  27651. * Callback called when the task is not successful
  27652. */
  27653. onError: (task: any, message?: string, exception?: any) => void;
  27654. /**
  27655. * Creates a new {BABYLON.AssetsManager}
  27656. * @param name defines the name of the task
  27657. */
  27658. constructor(
  27659. /**
  27660. * Task name
  27661. */ name: string);
  27662. private _isCompleted;
  27663. private _taskState;
  27664. private _errorObject;
  27665. /**
  27666. * Get if the task is completed
  27667. */
  27668. readonly isCompleted: boolean;
  27669. /**
  27670. * Gets the current state of the task
  27671. */
  27672. readonly taskState: AssetTaskState;
  27673. /**
  27674. * Gets the current error object (if task is in error)
  27675. */
  27676. readonly errorObject: {
  27677. message?: string;
  27678. exception?: any;
  27679. };
  27680. /**
  27681. * Internal only
  27682. * @hidden
  27683. */
  27684. _setErrorObject(message?: string, exception?: any): void;
  27685. /**
  27686. * Execute the current task
  27687. * @param scene defines the scene where you want your assets to be loaded
  27688. * @param onSuccess is a callback called when the task is successfully executed
  27689. * @param onError is a callback called if an error occurs
  27690. */
  27691. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27692. /**
  27693. * Execute the current task
  27694. * @param scene defines the scene where you want your assets to be loaded
  27695. * @param onSuccess is a callback called when the task is successfully executed
  27696. * @param onError is a callback called if an error occurs
  27697. */
  27698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27699. /**
  27700. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  27701. * This can be used with failed tasks that have the reason for failure fixed.
  27702. */
  27703. reset(): void;
  27704. private onErrorCallback(onError, message?, exception?);
  27705. private onDoneCallback(onSuccess, onError);
  27706. }
  27707. /**
  27708. * Define the interface used by progress events raised during assets loading
  27709. */
  27710. interface IAssetsProgressEvent {
  27711. /**
  27712. * Defines the number of remaining tasks to process
  27713. */
  27714. remainingCount: number;
  27715. /**
  27716. * Defines the total number of tasks
  27717. */
  27718. totalCount: number;
  27719. /**
  27720. * Defines the task that was just processed
  27721. */
  27722. task: AbstractAssetTask;
  27723. }
  27724. /**
  27725. * Class used to share progress information about assets loading
  27726. */
  27727. class AssetsProgressEvent implements IAssetsProgressEvent {
  27728. /**
  27729. * Defines the number of remaining tasks to process
  27730. */
  27731. remainingCount: number;
  27732. /**
  27733. * Defines the total number of tasks
  27734. */
  27735. totalCount: number;
  27736. /**
  27737. * Defines the task that was just processed
  27738. */
  27739. task: AbstractAssetTask;
  27740. /**
  27741. * Creates a {BABYLON.AssetsProgressEvent}
  27742. * @param remainingCount defines the number of remaining tasks to process
  27743. * @param totalCount defines the total number of tasks
  27744. * @param task defines the task that was just processed
  27745. */
  27746. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27747. }
  27748. /**
  27749. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27750. */
  27751. class MeshAssetTask extends AbstractAssetTask {
  27752. /**
  27753. * Defines the name of the task
  27754. */
  27755. name: string;
  27756. /**
  27757. * Defines the list of mesh's names you want to load
  27758. */
  27759. meshesNames: any;
  27760. /**
  27761. * Defines the root url to use as a base to load your meshes and associated resources
  27762. */
  27763. rootUrl: string;
  27764. /**
  27765. * Defines the filename of the scene to load from
  27766. */
  27767. sceneFilename: string;
  27768. /**
  27769. * Gets the list of loaded meshes
  27770. */
  27771. loadedMeshes: Array<AbstractMesh>;
  27772. /**
  27773. * Gets the list of loaded particle systems
  27774. */
  27775. loadedParticleSystems: Array<ParticleSystem>;
  27776. /**
  27777. * Gets the list of loaded skeletons
  27778. */
  27779. loadedSkeletons: Array<Skeleton>;
  27780. /**
  27781. * Callback called when the task is successful
  27782. */
  27783. onSuccess: (task: MeshAssetTask) => void;
  27784. /**
  27785. * Callback called when the task is successful
  27786. */
  27787. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27788. /**
  27789. * Creates a new {BABYLON.MeshAssetTask}
  27790. * @param name defines the name of the task
  27791. * @param meshesNames defines the list of mesh's names you want to load
  27792. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27793. * @param sceneFilename defines the filename of the scene to load from
  27794. */
  27795. constructor(
  27796. /**
  27797. * Defines the name of the task
  27798. */
  27799. name: string,
  27800. /**
  27801. * Defines the list of mesh's names you want to load
  27802. */
  27803. meshesNames: any,
  27804. /**
  27805. * Defines the root url to use as a base to load your meshes and associated resources
  27806. */
  27807. rootUrl: string,
  27808. /**
  27809. * Defines the filename of the scene to load from
  27810. */
  27811. sceneFilename: string);
  27812. /**
  27813. * Execute the current task
  27814. * @param scene defines the scene where you want your assets to be loaded
  27815. * @param onSuccess is a callback called when the task is successfully executed
  27816. * @param onError is a callback called if an error occurs
  27817. */
  27818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27819. }
  27820. /**
  27821. * Define a task used by {BABYLON.AssetsManager} to load text content
  27822. */
  27823. class TextFileAssetTask extends AbstractAssetTask {
  27824. /**
  27825. * Defines the name of the task
  27826. */
  27827. name: string;
  27828. /**
  27829. * Defines the location of the file to load
  27830. */
  27831. url: string;
  27832. /**
  27833. * Gets the loaded text string
  27834. */
  27835. text: string;
  27836. /**
  27837. * Callback called when the task is successful
  27838. */
  27839. onSuccess: (task: TextFileAssetTask) => void;
  27840. /**
  27841. * Callback called when the task is successful
  27842. */
  27843. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27844. /**
  27845. * Creates a new TextFileAssetTask object
  27846. * @param name defines the name of the task
  27847. * @param url defines the location of the file to load
  27848. */
  27849. constructor(
  27850. /**
  27851. * Defines the name of the task
  27852. */
  27853. name: string,
  27854. /**
  27855. * Defines the location of the file to load
  27856. */
  27857. url: string);
  27858. /**
  27859. * Execute the current task
  27860. * @param scene defines the scene where you want your assets to be loaded
  27861. * @param onSuccess is a callback called when the task is successfully executed
  27862. * @param onError is a callback called if an error occurs
  27863. */
  27864. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27865. }
  27866. /**
  27867. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27868. */
  27869. class BinaryFileAssetTask extends AbstractAssetTask {
  27870. /**
  27871. * Defines the name of the task
  27872. */
  27873. name: string;
  27874. /**
  27875. * Defines the location of the file to load
  27876. */
  27877. url: string;
  27878. /**
  27879. * Gets the lodaded data (as an array buffer)
  27880. */
  27881. data: ArrayBuffer;
  27882. /**
  27883. * Callback called when the task is successful
  27884. */
  27885. onSuccess: (task: BinaryFileAssetTask) => void;
  27886. /**
  27887. * Callback called when the task is successful
  27888. */
  27889. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27890. /**
  27891. * Creates a new BinaryFileAssetTask object
  27892. * @param name defines the name of the new task
  27893. * @param url defines the location of the file to load
  27894. */
  27895. constructor(
  27896. /**
  27897. * Defines the name of the task
  27898. */
  27899. name: string,
  27900. /**
  27901. * Defines the location of the file to load
  27902. */
  27903. url: string);
  27904. /**
  27905. * Execute the current task
  27906. * @param scene defines the scene where you want your assets to be loaded
  27907. * @param onSuccess is a callback called when the task is successfully executed
  27908. * @param onError is a callback called if an error occurs
  27909. */
  27910. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27911. }
  27912. /**
  27913. * Define a task used by {BABYLON.AssetsManager} to load images
  27914. */
  27915. class ImageAssetTask extends AbstractAssetTask {
  27916. /**
  27917. * Defines the name of the task
  27918. */
  27919. name: string;
  27920. /**
  27921. * Defines the location of the image to load
  27922. */
  27923. url: string;
  27924. /**
  27925. * Gets the loaded images
  27926. */
  27927. image: HTMLImageElement;
  27928. /**
  27929. * Callback called when the task is successful
  27930. */
  27931. onSuccess: (task: ImageAssetTask) => void;
  27932. /**
  27933. * Callback called when the task is successful
  27934. */
  27935. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27936. /**
  27937. * Creates a new ImageAssetTask
  27938. * @param name defines the name of the task
  27939. * @param url defines the location of the image to load
  27940. */
  27941. constructor(
  27942. /**
  27943. * Defines the name of the task
  27944. */
  27945. name: string,
  27946. /**
  27947. * Defines the location of the image to load
  27948. */
  27949. url: string);
  27950. /**
  27951. * Execute the current task
  27952. * @param scene defines the scene where you want your assets to be loaded
  27953. * @param onSuccess is a callback called when the task is successfully executed
  27954. * @param onError is a callback called if an error occurs
  27955. */
  27956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27957. }
  27958. /**
  27959. * Defines the interface used by texture loading tasks
  27960. */
  27961. interface ITextureAssetTask<TEX extends BaseTexture> {
  27962. /**
  27963. * Gets the loaded texture
  27964. */
  27965. texture: TEX;
  27966. }
  27967. /**
  27968. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27969. */
  27970. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27971. /**
  27972. * Defines the name of the task
  27973. */
  27974. name: string;
  27975. /**
  27976. * Defines the location of the file to load
  27977. */
  27978. url: string;
  27979. /**
  27980. * Defines if mipmap should not be generated (default is false)
  27981. */
  27982. noMipmap: boolean | undefined;
  27983. /**
  27984. * Defines if texture must be inverted on Y axis (default is false)
  27985. */
  27986. invertY: boolean | undefined;
  27987. /**
  27988. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27989. */
  27990. samplingMode: number;
  27991. /**
  27992. * Gets the loaded texture
  27993. */
  27994. texture: Texture;
  27995. /**
  27996. * Callback called when the task is successful
  27997. */
  27998. onSuccess: (task: TextureAssetTask) => void;
  27999. /**
  28000. * Callback called when the task is successful
  28001. */
  28002. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  28003. /**
  28004. * Creates a new TextureAssetTask object
  28005. * @param name defines the name of the task
  28006. * @param url defines the location of the file to load
  28007. * @param noMipmap defines if mipmap should not be generated (default is false)
  28008. * @param invertY defines if texture must be inverted on Y axis (default is false)
  28009. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28010. */
  28011. constructor(
  28012. /**
  28013. * Defines the name of the task
  28014. */
  28015. name: string,
  28016. /**
  28017. * Defines the location of the file to load
  28018. */
  28019. url: string,
  28020. /**
  28021. * Defines if mipmap should not be generated (default is false)
  28022. */
  28023. noMipmap?: boolean | undefined,
  28024. /**
  28025. * Defines if texture must be inverted on Y axis (default is false)
  28026. */
  28027. invertY?: boolean | undefined,
  28028. /**
  28029. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28030. */
  28031. samplingMode?: number);
  28032. /**
  28033. * Execute the current task
  28034. * @param scene defines the scene where you want your assets to be loaded
  28035. * @param onSuccess is a callback called when the task is successfully executed
  28036. * @param onError is a callback called if an error occurs
  28037. */
  28038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28039. }
  28040. /**
  28041. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  28042. */
  28043. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  28044. /**
  28045. * Defines the name of the task
  28046. */
  28047. name: string;
  28048. /**
  28049. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28050. */
  28051. url: string;
  28052. /**
  28053. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28054. */
  28055. extensions: string[] | undefined;
  28056. /**
  28057. * Defines if mipmaps should not be generated (default is false)
  28058. */
  28059. noMipmap: boolean | undefined;
  28060. /**
  28061. * Defines the explicit list of files (undefined by default)
  28062. */
  28063. files: string[] | undefined;
  28064. /**
  28065. * Gets the loaded texture
  28066. */
  28067. texture: CubeTexture;
  28068. /**
  28069. * Callback called when the task is successful
  28070. */
  28071. onSuccess: (task: CubeTextureAssetTask) => void;
  28072. /**
  28073. * Callback called when the task is successful
  28074. */
  28075. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  28076. /**
  28077. * Creates a new CubeTextureAssetTask
  28078. * @param name defines the name of the task
  28079. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28080. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28081. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28082. * @param files defines the explicit list of files (undefined by default)
  28083. */
  28084. constructor(
  28085. /**
  28086. * Defines the name of the task
  28087. */
  28088. name: string,
  28089. /**
  28090. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28091. */
  28092. url: string,
  28093. /**
  28094. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28095. */
  28096. extensions?: string[] | undefined,
  28097. /**
  28098. * Defines if mipmaps should not be generated (default is false)
  28099. */
  28100. noMipmap?: boolean | undefined,
  28101. /**
  28102. * Defines the explicit list of files (undefined by default)
  28103. */
  28104. files?: string[] | undefined);
  28105. /**
  28106. * Execute the current task
  28107. * @param scene defines the scene where you want your assets to be loaded
  28108. * @param onSuccess is a callback called when the task is successfully executed
  28109. * @param onError is a callback called if an error occurs
  28110. */
  28111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28112. }
  28113. /**
  28114. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  28115. */
  28116. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  28117. /**
  28118. * Defines the name of the task
  28119. */
  28120. name: string;
  28121. /**
  28122. * Defines the location of the file to load
  28123. */
  28124. url: string;
  28125. /**
  28126. * Defines the desired size (the more it increases the longer the generation will be)
  28127. */
  28128. size: number;
  28129. /**
  28130. * Defines if mipmaps should not be generated (default is false)
  28131. */
  28132. noMipmap: boolean;
  28133. /**
  28134. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28135. */
  28136. generateHarmonics: boolean;
  28137. /**
  28138. * 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)
  28139. */
  28140. gammaSpace: boolean;
  28141. /**
  28142. * Internal Use Only
  28143. */
  28144. reserved: boolean;
  28145. /**
  28146. * Gets the loaded texture
  28147. */
  28148. texture: HDRCubeTexture;
  28149. /**
  28150. * Callback called when the task is successful
  28151. */
  28152. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  28153. /**
  28154. * Callback called when the task is successful
  28155. */
  28156. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  28157. /**
  28158. * Creates a new HDRCubeTextureAssetTask object
  28159. * @param name defines the name of the task
  28160. * @param url defines the location of the file to load
  28161. * @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.
  28162. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28163. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28164. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  28165. * @param reserved Internal use only
  28166. */
  28167. constructor(
  28168. /**
  28169. * Defines the name of the task
  28170. */
  28171. name: string,
  28172. /**
  28173. * Defines the location of the file to load
  28174. */
  28175. url: string,
  28176. /**
  28177. * Defines the desired size (the more it increases the longer the generation will be)
  28178. */
  28179. size: number,
  28180. /**
  28181. * Defines if mipmaps should not be generated (default is false)
  28182. */
  28183. noMipmap?: boolean,
  28184. /**
  28185. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28186. */
  28187. generateHarmonics?: boolean,
  28188. /**
  28189. * 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)
  28190. */
  28191. gammaSpace?: boolean,
  28192. /**
  28193. * Internal Use Only
  28194. */
  28195. reserved?: boolean);
  28196. /**
  28197. * Execute the current task
  28198. * @param scene defines the scene where you want your assets to be loaded
  28199. * @param onSuccess is a callback called when the task is successfully executed
  28200. * @param onError is a callback called if an error occurs
  28201. */
  28202. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28203. }
  28204. /**
  28205. * This class can be used to easily import assets into a scene
  28206. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  28207. */
  28208. class AssetsManager {
  28209. private _scene;
  28210. private _isLoading;
  28211. protected _tasks: AbstractAssetTask[];
  28212. protected _waitingTasksCount: number;
  28213. protected _totalTasksCount: number;
  28214. /**
  28215. * Callback called when all tasks are processed
  28216. */
  28217. onFinish: (tasks: AbstractAssetTask[]) => void;
  28218. /**
  28219. * Callback called when a task is successful
  28220. */
  28221. onTaskSuccess: (task: AbstractAssetTask) => void;
  28222. /**
  28223. * Callback called when a task had an error
  28224. */
  28225. onTaskError: (task: AbstractAssetTask) => void;
  28226. /**
  28227. * Callback called when a task is done (whatever the result is)
  28228. */
  28229. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  28230. /**
  28231. * Observable called when all tasks are processed
  28232. */
  28233. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  28234. /**
  28235. * Observable called when a task had an error
  28236. */
  28237. onTaskErrorObservable: Observable<AbstractAssetTask>;
  28238. /**
  28239. * Observable called when a task is successful
  28240. */
  28241. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  28242. /**
  28243. * Observable called when a task is done (whatever the result is)
  28244. */
  28245. onProgressObservable: Observable<IAssetsProgressEvent>;
  28246. /**
  28247. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  28248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28249. */
  28250. useDefaultLoadingScreen: boolean;
  28251. /**
  28252. * Creates a new AssetsManager
  28253. * @param scene defines the scene to work on
  28254. */
  28255. constructor(scene: Scene);
  28256. /**
  28257. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  28258. * @param taskName defines the name of the new task
  28259. * @param meshesNames defines the name of meshes to load
  28260. * @param rootUrl defines the root url to use to locate files
  28261. * @param sceneFilename defines the filename of the scene file
  28262. * @returns a new {BABYLON.MeshAssetTask} object
  28263. */
  28264. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  28265. /**
  28266. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  28267. * @param taskName defines the name of the new task
  28268. * @param url defines the url of the file to load
  28269. * @returns a new {BABYLON.TextFileAssetTask} object
  28270. */
  28271. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  28272. /**
  28273. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  28274. * @param taskName defines the name of the new task
  28275. * @param url defines the url of the file to load
  28276. * @returns a new {BABYLON.BinaryFileAssetTask} object
  28277. */
  28278. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  28279. /**
  28280. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  28281. * @param taskName defines the name of the new task
  28282. * @param url defines the url of the file to load
  28283. * @returns a new {BABYLON.ImageAssetTask} object
  28284. */
  28285. addImageTask(taskName: string, url: string): ImageAssetTask;
  28286. /**
  28287. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  28288. * @param taskName defines the name of the new task
  28289. * @param url defines the url of the file to load
  28290. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28291. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  28292. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  28293. * @returns a new {BABYLON.TextureAssetTask} object
  28294. */
  28295. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  28296. /**
  28297. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  28298. * @param taskName defines the name of the new task
  28299. * @param url defines the url of the file to load
  28300. * @param extensions defines the extension to use to load the cube map (can be null)
  28301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28302. * @param files defines the list of files to load (can be null)
  28303. * @returns a new {BABYLON.CubeTextureAssetTask} object
  28304. */
  28305. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  28306. /**
  28307. *
  28308. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  28309. * @param taskName defines the name of the new task
  28310. * @param url defines the url of the file to load
  28311. * @param size defines the size you want for the cubemap (can be null)
  28312. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28313. * @param generateHarmonics defines if you want to automatically generate (true by default)
  28314. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  28315. * @param reserved Internal use only
  28316. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  28317. */
  28318. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  28319. /**
  28320. * Remove a task from the assets manager.
  28321. * @param task the task to remove
  28322. */
  28323. removeTask(task: AbstractAssetTask): void;
  28324. private _decreaseWaitingTasksCount(task);
  28325. private _runTask(task);
  28326. /**
  28327. * Reset the {BABYLON.AssetsManager} and remove all tasks
  28328. * @return the current instance of the {BABYLON.AssetsManager}
  28329. */
  28330. reset(): AssetsManager;
  28331. /**
  28332. * Start the loading process
  28333. * @return the current instance of the {BABYLON.AssetsManager}
  28334. */
  28335. load(): AssetsManager;
  28336. }
  28337. }
  28338. declare module BABYLON {
  28339. /**
  28340. * Class used to enable access to IndexedDB
  28341. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  28342. */
  28343. class Database {
  28344. private callbackManifestChecked;
  28345. private currentSceneUrl;
  28346. private db;
  28347. private _enableSceneOffline;
  28348. private _enableTexturesOffline;
  28349. private manifestVersionFound;
  28350. private mustUpdateRessources;
  28351. private hasReachedQuota;
  28352. private isSupported;
  28353. private idbFactory;
  28354. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  28355. static IsUASupportingBlobStorage: boolean;
  28356. /** Gets a boolean indicating if Database storate is enabled */
  28357. static IDBStorageEnabled: boolean;
  28358. /**
  28359. * Gets a boolean indicating if scene must be saved in the database
  28360. */
  28361. readonly enableSceneOffline: boolean;
  28362. /**
  28363. * Gets a boolean indicating if textures must be saved in the database
  28364. */
  28365. readonly enableTexturesOffline: boolean;
  28366. /**
  28367. * Creates a new Database
  28368. * @param urlToScene defines the url to load the scene
  28369. * @param callbackManifestChecked defines the callback to use when manifest is checked
  28370. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  28371. */
  28372. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  28373. private static _ParseURL;
  28374. private static _ReturnFullUrlLocation;
  28375. private _checkManifestFile();
  28376. /**
  28377. * Open the database and make it available
  28378. * @param successCallback defines the callback to call on success
  28379. * @param errorCallback defines the callback to call on error
  28380. */
  28381. openAsync(successCallback: () => void, errorCallback: () => void): void;
  28382. /**
  28383. * Loads an image from the database
  28384. * @param url defines the url to load from
  28385. * @param image defines the target DOM image
  28386. */
  28387. loadImageFromDB(url: string, image: HTMLImageElement): void;
  28388. private _loadImageFromDBAsync(url, image, notInDBCallback);
  28389. private _saveImageIntoDBAsync(url, image);
  28390. private _checkVersionFromDB(url, versionLoaded);
  28391. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  28392. private _saveVersionIntoDBAsync(url, callback);
  28393. /**
  28394. * Loads a file from database
  28395. * @param url defines the URL to load from
  28396. * @param sceneLoaded defines a callback to call on success
  28397. * @param progressCallBack defines a callback to call when progress changed
  28398. * @param errorCallback defines a callback to call on error
  28399. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  28400. */
  28401. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  28402. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  28403. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  28404. }
  28405. }
  28406. declare module BABYLON {
  28407. interface DDSInfo {
  28408. width: number;
  28409. height: number;
  28410. mipmapCount: number;
  28411. isFourCC: boolean;
  28412. isRGB: boolean;
  28413. isLuminance: boolean;
  28414. isCube: boolean;
  28415. isCompressed: boolean;
  28416. dxgiFormat: number;
  28417. textureType: number;
  28418. /** Sphericle polynomial created for the dds texture */
  28419. sphericalPolynomial?: SphericalPolynomial;
  28420. }
  28421. class DDSTools {
  28422. static StoreLODInAlphaChannel: boolean;
  28423. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  28424. private static _FloatView;
  28425. private static _Int32View;
  28426. private static _ToHalfFloat(value);
  28427. private static _FromHalfFloat(value);
  28428. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28429. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28430. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28431. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28432. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28433. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  28434. private static _ExtractLongWordOrder(value);
  28435. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  28436. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  28437. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  28438. }
  28439. }
  28440. declare module BABYLON {
  28441. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28442. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28443. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28444. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28445. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28446. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28447. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28448. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28449. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28450. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28451. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28452. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28453. /**
  28454. * Decorator used to define property that can be serialized as reference to a camera
  28455. * @param sourceName defines the name of the property to decorate
  28456. */
  28457. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28458. class SerializationHelper {
  28459. static Serialize<T>(entity: T, serializationObject?: any): any;
  28460. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28461. static Clone<T>(creationFunction: () => T, source: T): T;
  28462. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28463. }
  28464. }
  28465. declare module BABYLON {
  28466. /**
  28467. * Wrapper class for promise with external resolve and reject.
  28468. */
  28469. class Deferred<T> {
  28470. /**
  28471. * The promise associated with this deferred object.
  28472. */
  28473. readonly promise: Promise<T>;
  28474. private _resolve;
  28475. private _reject;
  28476. /**
  28477. * The resolve method of the promise associated with this deferred object.
  28478. */
  28479. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  28480. /**
  28481. * The reject method of the promise associated with this deferred object.
  28482. */
  28483. readonly reject: (reason?: any) => void;
  28484. /**
  28485. * Constructor for this deferred object.
  28486. */
  28487. constructor();
  28488. }
  28489. }
  28490. declare module BABYLON {
  28491. /**
  28492. * Raw texture data and descriptor sufficient for WebGL texture upload
  28493. */
  28494. interface EnvironmentTextureInfo {
  28495. /**
  28496. * Version of the environment map
  28497. */
  28498. version: number;
  28499. /**
  28500. * Width of image
  28501. */
  28502. width: number;
  28503. /**
  28504. * Irradiance information stored in the file.
  28505. */
  28506. irradiance: any;
  28507. /**
  28508. * Specular information stored in the file.
  28509. */
  28510. specular: any;
  28511. }
  28512. /**
  28513. * Sets of helpers addressing the serialization and deserialization of environment texture
  28514. * stored in a BabylonJS env file.
  28515. * Those files are usually stored as .env files.
  28516. */
  28517. class EnvironmentTextureTools {
  28518. /**
  28519. * Magic number identifying the env file.
  28520. */
  28521. private static _MagicBytes;
  28522. /**
  28523. * Gets the environment info from an env file.
  28524. * @param data The array buffer containing the .env bytes.
  28525. * @returns the environment file info (the json header) if successfully parsed.
  28526. */
  28527. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  28528. /**
  28529. * Creates an environment texture from a loaded cube texture.
  28530. * @param texture defines the cube texture to convert in env file
  28531. * @return a promise containing the environment data if succesfull.
  28532. */
  28533. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  28534. /**
  28535. * Creates a JSON representation of the spherical data.
  28536. * @param texture defines the texture containing the polynomials
  28537. * @return the JSON representation of the spherical info
  28538. */
  28539. private static _CreateEnvTextureIrradiance(texture);
  28540. /**
  28541. * Uploads the texture info contained in the env file to te GPU.
  28542. * @param texture defines the internal texture to upload to
  28543. * @param arrayBuffer defines the buffer cotaining the data to load
  28544. * @param info defines the texture info retrieved through the GetEnvInfo method
  28545. * @returns a promise
  28546. */
  28547. static UploadLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  28548. /**
  28549. * Uploads spherical polynomials information to the texture.
  28550. * @param texture defines the texture we are trying to upload the information to
  28551. * @param arrayBuffer defines the array buffer holding the data
  28552. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  28553. */
  28554. static UploadPolynomials(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): void;
  28555. /**
  28556. * Upload spherical polynomial coefficients to the texture
  28557. * @param polynmials Spherical polynmial coefficients (9)
  28558. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28559. */
  28560. private static _UploadSP(polynmials, outPolynomialCoefficents);
  28561. /**
  28562. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  28563. * L = (1/pi) * E * rho
  28564. *
  28565. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  28566. * @param harmonics Spherical harmonic coefficients (9)
  28567. */
  28568. private static _ConvertSHIrradianceToLambertianRadiance(harmonics);
  28569. /**
  28570. * Convert spherical harmonics to spherical polynomial coefficients
  28571. * @param harmonics Spherical harmonic coefficients (9)
  28572. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28573. */
  28574. private static _ConvertSHToSP(harmonics, outPolynomialCoefficents);
  28575. }
  28576. }
  28577. declare module BABYLON {
  28578. class FilesInput {
  28579. static FilesToLoad: {
  28580. [key: string]: File;
  28581. };
  28582. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  28583. private _engine;
  28584. private _currentScene;
  28585. private _sceneLoadedCallback;
  28586. private _progressCallback;
  28587. private _additionalRenderLoopLogicCallback;
  28588. private _textureLoadingCallback;
  28589. private _startingProcessingFilesCallback;
  28590. private _onReloadCallback;
  28591. private _errorCallback;
  28592. private _elementToMonitor;
  28593. private _sceneFileToLoad;
  28594. private _filesToLoad;
  28595. 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);
  28596. private _dragEnterHandler;
  28597. private _dragOverHandler;
  28598. private _dropHandler;
  28599. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  28600. dispose(): void;
  28601. private renderFunction();
  28602. private drag(e);
  28603. private drop(eventDrop);
  28604. private _traverseFolder(folder, files, remaining, callback);
  28605. private _processFiles(files);
  28606. loadFiles(event: any): void;
  28607. private _processReload();
  28608. reload(): void;
  28609. }
  28610. }
  28611. declare module BABYLON {
  28612. /**
  28613. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28614. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28615. */
  28616. class KhronosTextureContainer {
  28617. arrayBuffer: any;
  28618. static HEADER_LEN: number;
  28619. static COMPRESSED_2D: number;
  28620. static COMPRESSED_3D: number;
  28621. static TEX_2D: number;
  28622. static TEX_3D: number;
  28623. glType: number;
  28624. glTypeSize: number;
  28625. glFormat: number;
  28626. glInternalFormat: number;
  28627. glBaseInternalFormat: number;
  28628. pixelWidth: number;
  28629. pixelHeight: number;
  28630. pixelDepth: number;
  28631. numberOfArrayElements: number;
  28632. numberOfFaces: number;
  28633. numberOfMipmapLevels: number;
  28634. bytesOfKeyValueData: number;
  28635. loadType: number;
  28636. /**
  28637. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  28638. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  28639. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  28640. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  28641. */
  28642. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  28643. switchEndainness(val: number): number;
  28644. /**
  28645. * It is assumed that the texture has already been created & is currently bound
  28646. */
  28647. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  28648. private _upload2DCompressedLevels(gl, loadMipmaps);
  28649. }
  28650. }
  28651. declare module BABYLON {
  28652. /**
  28653. * A class serves as a medium between the observable and its observers
  28654. */
  28655. class EventState {
  28656. /**
  28657. * Create a new EventState
  28658. * @param mask defines the mask associated with this state
  28659. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28660. * @param target defines the original target of the state
  28661. * @param currentTarget defines the current target of the state
  28662. */
  28663. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  28664. /**
  28665. * Initialize the current event state
  28666. * @param mask defines the mask associated with this state
  28667. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28668. * @param target defines the original target of the state
  28669. * @param currentTarget defines the current target of the state
  28670. * @returns the current event state
  28671. */
  28672. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  28673. /**
  28674. * An Observer can set this property to true to prevent subsequent observers of being notified
  28675. */
  28676. skipNextObservers: boolean;
  28677. /**
  28678. * Get the mask value that were used to trigger the event corresponding to this EventState object
  28679. */
  28680. mask: number;
  28681. /**
  28682. * The object that originally notified the event
  28683. */
  28684. target?: any;
  28685. /**
  28686. * The current object in the bubbling phase
  28687. */
  28688. currentTarget?: any;
  28689. /**
  28690. * This will be populated with the return value of the last function that was executed.
  28691. * If it is the first function in the callback chain it will be the event data.
  28692. */
  28693. lastReturnValue?: any;
  28694. }
  28695. /**
  28696. * Represent an Observer registered to a given Observable object.
  28697. */
  28698. class Observer<T> {
  28699. /**
  28700. * Defines the callback to call when the observer is notified
  28701. */
  28702. callback: (eventData: T, eventState: EventState) => void;
  28703. /**
  28704. * Defines the mask of the observer (used to filter notifications)
  28705. */
  28706. mask: number;
  28707. /**
  28708. * Defines the current scope used to restore the JS context
  28709. */
  28710. scope: any;
  28711. /** @hidden */
  28712. _willBeUnregistered: boolean;
  28713. /**
  28714. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28715. */
  28716. unregisterOnNextCall: boolean;
  28717. /**
  28718. * Creates a new observer
  28719. * @param callback defines the callback to call when the observer is notified
  28720. * @param mask defines the mask of the observer (used to filter notifications)
  28721. * @param scope defines the current scope used to restore the JS context
  28722. */
  28723. constructor(
  28724. /**
  28725. * Defines the callback to call when the observer is notified
  28726. */
  28727. callback: (eventData: T, eventState: EventState) => void,
  28728. /**
  28729. * Defines the mask of the observer (used to filter notifications)
  28730. */
  28731. mask: number,
  28732. /**
  28733. * Defines the current scope used to restore the JS context
  28734. */
  28735. scope?: any);
  28736. }
  28737. /**
  28738. * Represent a list of observers registered to multiple Observables object.
  28739. */
  28740. class MultiObserver<T> {
  28741. private _observers;
  28742. private _observables;
  28743. /**
  28744. * Release associated resources
  28745. */
  28746. dispose(): void;
  28747. /**
  28748. * Raise a callback when one of the observable will notify
  28749. * @param observables defines a list of observables to watch
  28750. * @param callback defines the callback to call on notification
  28751. * @param mask defines the mask used to filter notifications
  28752. * @param scope defines the current scope used to restore the JS context
  28753. * @returns the new MultiObserver
  28754. */
  28755. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  28756. }
  28757. /**
  28758. * The Observable class is a simple implementation of the Observable pattern.
  28759. *
  28760. * 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.
  28761. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  28762. * 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).
  28763. * 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.
  28764. */
  28765. class Observable<T> {
  28766. private _observers;
  28767. private _eventState;
  28768. private _onObserverAdded;
  28769. /**
  28770. * Creates a new observable
  28771. * @param onObserverAdded defines a callback to call when a new observer is added
  28772. */
  28773. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  28774. /**
  28775. * Create a new Observer with the specified callback
  28776. * @param callback the callback that will be executed for that Observer
  28777. * @param mask the mask used to filter observers
  28778. * @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.
  28779. * @param scope optional scope for the callback to be called from
  28780. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  28781. * @returns the new observer created for the callback
  28782. */
  28783. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  28784. /**
  28785. * Create a new Observer with the specified callback and unregisters after the next notification
  28786. * @param callback the callback that will be executed for that Observer
  28787. * @returns the new observer created for the callback
  28788. */
  28789. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28790. /**
  28791. * Remove an Observer from the Observable object
  28792. * @param observer the instance of the Observer to remove
  28793. * @returns false if it doesn't belong to this Observable
  28794. */
  28795. remove(observer: Nullable<Observer<T>>): boolean;
  28796. /**
  28797. * Remove a callback from the Observable object
  28798. * @param callback the callback to remove
  28799. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28800. * @returns false if it doesn't belong to this Observable
  28801. */
  28802. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28803. private _deferUnregister(observer);
  28804. /**
  28805. * Notify all Observers by calling their respective callback with the given data
  28806. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28807. * @param eventData defines the data to send to all observers
  28808. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28809. * @param target defines the original target of the state
  28810. * @param currentTarget defines the current target of the state
  28811. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28812. */
  28813. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28814. /**
  28815. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28816. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28817. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28818. * and it is crucial that all callbacks will be executed.
  28819. * The order of the callbacks is kept, callbacks are not executed parallel.
  28820. *
  28821. * @param eventData The data to be sent to each callback
  28822. * @param mask is used to filter observers defaults to -1
  28823. * @param target defines the callback target (see EventState)
  28824. * @param currentTarget defines he current object in the bubbling phase
  28825. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28826. */
  28827. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28828. /**
  28829. * Notify a specific observer
  28830. * @param observer defines the observer to notify
  28831. * @param eventData defines the data to be sent to each callback
  28832. * @param mask is used to filter observers defaults to -1
  28833. */
  28834. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28835. /**
  28836. * Gets a boolean indicating if the observable has at least one observer
  28837. * @returns true is the Observable has at least one Observer registered
  28838. */
  28839. hasObservers(): boolean;
  28840. /**
  28841. * Clear the list of observers
  28842. */
  28843. clear(): void;
  28844. /**
  28845. * Clone the current observable
  28846. * @returns a new observable
  28847. */
  28848. clone(): Observable<T>;
  28849. /**
  28850. * Does this observable handles observer registered with a given mask
  28851. * @param mask defines the mask to be tested
  28852. * @return whether or not one observer registered with the given mask is handeled
  28853. **/
  28854. hasSpecificMask(mask?: number): boolean;
  28855. }
  28856. }
  28857. declare module BABYLON {
  28858. /**
  28859. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28860. */
  28861. class PerformanceMonitor {
  28862. private _enabled;
  28863. private _rollingFrameTime;
  28864. private _lastFrameTimeMs;
  28865. /**
  28866. * constructor
  28867. * @param frameSampleSize The number of samples required to saturate the sliding window
  28868. */
  28869. constructor(frameSampleSize?: number);
  28870. /**
  28871. * Samples current frame
  28872. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28873. */
  28874. sampleFrame(timeMs?: number): void;
  28875. /**
  28876. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28877. * @return Average frame time in milliseconds
  28878. */
  28879. readonly averageFrameTime: number;
  28880. /**
  28881. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28882. * @return Frame time variance in milliseconds squared
  28883. */
  28884. readonly averageFrameTimeVariance: number;
  28885. /**
  28886. * Returns the frame time of the most recent frame
  28887. * @return Frame time in milliseconds
  28888. */
  28889. readonly instantaneousFrameTime: number;
  28890. /**
  28891. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28892. * @return Framerate in frames per second
  28893. */
  28894. readonly averageFPS: number;
  28895. /**
  28896. * Returns the average framerate in frames per second using the most recent frame time
  28897. * @return Framerate in frames per second
  28898. */
  28899. readonly instantaneousFPS: number;
  28900. /**
  28901. * Returns true if enough samples have been taken to completely fill the sliding window
  28902. * @return true if saturated
  28903. */
  28904. readonly isSaturated: boolean;
  28905. /**
  28906. * Enables contributions to the sliding window sample set
  28907. */
  28908. enable(): void;
  28909. /**
  28910. * Disables contributions to the sliding window sample set
  28911. * Samples will not be interpolated over the disabled period
  28912. */
  28913. disable(): void;
  28914. /**
  28915. * Returns true if sampling is enabled
  28916. * @return true if enabled
  28917. */
  28918. readonly isEnabled: boolean;
  28919. /**
  28920. * Resets performance monitor
  28921. */
  28922. reset(): void;
  28923. }
  28924. /**
  28925. * RollingAverage
  28926. *
  28927. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28928. */
  28929. class RollingAverage {
  28930. /**
  28931. * Current average
  28932. */
  28933. average: number;
  28934. /**
  28935. * Current variance
  28936. */
  28937. variance: number;
  28938. protected _samples: Array<number>;
  28939. protected _sampleCount: number;
  28940. protected _pos: number;
  28941. protected _m2: number;
  28942. /**
  28943. * constructor
  28944. * @param length The number of samples required to saturate the sliding window
  28945. */
  28946. constructor(length: number);
  28947. /**
  28948. * Adds a sample to the sample set
  28949. * @param v The sample value
  28950. */
  28951. add(v: number): void;
  28952. /**
  28953. * Returns previously added values or null if outside of history or outside the sliding window domain
  28954. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28955. * @return Value previously recorded with add() or null if outside of range
  28956. */
  28957. history(i: number): number;
  28958. /**
  28959. * Returns true if enough samples have been taken to completely fill the sliding window
  28960. * @return true if sample-set saturated
  28961. */
  28962. isSaturated(): boolean;
  28963. /**
  28964. * Resets the rolling average (equivalent to 0 samples taken so far)
  28965. */
  28966. reset(): void;
  28967. /**
  28968. * Wraps a value around the sample range boundaries
  28969. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28970. * @return Wrapped position in sample range
  28971. */
  28972. protected _wrapPosition(i: number): number;
  28973. }
  28974. }
  28975. declare module BABYLON {
  28976. /**
  28977. * Helper class that provides a small promise polyfill
  28978. */
  28979. class PromisePolyfill {
  28980. /**
  28981. * Static function used to check if the polyfill is required
  28982. * If this is the case then the function will inject the polyfill to window.Promise
  28983. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28984. */
  28985. static Apply(force?: boolean): void;
  28986. }
  28987. }
  28988. declare module BABYLON {
  28989. /**
  28990. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28992. */
  28993. class SceneOptimization {
  28994. /**
  28995. * Defines the priority of this optimization (0 by default which means first in the list)
  28996. */
  28997. priority: number;
  28998. /**
  28999. * Gets a string describing the action executed by the current optimization
  29000. * @returns description string
  29001. */
  29002. getDescription(): string;
  29003. /**
  29004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29005. * @param scene defines the current scene where to apply this optimization
  29006. * @param optimizer defines the current optimizer
  29007. * @returns true if everything that can be done was applied
  29008. */
  29009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29010. /**
  29011. * Creates the SceneOptimization object
  29012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29013. * @param desc defines the description associated with the optimization
  29014. */
  29015. constructor(
  29016. /**
  29017. * Defines the priority of this optimization (0 by default which means first in the list)
  29018. */
  29019. priority?: number);
  29020. }
  29021. /**
  29022. * Defines an optimization used to reduce the size of render target textures
  29023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29024. */
  29025. class TextureOptimization extends SceneOptimization {
  29026. /**
  29027. * Defines the priority of this optimization (0 by default which means first in the list)
  29028. */
  29029. priority: number;
  29030. /**
  29031. * 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
  29032. */
  29033. maximumSize: number;
  29034. /**
  29035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29036. */
  29037. step: number;
  29038. /**
  29039. * Gets a string describing the action executed by the current optimization
  29040. * @returns description string
  29041. */
  29042. getDescription(): string;
  29043. /**
  29044. * Creates the TextureOptimization object
  29045. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29046. * @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
  29047. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29048. */
  29049. constructor(
  29050. /**
  29051. * Defines the priority of this optimization (0 by default which means first in the list)
  29052. */
  29053. priority?: number,
  29054. /**
  29055. * 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
  29056. */
  29057. maximumSize?: number,
  29058. /**
  29059. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29060. */
  29061. step?: number);
  29062. /**
  29063. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29064. * @param scene defines the current scene where to apply this optimization
  29065. * @param optimizer defines the current optimizer
  29066. * @returns true if everything that can be done was applied
  29067. */
  29068. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29069. }
  29070. /**
  29071. * Defines an optimization used to increase or decrease the rendering resolution
  29072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29073. */
  29074. class HardwareScalingOptimization extends SceneOptimization {
  29075. /**
  29076. * Defines the priority of this optimization (0 by default which means first in the list)
  29077. */
  29078. priority: number;
  29079. /**
  29080. * Defines the maximum scale to use (2 by default)
  29081. */
  29082. maximumScale: number;
  29083. /**
  29084. * Defines the step to use between two passes (0.5 by default)
  29085. */
  29086. step: number;
  29087. private _currentScale;
  29088. private _directionOffset;
  29089. /**
  29090. * Gets a string describing the action executed by the current optimization
  29091. * @return description string
  29092. */
  29093. getDescription(): string;
  29094. /**
  29095. * Creates the HardwareScalingOptimization object
  29096. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29097. * @param maximumScale defines the maximum scale to use (2 by default)
  29098. * @param step defines the step to use between two passes (0.5 by default)
  29099. */
  29100. constructor(
  29101. /**
  29102. * Defines the priority of this optimization (0 by default which means first in the list)
  29103. */
  29104. priority?: number,
  29105. /**
  29106. * Defines the maximum scale to use (2 by default)
  29107. */
  29108. maximumScale?: number,
  29109. /**
  29110. * Defines the step to use between two passes (0.5 by default)
  29111. */
  29112. step?: number);
  29113. /**
  29114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29115. * @param scene defines the current scene where to apply this optimization
  29116. * @param optimizer defines the current optimizer
  29117. * @returns true if everything that can be done was applied
  29118. */
  29119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29120. }
  29121. /**
  29122. * Defines an optimization used to remove shadows
  29123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29124. */
  29125. class ShadowsOptimization extends SceneOptimization {
  29126. /**
  29127. * Gets a string describing the action executed by the current optimization
  29128. * @return description string
  29129. */
  29130. getDescription(): string;
  29131. /**
  29132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29133. * @param scene defines the current scene where to apply this optimization
  29134. * @param optimizer defines the current optimizer
  29135. * @returns true if everything that can be done was applied
  29136. */
  29137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29138. }
  29139. /**
  29140. * Defines an optimization used to turn post-processes off
  29141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29142. */
  29143. class PostProcessesOptimization extends SceneOptimization {
  29144. /**
  29145. * Gets a string describing the action executed by the current optimization
  29146. * @return description string
  29147. */
  29148. getDescription(): string;
  29149. /**
  29150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29151. * @param scene defines the current scene where to apply this optimization
  29152. * @param optimizer defines the current optimizer
  29153. * @returns true if everything that can be done was applied
  29154. */
  29155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29156. }
  29157. /**
  29158. * Defines an optimization used to turn lens flares off
  29159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29160. */
  29161. class LensFlaresOptimization extends SceneOptimization {
  29162. /**
  29163. * Gets a string describing the action executed by the current optimization
  29164. * @return description string
  29165. */
  29166. getDescription(): string;
  29167. /**
  29168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29169. * @param scene defines the current scene where to apply this optimization
  29170. * @param optimizer defines the current optimizer
  29171. * @returns true if everything that can be done was applied
  29172. */
  29173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29174. }
  29175. /**
  29176. * Defines an optimization based on user defined callback.
  29177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29178. */
  29179. class CustomOptimization extends SceneOptimization {
  29180. /**
  29181. * Callback called to apply the custom optimization.
  29182. */
  29183. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  29184. /**
  29185. * Callback called to get custom description
  29186. */
  29187. onGetDescription: () => string;
  29188. /**
  29189. * Gets a string describing the action executed by the current optimization
  29190. * @returns description string
  29191. */
  29192. getDescription(): string;
  29193. /**
  29194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29195. * @param scene defines the current scene where to apply this optimization
  29196. * @param optimizer defines the current optimizer
  29197. * @returns true if everything that can be done was applied
  29198. */
  29199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29200. }
  29201. /**
  29202. * Defines an optimization used to turn particles off
  29203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29204. */
  29205. class ParticlesOptimization extends SceneOptimization {
  29206. /**
  29207. * Gets a string describing the action executed by the current optimization
  29208. * @return description string
  29209. */
  29210. getDescription(): string;
  29211. /**
  29212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29213. * @param scene defines the current scene where to apply this optimization
  29214. * @param optimizer defines the current optimizer
  29215. * @returns true if everything that can be done was applied
  29216. */
  29217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29218. }
  29219. /**
  29220. * Defines an optimization used to turn render targets off
  29221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29222. */
  29223. class RenderTargetsOptimization extends SceneOptimization {
  29224. /**
  29225. * Gets a string describing the action executed by the current optimization
  29226. * @return description string
  29227. */
  29228. getDescription(): string;
  29229. /**
  29230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29231. * @param scene defines the current scene where to apply this optimization
  29232. * @param optimizer defines the current optimizer
  29233. * @returns true if everything that can be done was applied
  29234. */
  29235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29236. }
  29237. /**
  29238. * Defines an optimization used to merge meshes with compatible materials
  29239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29240. */
  29241. class MergeMeshesOptimization extends SceneOptimization {
  29242. private static _UpdateSelectionTree;
  29243. /**
  29244. * Gets or sets a boolean which defines if optimization octree has to be updated
  29245. */
  29246. /**
  29247. * Gets or sets a boolean which defines if optimization octree has to be updated
  29248. */
  29249. static UpdateSelectionTree: boolean;
  29250. /**
  29251. * Gets a string describing the action executed by the current optimization
  29252. * @return description string
  29253. */
  29254. getDescription(): string;
  29255. private _canBeMerged;
  29256. /**
  29257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29258. * @param scene defines the current scene where to apply this optimization
  29259. * @param optimizer defines the current optimizer
  29260. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  29261. * @returns true if everything that can be done was applied
  29262. */
  29263. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  29264. }
  29265. /**
  29266. * Defines a list of options used by SceneOptimizer
  29267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29268. */
  29269. class SceneOptimizerOptions {
  29270. /**
  29271. * Defines the target frame rate to reach (60 by default)
  29272. */
  29273. targetFrameRate: number;
  29274. /**
  29275. * Defines the interval between two checkes (2000ms by default)
  29276. */
  29277. trackerDuration: number;
  29278. /**
  29279. * Gets the list of optimizations to apply
  29280. */
  29281. optimizations: SceneOptimization[];
  29282. /**
  29283. * Creates a new list of options used by SceneOptimizer
  29284. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  29285. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  29286. */
  29287. constructor(
  29288. /**
  29289. * Defines the target frame rate to reach (60 by default)
  29290. */
  29291. targetFrameRate?: number,
  29292. /**
  29293. * Defines the interval between two checkes (2000ms by default)
  29294. */
  29295. trackerDuration?: number);
  29296. /**
  29297. * Add a new optimization
  29298. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  29299. * @returns the current SceneOptimizerOptions
  29300. */
  29301. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  29302. /**
  29303. * Add a new custom optimization
  29304. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  29305. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  29306. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29307. * @returns the current SceneOptimizerOptions
  29308. */
  29309. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  29310. /**
  29311. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  29312. * @param targetFrameRate defines the target frame rate (60 by default)
  29313. * @returns a SceneOptimizerOptions object
  29314. */
  29315. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29316. /**
  29317. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  29318. * @param targetFrameRate defines the target frame rate (60 by default)
  29319. * @returns a SceneOptimizerOptions object
  29320. */
  29321. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29322. /**
  29323. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  29324. * @param targetFrameRate defines the target frame rate (60 by default)
  29325. * @returns a SceneOptimizerOptions object
  29326. */
  29327. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29328. }
  29329. /**
  29330. * Class used to run optimizations in order to reach a target frame rate
  29331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29332. */
  29333. class SceneOptimizer implements IDisposable {
  29334. private _isRunning;
  29335. private _options;
  29336. private _scene;
  29337. private _currentPriorityLevel;
  29338. private _targetFrameRate;
  29339. private _trackerDuration;
  29340. private _currentFrameRate;
  29341. private _sceneDisposeObserver;
  29342. private _improvementMode;
  29343. /**
  29344. * Defines an observable called when the optimizer reaches the target frame rate
  29345. */
  29346. onSuccessObservable: Observable<SceneOptimizer>;
  29347. /**
  29348. * Defines an observable called when the optimizer enables an optimization
  29349. */
  29350. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  29351. /**
  29352. * Defines an observable called when the optimizer is not able to reach the target frame rate
  29353. */
  29354. onFailureObservable: Observable<SceneOptimizer>;
  29355. /**
  29356. * Gets a boolean indicating if the optimizer is in improvement mode
  29357. */
  29358. readonly isInImprovementMode: boolean;
  29359. /**
  29360. * Gets the current priority level (0 at start)
  29361. */
  29362. readonly currentPriorityLevel: number;
  29363. /**
  29364. * Gets the current frame rate checked by the SceneOptimizer
  29365. */
  29366. readonly currentFrameRate: number;
  29367. /**
  29368. * Gets or sets the current target frame rate (60 by default)
  29369. */
  29370. /**
  29371. * Gets or sets the current target frame rate (60 by default)
  29372. */
  29373. targetFrameRate: number;
  29374. /**
  29375. * Gets or sets the current interval between two checks (every 2000ms by default)
  29376. */
  29377. /**
  29378. * Gets or sets the current interval between two checks (every 2000ms by default)
  29379. */
  29380. trackerDuration: number;
  29381. /**
  29382. * Gets the list of active optimizations
  29383. */
  29384. readonly optimizations: SceneOptimization[];
  29385. /**
  29386. * Creates a new SceneOptimizer
  29387. * @param scene defines the scene to work on
  29388. * @param options defines the options to use with the SceneOptimizer
  29389. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  29390. * @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)
  29391. */
  29392. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  29393. /**
  29394. * Stops the current optimizer
  29395. */
  29396. stop(): void;
  29397. /**
  29398. * Reset the optimizer to initial step (current priority level = 0)
  29399. */
  29400. reset(): void;
  29401. /**
  29402. * Start the optimizer. By default it will try to reach a specific framerate
  29403. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  29404. */
  29405. start(): void;
  29406. private _checkCurrentState();
  29407. /**
  29408. * Release all resources
  29409. */
  29410. dispose(): void;
  29411. /**
  29412. * Helper function to create a SceneOptimizer with one single line of code
  29413. * @param scene defines the scene to work on
  29414. * @param options defines the options to use with the SceneOptimizer
  29415. * @param onSuccess defines a callback to call on success
  29416. * @param onFailure defines a callback to call on failure
  29417. * @returns the new SceneOptimizer object
  29418. */
  29419. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  29420. }
  29421. }
  29422. declare module BABYLON {
  29423. class SceneSerializer {
  29424. static ClearCache(): void;
  29425. static Serialize(scene: Scene): any;
  29426. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  29427. }
  29428. }
  29429. declare module BABYLON {
  29430. class SmartArray<T> {
  29431. data: Array<T>;
  29432. length: number;
  29433. protected _id: number;
  29434. [index: number]: T;
  29435. constructor(capacity: number);
  29436. push(value: T): void;
  29437. forEach(func: (content: T) => void): void;
  29438. sort(compareFn: (a: T, b: T) => number): void;
  29439. reset(): void;
  29440. dispose(): void;
  29441. concat(array: any): void;
  29442. indexOf(value: T): number;
  29443. contains(value: T): boolean;
  29444. private static _GlobalId;
  29445. }
  29446. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  29447. private _duplicateId;
  29448. [index: number]: T;
  29449. push(value: T): void;
  29450. pushNoDuplicate(value: T): boolean;
  29451. reset(): void;
  29452. concatWithNoDuplicate(array: any): void;
  29453. }
  29454. }
  29455. declare module BABYLON {
  29456. /**
  29457. * This class implement a typical dictionary using a string as key and the generic type T as value.
  29458. * The underlying implementation relies on an associative array to ensure the best performances.
  29459. * The value can be anything including 'null' but except 'undefined'
  29460. */
  29461. class StringDictionary<T> {
  29462. /**
  29463. * This will clear this dictionary and copy the content from the 'source' one.
  29464. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  29465. * @param source the dictionary to take the content from and copy to this dictionary
  29466. */
  29467. copyFrom(source: StringDictionary<T>): void;
  29468. /**
  29469. * Get a value based from its key
  29470. * @param key the given key to get the matching value from
  29471. * @return the value if found, otherwise undefined is returned
  29472. */
  29473. get(key: string): T | undefined;
  29474. /**
  29475. * Get a value from its key or add it if it doesn't exist.
  29476. * This method will ensure you that a given key/data will be present in the dictionary.
  29477. * @param key the given key to get the matching value from
  29478. * @param factory the factory that will create the value if the key is not present in the dictionary.
  29479. * The factory will only be invoked if there's no data for the given key.
  29480. * @return the value corresponding to the key.
  29481. */
  29482. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  29483. /**
  29484. * Get a value from its key if present in the dictionary otherwise add it
  29485. * @param key the key to get the value from
  29486. * @param val if there's no such key/value pair in the dictionary add it with this value
  29487. * @return the value corresponding to the key
  29488. */
  29489. getOrAdd(key: string, val: T): T;
  29490. /**
  29491. * Check if there's a given key in the dictionary
  29492. * @param key the key to check for
  29493. * @return true if the key is present, false otherwise
  29494. */
  29495. contains(key: string): boolean;
  29496. /**
  29497. * Add a new key and its corresponding value
  29498. * @param key the key to add
  29499. * @param value the value corresponding to the key
  29500. * @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
  29501. */
  29502. add(key: string, value: T): boolean;
  29503. set(key: string, value: T): boolean;
  29504. /**
  29505. * Get the element of the given key and remove it from the dictionary
  29506. * @param key
  29507. */
  29508. getAndRemove(key: string): Nullable<T>;
  29509. /**
  29510. * Remove a key/value from the dictionary.
  29511. * @param key the key to remove
  29512. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  29513. */
  29514. remove(key: string): boolean;
  29515. /**
  29516. * Clear the whole content of the dictionary
  29517. */
  29518. clear(): void;
  29519. readonly count: number;
  29520. /**
  29521. * Execute a callback on each key/val of the dictionary.
  29522. * Note that you can remove any element in this dictionary in the callback implementation
  29523. * @param callback the callback to execute on a given key/value pair
  29524. */
  29525. forEach(callback: (key: string, val: T) => void): void;
  29526. /**
  29527. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  29528. * If the callback returns null or undefined the method will iterate to the next key/value pair
  29529. * Note that you can remove any element in this dictionary in the callback implementation
  29530. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  29531. */
  29532. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  29533. private _count;
  29534. private _data;
  29535. }
  29536. }
  29537. declare module BABYLON {
  29538. class Tags {
  29539. static EnableFor(obj: any): void;
  29540. static DisableFor(obj: any): void;
  29541. static HasTags(obj: any): boolean;
  29542. static GetTags(obj: any, asString?: boolean): any;
  29543. static AddTagsTo(obj: any, tagsString: string): void;
  29544. static _AddTagTo(obj: any, tag: string): void;
  29545. static RemoveTagsFrom(obj: any, tagsString: string): void;
  29546. static _RemoveTagFrom(obj: any, tag: string): void;
  29547. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  29548. }
  29549. }
  29550. declare module BABYLON {
  29551. class TextureTools {
  29552. /**
  29553. * Uses the GPU to create a copy texture rescaled at a given size
  29554. * @param texture Texture to copy from
  29555. * @param width Desired width
  29556. * @param height Desired height
  29557. * @return Generated texture
  29558. */
  29559. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  29560. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  29561. private static _environmentBRDFBase64Texture;
  29562. }
  29563. }
  29564. declare module BABYLON {
  29565. class TGATools {
  29566. private static _TYPE_INDEXED;
  29567. private static _TYPE_RGB;
  29568. private static _TYPE_GREY;
  29569. private static _TYPE_RLE_INDEXED;
  29570. private static _TYPE_RLE_RGB;
  29571. private static _TYPE_RLE_GREY;
  29572. private static _ORIGIN_MASK;
  29573. private static _ORIGIN_SHIFT;
  29574. private static _ORIGIN_BL;
  29575. private static _ORIGIN_BR;
  29576. private static _ORIGIN_UL;
  29577. private static _ORIGIN_UR;
  29578. static GetTGAHeader(data: Uint8Array): any;
  29579. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  29580. 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;
  29581. 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;
  29582. 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;
  29583. 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;
  29584. 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;
  29585. 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;
  29586. }
  29587. }
  29588. declare module BABYLON {
  29589. interface IAnimatable {
  29590. animations: Array<Animation>;
  29591. }
  29592. /** Interface used by value gradients (color, factor, ...) */
  29593. interface IValueGradient {
  29594. /**
  29595. * Gets or sets the gradient value (between 0 and 1)
  29596. */
  29597. gradient: number;
  29598. }
  29599. /** Class used to store color gradient */
  29600. class ColorGradient implements IValueGradient {
  29601. /**
  29602. * Gets or sets the gradient value (between 0 and 1)
  29603. */
  29604. gradient: number;
  29605. /**
  29606. * Gets or sets first associated color
  29607. */
  29608. color1: Color4;
  29609. /**
  29610. * Gets or sets second associated color
  29611. */
  29612. color2?: Color4;
  29613. /**
  29614. * Will get a color picked randomly between color1 and color2.
  29615. * If color2 is undefined then color1 will be used
  29616. * @param result defines the target Color4 to store the result in
  29617. */
  29618. getColorToRef(result: Color4): void;
  29619. }
  29620. /** Class used to store factor gradient */
  29621. class FactorGradient implements IValueGradient {
  29622. /**
  29623. * Gets or sets the gradient value (between 0 and 1)
  29624. */
  29625. gradient: number;
  29626. /**
  29627. * Gets or sets associated factor
  29628. */
  29629. factor: number;
  29630. }
  29631. class LoadFileError extends Error {
  29632. request: XMLHttpRequest | undefined;
  29633. private static _setPrototypeOf;
  29634. constructor(message: string, request?: XMLHttpRequest | undefined);
  29635. }
  29636. class RetryStrategy {
  29637. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29638. }
  29639. interface IFileRequest {
  29640. /**
  29641. * Raised when the request is complete (success or error).
  29642. */
  29643. onCompleteObservable: Observable<IFileRequest>;
  29644. /**
  29645. * Aborts the request for a file.
  29646. */
  29647. abort: () => void;
  29648. }
  29649. class Tools {
  29650. static BaseUrl: string;
  29651. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29652. /**
  29653. * Default behaviour for cors in the application.
  29654. * It can be a string if the expected behavior is identical in the entire app.
  29655. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29656. */
  29657. static CorsBehavior: string | ((url: string | string[]) => string);
  29658. static UseFallbackTexture: boolean;
  29659. /**
  29660. * Use this object to register external classes like custom textures or material
  29661. * to allow the laoders to instantiate them
  29662. */
  29663. static RegisteredExternalClasses: {
  29664. [key: string]: Object;
  29665. };
  29666. static fallbackTexture: string;
  29667. /**
  29668. * Interpolates between a and b via alpha
  29669. * @param a The lower value (returned when alpha = 0)
  29670. * @param b The upper value (returned when alpha = 1)
  29671. * @param alpha The interpolation-factor
  29672. * @return The mixed value
  29673. */
  29674. static Mix(a: number, b: number, alpha: number): number;
  29675. static Instantiate(className: string): any;
  29676. /**
  29677. * Provides a slice function that will work even on IE
  29678. * @param data defines the array to slice
  29679. * @param start defines the start of the data (optional)
  29680. * @param end defines the end of the data (optional)
  29681. * @returns the new sliced array
  29682. */
  29683. static Slice<T>(data: T, start?: number, end?: number): T;
  29684. static SetImmediate(action: () => void): void;
  29685. static IsExponentOfTwo(value: number): boolean;
  29686. private static _tmpFloatArray;
  29687. /**
  29688. * Returns the nearest 32-bit single precision float representation of a Number
  29689. * @param value A Number. If the parameter is of a different type, it will get converted
  29690. * to a number or to NaN if it cannot be converted
  29691. * @returns number
  29692. */
  29693. static FloatRound(value: number): number;
  29694. /**
  29695. * Find the next highest power of two.
  29696. * @param x Number to start search from.
  29697. * @return Next highest power of two.
  29698. */
  29699. static CeilingPOT(x: number): number;
  29700. /**
  29701. * Find the next lowest power of two.
  29702. * @param x Number to start search from.
  29703. * @return Next lowest power of two.
  29704. */
  29705. static FloorPOT(x: number): number;
  29706. /**
  29707. * Find the nearest power of two.
  29708. * @param x Number to start search from.
  29709. * @return Next nearest power of two.
  29710. */
  29711. static NearestPOT(x: number): number;
  29712. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29713. static GetFilename(path: string): string;
  29714. /**
  29715. * Extracts the "folder" part of a path (everything before the filename).
  29716. * @param uri The URI to extract the info from
  29717. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29718. * @returns The "folder" part of the path
  29719. */
  29720. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29721. static GetDOMTextContent(element: HTMLElement): string;
  29722. static ToDegrees(angle: number): number;
  29723. static ToRadians(angle: number): number;
  29724. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29725. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29726. minimum: Vector3;
  29727. maximum: Vector3;
  29728. };
  29729. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29730. minimum: Vector3;
  29731. maximum: Vector3;
  29732. };
  29733. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  29734. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  29735. minimum: Vector2;
  29736. maximum: Vector2;
  29737. };
  29738. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29739. static GetPointerPrefix(): string;
  29740. /**
  29741. * @param func - the function to be called
  29742. * @param requester - the object that will request the next frame. Falls back to window.
  29743. */
  29744. static QueueNewFrame(func: () => void, requester?: any): number;
  29745. static RequestFullscreen(element: HTMLElement): void;
  29746. static ExitFullscreen(): void;
  29747. static SetCorsBehavior(url: string | string[], element: {
  29748. crossOrigin: string | null;
  29749. }): void;
  29750. static CleanUrl(url: string): string;
  29751. static PreprocessUrl: (url: string) => string;
  29752. /**
  29753. * Loads an image as an HTMLImageElement.
  29754. * @param input url string, ArrayBuffer, or Blob to load
  29755. * @param onLoad callback called when the image successfully loads
  29756. * @param onError callback called when the image fails to load
  29757. * @param database database for caching
  29758. * @returns the HTMLImageElement of the loaded image
  29759. */
  29760. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  29761. 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;
  29762. /**
  29763. * Load a script (identified by an url). When the url returns, the
  29764. * content of this file is added into a new script element, attached to the DOM (body element)
  29765. */
  29766. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29767. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29768. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29769. static FileAsURL(content: string): string;
  29770. static Format(value: number, decimals?: number): string;
  29771. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29772. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29773. static IsEmpty(obj: any): boolean;
  29774. static RegisterTopRootEvents(events: {
  29775. name: string;
  29776. handler: Nullable<(e: FocusEvent) => any>;
  29777. }[]): void;
  29778. static UnregisterTopRootEvents(events: {
  29779. name: string;
  29780. handler: Nullable<(e: FocusEvent) => any>;
  29781. }[]): void;
  29782. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29783. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29784. /**
  29785. * Downloads a blob in the browser
  29786. * @param blob defines the blob to download
  29787. * @param fileName defines the name of the downloaded file
  29788. */
  29789. static Download(blob: Blob, fileName: string): void;
  29790. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29791. /**
  29792. * Generates an image screenshot from the specified camera.
  29793. *
  29794. * @param engine The engine to use for rendering
  29795. * @param camera The camera to use for rendering
  29796. * @param size This parameter can be set to a single number or to an object with the
  29797. * following (optional) properties: precision, width, height. If a single number is passed,
  29798. * it will be used for both width and height. If an object is passed, the screenshot size
  29799. * will be derived from the parameters. The precision property is a multiplier allowing
  29800. * rendering at a higher or lower resolution.
  29801. * @param successCallback The callback receives a single parameter which contains the
  29802. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29803. * src parameter of an <img> to display it.
  29804. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29805. * Check your browser for supported MIME types.
  29806. * @param samples Texture samples (default: 1)
  29807. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29808. * @param fileName A name for for the downloaded file.
  29809. * @constructor
  29810. */
  29811. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29812. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  29813. /**
  29814. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29815. * Be aware Math.random() could cause collisions, but:
  29816. * "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"
  29817. */
  29818. static RandomId(): string;
  29819. /**
  29820. * Test if the given uri is a base64 string.
  29821. * @param uri The uri to test
  29822. * @return True if the uri is a base64 string or false otherwise.
  29823. */
  29824. static IsBase64(uri: string): boolean;
  29825. /**
  29826. * Decode the given base64 uri.
  29827. * @param uri The uri to decode
  29828. * @return The decoded base64 data.
  29829. */
  29830. static DecodeBase64(uri: string): ArrayBuffer;
  29831. private static _NoneLogLevel;
  29832. private static _MessageLogLevel;
  29833. private static _WarningLogLevel;
  29834. private static _ErrorLogLevel;
  29835. private static _LogCache;
  29836. static errorsCount: number;
  29837. static OnNewCacheEntry: (entry: string) => void;
  29838. static readonly NoneLogLevel: number;
  29839. static readonly MessageLogLevel: number;
  29840. static readonly WarningLogLevel: number;
  29841. static readonly ErrorLogLevel: number;
  29842. static readonly AllLogLevel: number;
  29843. private static _AddLogEntry(entry);
  29844. private static _FormatMessage(message);
  29845. private static _LogDisabled(message);
  29846. private static _LogEnabled(message);
  29847. private static _WarnDisabled(message);
  29848. private static _WarnEnabled(message);
  29849. private static _ErrorDisabled(message);
  29850. private static _ErrorEnabled(message);
  29851. static Log: (message: string) => void;
  29852. static Warn: (message: string) => void;
  29853. static Error: (message: string) => void;
  29854. static readonly LogCache: string;
  29855. static ClearLogCache(): void;
  29856. static LogLevels: number;
  29857. static IsWindowObjectExist(): boolean;
  29858. private static _PerformanceNoneLogLevel;
  29859. private static _PerformanceUserMarkLogLevel;
  29860. private static _PerformanceConsoleLogLevel;
  29861. private static _performance;
  29862. static readonly PerformanceNoneLogLevel: number;
  29863. static readonly PerformanceUserMarkLogLevel: number;
  29864. static readonly PerformanceConsoleLogLevel: number;
  29865. static PerformanceLogLevel: number;
  29866. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29867. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29868. static _StartUserMark(counterName: string, condition?: boolean): void;
  29869. static _EndUserMark(counterName: string, condition?: boolean): void;
  29870. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29871. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29872. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29873. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29874. static readonly Now: number;
  29875. /**
  29876. * This method will return the name of the class used to create the instance of the given object.
  29877. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29878. * @param object the object to get the class name from
  29879. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29880. */
  29881. static GetClassName(object: any, isType?: boolean): string;
  29882. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29883. /**
  29884. * This method will return the name of the full name of the class, including its owning module (if any).
  29885. * 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).
  29886. * @param object the object to get the class name from
  29887. * @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.
  29888. */
  29889. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29890. /**
  29891. * 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.
  29892. * @param array
  29893. */
  29894. static arrayOrStringFeeder(array: any): (i: number) => number;
  29895. /**
  29896. * Compute the hashCode of a stream of number
  29897. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29898. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29899. * @return the hash code computed
  29900. */
  29901. static hashCodeFromStream(feeder: (index: number) => number): number;
  29902. /**
  29903. * Returns a promise that resolves after the given amount of time.
  29904. * @param delay Number of milliseconds to delay
  29905. * @returns Promise that resolves after the given amount of time
  29906. */
  29907. static DelayAsync(delay: number): Promise<void>;
  29908. /**
  29909. * Gets the current gradient from an array of IValueGradient
  29910. * @param ratio defines the current ratio to get
  29911. * @param gradients defines the array of IValueGradient
  29912. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  29913. */
  29914. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  29915. }
  29916. /**
  29917. * This class is used to track a performance counter which is number based.
  29918. * The user has access to many properties which give statistics of different nature
  29919. *
  29920. * The implementer can track two kinds of Performance Counter: time and count
  29921. * 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.
  29922. * 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.
  29923. */
  29924. class PerfCounter {
  29925. static Enabled: boolean;
  29926. /**
  29927. * Returns the smallest value ever
  29928. */
  29929. readonly min: number;
  29930. /**
  29931. * Returns the biggest value ever
  29932. */
  29933. readonly max: number;
  29934. /**
  29935. * Returns the average value since the performance counter is running
  29936. */
  29937. readonly average: number;
  29938. /**
  29939. * Returns the average value of the last second the counter was monitored
  29940. */
  29941. readonly lastSecAverage: number;
  29942. /**
  29943. * Returns the current value
  29944. */
  29945. readonly current: number;
  29946. readonly total: number;
  29947. readonly count: number;
  29948. constructor();
  29949. /**
  29950. * Call this method to start monitoring a new frame.
  29951. * 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.
  29952. */
  29953. fetchNewFrame(): void;
  29954. /**
  29955. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29956. * @param newCount the count value to add to the monitored count
  29957. * @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.
  29958. */
  29959. addCount(newCount: number, fetchResult: boolean): void;
  29960. /**
  29961. * Start monitoring this performance counter
  29962. */
  29963. beginMonitoring(): void;
  29964. /**
  29965. * Compute the time lapsed since the previous beginMonitoring() call.
  29966. * @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
  29967. */
  29968. endMonitoring(newFrame?: boolean): void;
  29969. private _fetchResult();
  29970. private _startMonitoringTime;
  29971. private _min;
  29972. private _max;
  29973. private _average;
  29974. private _current;
  29975. private _totalValueCount;
  29976. private _totalAccumulated;
  29977. private _lastSecAverage;
  29978. private _lastSecAccumulated;
  29979. private _lastSecTime;
  29980. private _lastSecValueCount;
  29981. }
  29982. /**
  29983. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29984. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29985. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29986. * @param name The name of the class, case should be preserved
  29987. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29988. */
  29989. function className(name: string, module?: string): (target: Object) => void;
  29990. /**
  29991. * An implementation of a loop for asynchronous functions.
  29992. */
  29993. class AsyncLoop {
  29994. iterations: number;
  29995. private _fn;
  29996. private _successCallback;
  29997. index: number;
  29998. private _done;
  29999. /**
  30000. * Constroctor.
  30001. * @param iterations the number of iterations.
  30002. * @param _fn the function to run each iteration
  30003. * @param _successCallback the callback that will be called upon succesful execution
  30004. * @param offset starting offset.
  30005. */
  30006. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  30007. /**
  30008. * Execute the next iteration. Must be called after the last iteration was finished.
  30009. */
  30010. executeNext(): void;
  30011. /**
  30012. * Break the loop and run the success callback.
  30013. */
  30014. breakLoop(): void;
  30015. /**
  30016. * Helper function
  30017. */
  30018. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  30019. /**
  30020. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30021. * @param iterations total number of iterations
  30022. * @param syncedIterations number of synchronous iterations in each async iteration.
  30023. * @param fn the function to call each iteration.
  30024. * @param callback a success call back that will be called when iterating stops.
  30025. * @param breakFunction a break condition (optional)
  30026. * @param timeout timeout settings for the setTimeout function. default - 0.
  30027. * @constructor
  30028. */
  30029. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  30030. }
  30031. }
  30032. declare module BABYLON {
  30033. /**
  30034. * Defines the potential axis of a Joystick
  30035. */
  30036. enum JoystickAxis {
  30037. /** X axis */
  30038. X = 0,
  30039. /** Y axis */
  30040. Y = 1,
  30041. /** Z axis */
  30042. Z = 2,
  30043. }
  30044. /**
  30045. * Class used to define virtual joystick (used in touch mode)
  30046. */
  30047. class VirtualJoystick {
  30048. /**
  30049. * Gets or sets a boolean indicating that left and right values must be inverted
  30050. */
  30051. reverseLeftRight: boolean;
  30052. /**
  30053. * Gets or sets a boolean indicating that up and down values must be inverted
  30054. */
  30055. reverseUpDown: boolean;
  30056. /**
  30057. * Gets the offset value for the position (ie. the change of the position value)
  30058. */
  30059. deltaPosition: Vector3;
  30060. /**
  30061. * Gets a boolean indicating if the virtual joystick was pressed
  30062. */
  30063. pressed: boolean;
  30064. private static _globalJoystickIndex;
  30065. private static vjCanvas;
  30066. private static vjCanvasContext;
  30067. private static vjCanvasWidth;
  30068. private static vjCanvasHeight;
  30069. private static halfWidth;
  30070. private _action;
  30071. private _axisTargetedByLeftAndRight;
  30072. private _axisTargetedByUpAndDown;
  30073. private _joystickSensibility;
  30074. private _inversedSensibility;
  30075. private _joystickPointerID;
  30076. private _joystickColor;
  30077. private _joystickPointerPos;
  30078. private _joystickPreviousPointerPos;
  30079. private _joystickPointerStartPos;
  30080. private _deltaJoystickVector;
  30081. private _leftJoystick;
  30082. private _touches;
  30083. private _onPointerDownHandlerRef;
  30084. private _onPointerMoveHandlerRef;
  30085. private _onPointerUpHandlerRef;
  30086. private _onResize;
  30087. /**
  30088. * Creates a new virtual joystick
  30089. * @param leftJoystick defines that the joystick is for left hand (false by default)
  30090. */
  30091. constructor(leftJoystick?: boolean);
  30092. /**
  30093. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  30094. * @param newJoystickSensibility defines the new sensibility
  30095. */
  30096. setJoystickSensibility(newJoystickSensibility: number): void;
  30097. private _onPointerDown(e);
  30098. private _onPointerMove(e);
  30099. private _onPointerUp(e);
  30100. /**
  30101. * Change the color of the virtual joystick
  30102. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  30103. */
  30104. setJoystickColor(newColor: string): void;
  30105. /**
  30106. * Defines a callback to call when the joystick is touched
  30107. * @param action defines the callback
  30108. */
  30109. setActionOnTouch(action: () => any): void;
  30110. /**
  30111. * Defines which axis you'd like to control for left & right
  30112. * @param axis defines the axis to use
  30113. */
  30114. setAxisForLeftRight(axis: JoystickAxis): void;
  30115. /**
  30116. * Defines which axis you'd like to control for up & down
  30117. * @param axis defines the axis to use
  30118. */
  30119. setAxisForUpDown(axis: JoystickAxis): void;
  30120. private _drawVirtualJoystick();
  30121. /**
  30122. * Release internal HTML canvas
  30123. */
  30124. releaseCanvas(): void;
  30125. }
  30126. }
  30127. declare module BABYLON {
  30128. /**
  30129. * Helper class to push actions to a pool of workers.
  30130. */
  30131. class WorkerPool implements IDisposable {
  30132. private _workerInfos;
  30133. private _pendingActions;
  30134. /**
  30135. * Constructor
  30136. * @param workers Array of workers to use for actions
  30137. */
  30138. constructor(workers: Array<Worker>);
  30139. /**
  30140. * Terminates all workers and clears any pending actions.
  30141. */
  30142. dispose(): void;
  30143. /**
  30144. * Pushes an action to the worker pool. If all the workers are active, the action will be
  30145. * pended until a worker has completed its action.
  30146. * @param action The action to perform. Call onComplete when the action is complete.
  30147. */
  30148. push(action: (worker: Worker, onComplete: () => void) => void): void;
  30149. private _execute(workerInfo, action);
  30150. }
  30151. }
  30152. declare module BABYLON {
  30153. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  30154. readonly name: string;
  30155. private _zoomStopsAnimation;
  30156. private _idleRotationSpeed;
  30157. private _idleRotationWaitTime;
  30158. private _idleRotationSpinupTime;
  30159. /**
  30160. * Gets the flag that indicates if user zooming should stop animation.
  30161. */
  30162. /**
  30163. * Sets the flag that indicates if user zooming should stop animation.
  30164. */
  30165. zoomStopsAnimation: boolean;
  30166. /**
  30167. * Gets the default speed at which the camera rotates around the model.
  30168. */
  30169. /**
  30170. * Sets the default speed at which the camera rotates around the model.
  30171. */
  30172. idleRotationSpeed: number;
  30173. /**
  30174. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  30175. */
  30176. /**
  30177. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  30178. */
  30179. idleRotationWaitTime: number;
  30180. /**
  30181. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30182. */
  30183. /**
  30184. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30185. */
  30186. idleRotationSpinupTime: number;
  30187. /**
  30188. * Gets a value indicating if the camera is currently rotating because of this behavior
  30189. */
  30190. readonly rotationInProgress: boolean;
  30191. private _onPrePointerObservableObserver;
  30192. private _onAfterCheckInputsObserver;
  30193. private _attachedCamera;
  30194. private _isPointerDown;
  30195. private _lastFrameTime;
  30196. private _lastInteractionTime;
  30197. private _cameraRotationSpeed;
  30198. init(): void;
  30199. attach(camera: ArcRotateCamera): void;
  30200. detach(): void;
  30201. /**
  30202. * Returns true if user is scrolling.
  30203. * @return true if user is scrolling.
  30204. */
  30205. private _userIsZooming();
  30206. private _lastFrameRadius;
  30207. private _shouldAnimationStopForInteraction();
  30208. /**
  30209. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30210. */
  30211. private _applyUserInteraction();
  30212. private _userIsMoving();
  30213. }
  30214. }
  30215. declare module BABYLON {
  30216. /**
  30217. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  30218. */
  30219. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  30220. readonly name: string;
  30221. /**
  30222. * The easing function used by animations
  30223. */
  30224. static EasingFunction: BackEase;
  30225. /**
  30226. * The easing mode used by animations
  30227. */
  30228. static EasingMode: number;
  30229. /**
  30230. * The duration of the animation, in milliseconds
  30231. */
  30232. transitionDuration: number;
  30233. /**
  30234. * Length of the distance animated by the transition when lower radius is reached
  30235. */
  30236. lowerRadiusTransitionRange: number;
  30237. /**
  30238. * Length of the distance animated by the transition when upper radius is reached
  30239. */
  30240. upperRadiusTransitionRange: number;
  30241. private _autoTransitionRange;
  30242. /**
  30243. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30244. */
  30245. /**
  30246. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30247. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  30248. */
  30249. autoTransitionRange: boolean;
  30250. private _attachedCamera;
  30251. private _onAfterCheckInputsObserver;
  30252. private _onMeshTargetChangedObserver;
  30253. init(): void;
  30254. attach(camera: ArcRotateCamera): void;
  30255. detach(): void;
  30256. private _radiusIsAnimating;
  30257. private _radiusBounceTransition;
  30258. private _animatables;
  30259. private _cachedWheelPrecision;
  30260. /**
  30261. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  30262. * @param radiusLimit The limit to check against.
  30263. * @return Bool to indicate if at limit.
  30264. */
  30265. private _isRadiusAtLimit(radiusLimit);
  30266. /**
  30267. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  30268. * @param radiusDelta The delta by which to animate to. Can be negative.
  30269. */
  30270. private _applyBoundRadiusAnimation(radiusDelta);
  30271. /**
  30272. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  30273. */
  30274. protected _clearAnimationLocks(): void;
  30275. /**
  30276. * Stops and removes all animations that have been applied to the camera
  30277. */
  30278. stopAllAnimations(): void;
  30279. }
  30280. }
  30281. declare module BABYLON {
  30282. class FramingBehavior implements Behavior<ArcRotateCamera> {
  30283. readonly name: string;
  30284. private _mode;
  30285. private _radiusScale;
  30286. private _positionScale;
  30287. private _defaultElevation;
  30288. private _elevationReturnTime;
  30289. private _elevationReturnWaitTime;
  30290. private _zoomStopsAnimation;
  30291. private _framingTime;
  30292. /**
  30293. * The easing function used by animations
  30294. */
  30295. static EasingFunction: ExponentialEase;
  30296. /**
  30297. * The easing mode used by animations
  30298. */
  30299. static EasingMode: number;
  30300. /**
  30301. * Gets current mode used by the behavior.
  30302. */
  30303. /**
  30304. * Sets the current mode used by the behavior
  30305. */
  30306. mode: number;
  30307. /**
  30308. * Gets the scale applied to the radius
  30309. */
  30310. /**
  30311. * Sets the scale applied to the radius (1 by default)
  30312. */
  30313. radiusScale: number;
  30314. /**
  30315. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  30316. */
  30317. /**
  30318. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  30319. */
  30320. positionScale: number;
  30321. /**
  30322. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  30323. * behaviour is triggered, in radians.
  30324. */
  30325. /**
  30326. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  30327. * behaviour is triggered, in radians.
  30328. */
  30329. defaultElevation: number;
  30330. /**
  30331. * Gets the time (in milliseconds) taken to return to the default beta position.
  30332. * Negative value indicates camera should not return to default.
  30333. */
  30334. /**
  30335. * Sets the time (in milliseconds) taken to return to the default beta position.
  30336. * Negative value indicates camera should not return to default.
  30337. */
  30338. elevationReturnTime: number;
  30339. /**
  30340. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30341. */
  30342. /**
  30343. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30344. */
  30345. elevationReturnWaitTime: number;
  30346. /**
  30347. * Gets the flag that indicates if user zooming should stop animation.
  30348. */
  30349. /**
  30350. * Sets the flag that indicates if user zooming should stop animation.
  30351. */
  30352. zoomStopsAnimation: boolean;
  30353. /**
  30354. * Gets the transition time when framing the mesh, in milliseconds
  30355. */
  30356. /**
  30357. * Sets the transition time when framing the mesh, in milliseconds
  30358. */
  30359. framingTime: number;
  30360. private _onPrePointerObservableObserver;
  30361. private _onAfterCheckInputsObserver;
  30362. private _onMeshTargetChangedObserver;
  30363. private _attachedCamera;
  30364. private _isPointerDown;
  30365. private _lastInteractionTime;
  30366. init(): void;
  30367. attach(camera: ArcRotateCamera): void;
  30368. detach(): void;
  30369. private _animatables;
  30370. private _betaIsAnimating;
  30371. private _betaTransition;
  30372. private _radiusTransition;
  30373. private _vectorTransition;
  30374. /**
  30375. * Targets the given mesh and updates zoom level accordingly.
  30376. * @param mesh The mesh to target.
  30377. * @param radius Optional. If a cached radius position already exists, overrides default.
  30378. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30379. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30380. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30381. */
  30382. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30383. /**
  30384. * Targets the given mesh with its children and updates zoom level accordingly.
  30385. * @param mesh The mesh to target.
  30386. * @param radius Optional. If a cached radius position already exists, overrides default.
  30387. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30388. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30389. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30390. */
  30391. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30392. /**
  30393. * Targets the given meshes with their children and updates zoom level accordingly.
  30394. * @param meshes The mesh to target.
  30395. * @param radius Optional. If a cached radius position already exists, overrides default.
  30396. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30397. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30398. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30399. */
  30400. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30401. /**
  30402. * Targets the given mesh and updates zoom level accordingly.
  30403. * @param mesh The mesh to target.
  30404. * @param radius Optional. If a cached radius position already exists, overrides default.
  30405. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30406. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30407. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30408. */
  30409. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30410. /**
  30411. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  30412. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  30413. * frustum width.
  30414. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  30415. * to fully enclose the mesh in the viewing frustum.
  30416. */
  30417. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  30418. /**
  30419. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  30420. * is automatically returned to its default position (expected to be above ground plane).
  30421. */
  30422. private _maintainCameraAboveGround();
  30423. /**
  30424. * Returns the frustum slope based on the canvas ratio and camera FOV
  30425. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  30426. */
  30427. private _getFrustumSlope();
  30428. /**
  30429. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  30430. */
  30431. private _clearAnimationLocks();
  30432. /**
  30433. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30434. */
  30435. private _applyUserInteraction();
  30436. /**
  30437. * Stops and removes all animations that have been applied to the camera
  30438. */
  30439. stopAllAnimations(): void;
  30440. /**
  30441. * Gets a value indicating if the user is moving the camera
  30442. */
  30443. readonly isUserIsMoving: boolean;
  30444. /**
  30445. * The camera can move all the way towards the mesh.
  30446. */
  30447. static IgnoreBoundsSizeMode: number;
  30448. /**
  30449. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  30450. */
  30451. static FitFrustumSidesMode: number;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /**
  30456. * A behavior that when attached to a mesh will allow the mesh to be scaled
  30457. */
  30458. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  30459. private _dragBehaviorA;
  30460. private _dragBehaviorB;
  30461. private _startDistance;
  30462. private _initialScale;
  30463. private _targetScale;
  30464. private _ownerNode;
  30465. private _sceneRenderObserver;
  30466. constructor();
  30467. /**
  30468. * The name of the behavior
  30469. */
  30470. readonly name: string;
  30471. /**
  30472. * Initializes the behavior
  30473. */
  30474. init(): void;
  30475. private _getCurrentDistance();
  30476. /**
  30477. * Attaches the scale behavior the passed in mesh
  30478. * @param ownerNode The mesh that will be scaled around once attached
  30479. */
  30480. attach(ownerNode: Mesh): void;
  30481. /**
  30482. * Detaches the behavior from the mesh
  30483. */
  30484. detach(): void;
  30485. }
  30486. }
  30487. declare module BABYLON {
  30488. /**
  30489. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  30490. */
  30491. class PointerDragBehavior implements Behavior<Mesh> {
  30492. private options;
  30493. private _attachedNode;
  30494. private _dragPlane;
  30495. private _scene;
  30496. private _pointerObserver;
  30497. private static _planeScene;
  30498. /**
  30499. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30500. */
  30501. currentDraggingPointerID: number;
  30502. /**
  30503. * The last position where the pointer hit the drag plane in world space
  30504. */
  30505. lastDragPosition: Vector3;
  30506. /**
  30507. * If the behavior is currently in a dragging state
  30508. */
  30509. dragging: boolean;
  30510. /**
  30511. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  30512. */
  30513. dragDeltaRatio: number;
  30514. /**
  30515. * If the drag plane orientation should be updated during the dragging (Default: true)
  30516. */
  30517. updateDragPlane: boolean;
  30518. private _debugMode;
  30519. private _moving;
  30520. /**
  30521. * Fires each time the attached mesh is dragged with the pointer
  30522. * * delta between last drag position and current drag position in world space
  30523. * * dragDistance along the drag axis
  30524. * * dragPlaneNormal normal of the current drag plane used during the drag
  30525. * * dragPlanePoint in world space where the drag intersects the drag plane
  30526. */
  30527. onDragObservable: Observable<{
  30528. delta: Vector3;
  30529. dragPlanePoint: Vector3;
  30530. dragPlaneNormal: Vector3;
  30531. dragDistance: number;
  30532. pointerId: number;
  30533. }>;
  30534. /**
  30535. * Fires each time a drag begins (eg. mouse down on mesh)
  30536. */
  30537. onDragStartObservable: Observable<{
  30538. dragPlanePoint: Vector3;
  30539. pointerId: number;
  30540. }>;
  30541. /**
  30542. * Fires each time a drag ends (eg. mouse release after drag)
  30543. */
  30544. onDragEndObservable: Observable<{
  30545. dragPlanePoint: Vector3;
  30546. pointerId: number;
  30547. }>;
  30548. /**
  30549. * If the attached mesh should be moved when dragged
  30550. */
  30551. moveAttached: boolean;
  30552. /**
  30553. * If the drag behavior will react to drag events (Default: true)
  30554. */
  30555. enabled: boolean;
  30556. /**
  30557. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  30558. */
  30559. useObjectOrienationForDragging: boolean;
  30560. /**
  30561. * Creates a pointer drag behavior that can be attached to a mesh
  30562. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  30563. */
  30564. constructor(options: {
  30565. dragAxis?: Vector3;
  30566. dragPlaneNormal?: Vector3;
  30567. });
  30568. /**
  30569. * The name of the behavior
  30570. */
  30571. readonly name: string;
  30572. /**
  30573. * Initializes the behavior
  30574. */
  30575. init(): void;
  30576. private _tmpVector;
  30577. private _worldDragAxis;
  30578. /**
  30579. * Attaches the drag behavior the passed in mesh
  30580. * @param ownerNode The mesh that will be dragged around once attached
  30581. */
  30582. attach(ownerNode: Mesh): void;
  30583. releaseDrag(): void;
  30584. private _pickWithRayOnDragPlane(ray);
  30585. private _pointA;
  30586. private _pointB;
  30587. private _pointC;
  30588. private _lineA;
  30589. private _lineB;
  30590. private _localAxis;
  30591. private _lookAt;
  30592. private _updateDragPlanePosition(ray, dragPlanePosition);
  30593. /**
  30594. * Detaches the behavior from the mesh
  30595. */
  30596. detach(): void;
  30597. }
  30598. }
  30599. declare module BABYLON {
  30600. /**
  30601. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  30602. */
  30603. class SixDofDragBehavior implements Behavior<Mesh> {
  30604. private static _virtualScene;
  30605. private _ownerNode;
  30606. private _sceneRenderObserver;
  30607. private _scene;
  30608. private _targetPosition;
  30609. private _virtualOriginMesh;
  30610. private _virtualDragMesh;
  30611. private _pointerObserver;
  30612. private _moving;
  30613. private _startingOrientation;
  30614. /**
  30615. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 5)
  30616. */
  30617. private zDragFactor;
  30618. /**
  30619. * If the behavior is currently in a dragging state
  30620. */
  30621. dragging: boolean;
  30622. /**
  30623. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  30624. */
  30625. dragDeltaRatio: number;
  30626. /**
  30627. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30628. */
  30629. currentDraggingPointerID: number;
  30630. constructor();
  30631. /**
  30632. * The name of the behavior
  30633. */
  30634. readonly name: string;
  30635. /**
  30636. * Initializes the behavior
  30637. */
  30638. init(): void;
  30639. /**
  30640. * Attaches the scale behavior the passed in mesh
  30641. * @param ownerNode The mesh that will be scaled around once attached
  30642. */
  30643. attach(ownerNode: Mesh): void;
  30644. /**
  30645. * Detaches the behavior from the mesh
  30646. */
  30647. detach(): void;
  30648. }
  30649. }
  30650. declare module BABYLON {
  30651. class VRCameraMetrics {
  30652. hResolution: number;
  30653. vResolution: number;
  30654. hScreenSize: number;
  30655. vScreenSize: number;
  30656. vScreenCenter: number;
  30657. eyeToScreenDistance: number;
  30658. lensSeparationDistance: number;
  30659. interpupillaryDistance: number;
  30660. distortionK: number[];
  30661. chromaAbCorrection: number[];
  30662. postProcessScaleFactor: number;
  30663. lensCenterOffset: number;
  30664. compensateDistortion: boolean;
  30665. readonly aspectRatio: number;
  30666. readonly aspectRatioFov: number;
  30667. readonly leftHMatrix: Matrix;
  30668. readonly rightHMatrix: Matrix;
  30669. readonly leftPreViewMatrix: Matrix;
  30670. readonly rightPreViewMatrix: Matrix;
  30671. static GetDefault(): VRCameraMetrics;
  30672. }
  30673. }
  30674. declare module BABYLON {
  30675. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  30676. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30677. getClassName(): string;
  30678. }
  30679. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  30680. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30681. getClassName(): string;
  30682. }
  30683. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  30684. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  30685. getClassName(): string;
  30686. }
  30687. }
  30688. declare module BABYLON {
  30689. /**
  30690. * Options to modify the vr teleportation behavior.
  30691. */
  30692. interface VRTeleportationOptions {
  30693. /**
  30694. * The name of the mesh which should be used as the teleportation floor. (default: null)
  30695. */
  30696. floorMeshName?: string;
  30697. /**
  30698. * A list of meshes to be used as the teleportation floor. (default: empty)
  30699. */
  30700. floorMeshes?: Mesh[];
  30701. }
  30702. /**
  30703. * Options to modify the vr experience helper's behavior.
  30704. */
  30705. interface VRExperienceHelperOptions extends WebVROptions {
  30706. /**
  30707. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  30708. */
  30709. createDeviceOrientationCamera?: boolean;
  30710. /**
  30711. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  30712. */
  30713. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  30714. /**
  30715. * Uses the main button on the controller to toggle the laser casted. (default: true)
  30716. */
  30717. laserToggle?: boolean;
  30718. /**
  30719. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  30720. */
  30721. floorMeshes?: Mesh[];
  30722. }
  30723. /**
  30724. * Helps to quickly add VR support to an existing scene.
  30725. * See http://doc.babylonjs.com/how_to/webvr_helper
  30726. */
  30727. class VRExperienceHelper {
  30728. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  30729. private _scene;
  30730. private _position;
  30731. private _btnVR;
  30732. private _btnVRDisplayed;
  30733. private _webVRsupported;
  30734. private _webVRready;
  30735. private _webVRrequesting;
  30736. private _webVRpresenting;
  30737. private _fullscreenVRpresenting;
  30738. private _canvas;
  30739. private _webVRCamera;
  30740. private _vrDeviceOrientationCamera;
  30741. private _deviceOrientationCamera;
  30742. private _existingCamera;
  30743. private _onKeyDown;
  30744. private _onVrDisplayPresentChange;
  30745. private _onVRDisplayChanged;
  30746. private _onVRRequestPresentStart;
  30747. private _onVRRequestPresentComplete;
  30748. /**
  30749. * Observable raised when entering VR.
  30750. */
  30751. onEnteringVRObservable: Observable<VRExperienceHelper>;
  30752. /**
  30753. * Observable raised when exiting VR.
  30754. */
  30755. onExitingVRObservable: Observable<VRExperienceHelper>;
  30756. /**
  30757. * Observable raised when controller mesh is loaded.
  30758. */
  30759. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30760. /** Return this.onEnteringVRObservable
  30761. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  30762. */
  30763. readonly onEnteringVR: Observable<VRExperienceHelper>;
  30764. /** Return this.onExitingVRObservable
  30765. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  30766. */
  30767. readonly onExitingVR: Observable<VRExperienceHelper>;
  30768. /** Return this.onControllerMeshLoadedObservable
  30769. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  30770. */
  30771. readonly onControllerMeshLoaded: Observable<WebVRController>;
  30772. private _rayLength;
  30773. private _useCustomVRButton;
  30774. private _teleportationRequested;
  30775. private _teleportActive;
  30776. private _floorMeshName;
  30777. private _floorMeshesCollection;
  30778. private _rotationAllowed;
  30779. private _teleportBackwardsVector;
  30780. private _teleportationTarget;
  30781. private _isDefaultTeleportationTarget;
  30782. private _postProcessMove;
  30783. private _teleportationFillColor;
  30784. private _teleportationBorderColor;
  30785. private _rotationAngle;
  30786. private _haloCenter;
  30787. private _cameraGazer;
  30788. private _padSensibilityUp;
  30789. private _padSensibilityDown;
  30790. private leftController;
  30791. private rightController;
  30792. /**
  30793. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  30794. */
  30795. onNewMeshSelected: Observable<AbstractMesh>;
  30796. /**
  30797. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  30798. */
  30799. onNewMeshPicked: Observable<PickingInfo>;
  30800. private _circleEase;
  30801. /**
  30802. * Observable raised before camera teleportation
  30803. */
  30804. onBeforeCameraTeleport: Observable<Vector3>;
  30805. /**
  30806. * Observable raised after camera teleportation
  30807. */
  30808. onAfterCameraTeleport: Observable<Vector3>;
  30809. /**
  30810. * Observable raised when current selected mesh gets unselected
  30811. */
  30812. onSelectedMeshUnselected: Observable<AbstractMesh>;
  30813. private _raySelectionPredicate;
  30814. /**
  30815. * To be optionaly changed by user to define custom ray selection
  30816. */
  30817. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  30818. /**
  30819. * To be optionaly changed by user to define custom selection logic (after ray selection)
  30820. */
  30821. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  30822. /**
  30823. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  30824. */
  30825. teleportationEnabled: boolean;
  30826. private _defaultHeight;
  30827. private _teleportationInitialized;
  30828. private _interactionsEnabled;
  30829. private _interactionsRequested;
  30830. private _displayGaze;
  30831. private _displayLaserPointer;
  30832. /**
  30833. * The mesh used to display where the user is going to teleport.
  30834. */
  30835. /**
  30836. * Sets the mesh to be used to display where the user is going to teleport.
  30837. */
  30838. teleportationTarget: Mesh;
  30839. /**
  30840. * The mesh used to display where the user is selecting,
  30841. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  30842. * See http://doc.babylonjs.com/resources/baking_transformations
  30843. */
  30844. gazeTrackerMesh: Mesh;
  30845. /**
  30846. * If the ray of the gaze should be displayed.
  30847. */
  30848. /**
  30849. * Sets if the ray of the gaze should be displayed.
  30850. */
  30851. displayGaze: boolean;
  30852. /**
  30853. * If the ray of the LaserPointer should be displayed.
  30854. */
  30855. /**
  30856. * Sets if the ray of the LaserPointer should be displayed.
  30857. */
  30858. displayLaserPointer: boolean;
  30859. /**
  30860. * The deviceOrientationCamera used as the camera when not in VR.
  30861. */
  30862. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  30863. /**
  30864. * Based on the current WebVR support, returns the current VR camera used.
  30865. */
  30866. readonly currentVRCamera: Nullable<Camera>;
  30867. /**
  30868. * The webVRCamera which is used when in VR.
  30869. */
  30870. readonly webVRCamera: WebVRFreeCamera;
  30871. /**
  30872. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  30873. */
  30874. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  30875. private readonly _teleportationRequestInitiated;
  30876. /**
  30877. * Instantiates a VRExperienceHelper.
  30878. * Helps to quickly add VR support to an existing scene.
  30879. * @param scene The scene the VRExperienceHelper belongs to.
  30880. * @param webVROptions Options to modify the vr experience helper's behavior.
  30881. */
  30882. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30883. private _onDefaultMeshLoaded(webVRController);
  30884. private _onResize;
  30885. private _onFullscreenChange;
  30886. /**
  30887. * Gets a value indicating if we are currently in VR mode.
  30888. */
  30889. readonly isInVRMode: boolean;
  30890. private onVrDisplayPresentChange();
  30891. private onVRDisplayChanged(eventArgs);
  30892. private moveButtonToBottomRight();
  30893. private displayVRButton();
  30894. private updateButtonVisibility();
  30895. /**
  30896. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30897. * Otherwise, will use the fullscreen API.
  30898. */
  30899. enterVR(): void;
  30900. /**
  30901. * Attempt to exit VR, or fullscreen.
  30902. */
  30903. exitVR(): void;
  30904. /**
  30905. * The position of the vr experience helper.
  30906. */
  30907. /**
  30908. * Sets the position of the vr experience helper.
  30909. */
  30910. position: Vector3;
  30911. /**
  30912. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30913. */
  30914. enableInteractions(): void;
  30915. private readonly _noControllerIsActive;
  30916. private beforeRender;
  30917. private _isTeleportationFloor(mesh);
  30918. /**
  30919. * Adds a floor mesh to be used for teleportation.
  30920. * @param floorMesh the mesh to be used for teleportation.
  30921. */
  30922. addFloorMesh(floorMesh: Mesh): void;
  30923. /**
  30924. * Removes a floor mesh from being used for teleportation.
  30925. * @param floorMesh the mesh to be removed.
  30926. */
  30927. removeFloorMesh(floorMesh: Mesh): void;
  30928. /**
  30929. * Enables interactions and teleportation using the VR controllers and gaze.
  30930. * @param vrTeleportationOptions options to modify teleportation behavior.
  30931. */
  30932. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30933. private _onNewGamepadConnected;
  30934. private _tryEnableInteractionOnController;
  30935. private _onNewGamepadDisconnected;
  30936. private _enableInteractionOnController(controller);
  30937. private _checkTeleportWithRay(stateObject, gazer);
  30938. private _checkRotate(stateObject, gazer);
  30939. private _checkTeleportBackwards(stateObject, gazer);
  30940. private _enableTeleportationOnController(controller);
  30941. private _createTeleportationCircles();
  30942. private _displayTeleportationTarget();
  30943. private _hideTeleportationTarget();
  30944. private _rotateCamera(right);
  30945. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30946. private _workingVector;
  30947. private _workingQuaternion;
  30948. private _workingMatrix;
  30949. private _teleportCamera(location);
  30950. private _convertNormalToDirectionOfRay(normal, ray);
  30951. private _castRayAndSelectObject(gazer);
  30952. private _notifySelectedMeshUnselected(mesh);
  30953. /**
  30954. * Sets the color of the laser ray from the vr controllers.
  30955. * @param color new color for the ray.
  30956. */
  30957. changeLaserColor(color: Color3): void;
  30958. /**
  30959. * Sets the color of the ray from the vr headsets gaze.
  30960. * @param color new color for the ray.
  30961. */
  30962. changeGazeColor(color: Color3): void;
  30963. /**
  30964. * Exits VR and disposes of the vr experience helper
  30965. */
  30966. dispose(): void;
  30967. /**
  30968. * Gets the name of the VRExperienceHelper class
  30969. * @returns "VRExperienceHelper"
  30970. */
  30971. getClassName(): string;
  30972. }
  30973. }
  30974. declare module BABYLON {
  30975. /**
  30976. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30977. * IMPORTANT!! The data is right-hand data.
  30978. * @export
  30979. * @interface DevicePose
  30980. */
  30981. interface DevicePose {
  30982. /**
  30983. * The position of the device, values in array are [x,y,z].
  30984. */
  30985. readonly position: Nullable<Float32Array>;
  30986. /**
  30987. * The linearVelocity of the device, values in array are [x,y,z].
  30988. */
  30989. readonly linearVelocity: Nullable<Float32Array>;
  30990. /**
  30991. * The linearAcceleration of the device, values in array are [x,y,z].
  30992. */
  30993. readonly linearAcceleration: Nullable<Float32Array>;
  30994. /**
  30995. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30996. */
  30997. readonly orientation: Nullable<Float32Array>;
  30998. /**
  30999. * The angularVelocity of the device, values in array are [x,y,z].
  31000. */
  31001. readonly angularVelocity: Nullable<Float32Array>;
  31002. /**
  31003. * The angularAcceleration of the device, values in array are [x,y,z].
  31004. */
  31005. readonly angularAcceleration: Nullable<Float32Array>;
  31006. }
  31007. /**
  31008. * Interface representing a pose controlled object in Babylon.
  31009. * A pose controlled object has both regular pose values as well as pose values
  31010. * from an external device such as a VR head mounted display
  31011. */
  31012. interface PoseControlled {
  31013. /**
  31014. * The position of the object in babylon space.
  31015. */
  31016. position: Vector3;
  31017. /**
  31018. * The rotation quaternion of the object in babylon space.
  31019. */
  31020. rotationQuaternion: Quaternion;
  31021. /**
  31022. * The position of the device in babylon space.
  31023. */
  31024. devicePosition?: Vector3;
  31025. /**
  31026. * The rotation quaternion of the device in babylon space.
  31027. */
  31028. deviceRotationQuaternion: Quaternion;
  31029. /**
  31030. * The raw pose coming from the device.
  31031. */
  31032. rawPose: Nullable<DevicePose>;
  31033. /**
  31034. * The scale of the device to be used when translating from device space to babylon space.
  31035. */
  31036. deviceScaleFactor: number;
  31037. /**
  31038. * Updates the poseControlled values based on the input device pose.
  31039. * @param poseData the pose data to update the object with
  31040. */
  31041. updateFromDevice(poseData: DevicePose): void;
  31042. }
  31043. /**
  31044. * Set of options to customize the webVRCamera
  31045. */
  31046. interface WebVROptions {
  31047. /**
  31048. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  31049. */
  31050. trackPosition?: boolean;
  31051. /**
  31052. * Sets the scale of the vrDevice in babylon space. (default: 1)
  31053. */
  31054. positionScale?: number;
  31055. /**
  31056. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  31057. */
  31058. displayName?: string;
  31059. /**
  31060. * Should the native controller meshes be initialized. (default: true)
  31061. */
  31062. controllerMeshes?: boolean;
  31063. /**
  31064. * Creating a default HemiLight only on controllers. (default: true)
  31065. */
  31066. defaultLightingOnControllers?: boolean;
  31067. /**
  31068. * If you don't want to use the default VR button of the helper. (default: false)
  31069. */
  31070. useCustomVRButton?: boolean;
  31071. /**
  31072. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  31073. */
  31074. customVRButton?: HTMLButtonElement;
  31075. /**
  31076. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  31077. */
  31078. rayLength?: number;
  31079. /**
  31080. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  31081. */
  31082. defaultHeight?: number;
  31083. }
  31084. /**
  31085. * This represents a WebVR camera.
  31086. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  31087. * @example http://doc.babylonjs.com/how_to/webvr_camera
  31088. */
  31089. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  31090. private webVROptions;
  31091. /**
  31092. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  31093. */
  31094. _vrDevice: any;
  31095. /**
  31096. * The rawPose of the vrDevice.
  31097. */
  31098. rawPose: Nullable<DevicePose>;
  31099. private _onVREnabled;
  31100. private _specsVersion;
  31101. private _attached;
  31102. private _frameData;
  31103. protected _descendants: Array<Node>;
  31104. private _deviceRoomPosition;
  31105. private _deviceRoomRotationQuaternion;
  31106. private _standingMatrix;
  31107. /**
  31108. * Represents device position in babylon space.
  31109. */
  31110. devicePosition: Vector3;
  31111. /**
  31112. * Represents device rotation in babylon space.
  31113. */
  31114. deviceRotationQuaternion: Quaternion;
  31115. /**
  31116. * The scale of the device to be used when translating from device space to babylon space.
  31117. */
  31118. deviceScaleFactor: number;
  31119. private _deviceToWorld;
  31120. private _worldToDevice;
  31121. /**
  31122. * References to the webVR controllers for the vrDevice.
  31123. */
  31124. controllers: Array<WebVRController>;
  31125. /**
  31126. * Emits an event when a controller is attached.
  31127. */
  31128. onControllersAttachedObservable: Observable<WebVRController[]>;
  31129. /**
  31130. * Emits an event when a controller's mesh has been loaded;
  31131. */
  31132. onControllerMeshLoadedObservable: Observable<WebVRController>;
  31133. /**
  31134. * If the rig cameras be used as parent instead of this camera.
  31135. */
  31136. rigParenting: boolean;
  31137. private _lightOnControllers;
  31138. private _defaultHeight?;
  31139. /**
  31140. * Instantiates a WebVRFreeCamera.
  31141. * @param name The name of the WebVRFreeCamera
  31142. * @param position The starting anchor position for the camera
  31143. * @param scene The scene the camera belongs to
  31144. * @param webVROptions a set of customizable options for the webVRCamera
  31145. */
  31146. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  31147. /**
  31148. * Gets the device distance from the ground in meters.
  31149. * @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.
  31150. */
  31151. deviceDistanceToRoomGround(): number;
  31152. /**
  31153. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  31154. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  31155. */
  31156. useStandingMatrix(callback?: (bool: boolean) => void): void;
  31157. /**
  31158. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  31159. * @returns A promise with a boolean set to if the standing matrix is supported.
  31160. */
  31161. useStandingMatrixAsync(): Promise<boolean>;
  31162. /**
  31163. * Disposes the camera
  31164. */
  31165. dispose(): void;
  31166. /**
  31167. * Gets a vrController by name.
  31168. * @param name The name of the controller to retreive
  31169. * @returns the controller matching the name specified or null if not found
  31170. */
  31171. getControllerByName(name: string): Nullable<WebVRController>;
  31172. private _leftController;
  31173. /**
  31174. * The controller corrisponding to the users left hand.
  31175. */
  31176. readonly leftController: Nullable<WebVRController>;
  31177. private _rightController;
  31178. /**
  31179. * The controller corrisponding to the users right hand.
  31180. */
  31181. readonly rightController: Nullable<WebVRController>;
  31182. /**
  31183. * Casts a ray forward from the vrCamera's gaze.
  31184. * @param length Length of the ray (default: 100)
  31185. * @returns the ray corrisponding to the gaze
  31186. */
  31187. getForwardRay(length?: number): Ray;
  31188. /**
  31189. * Updates the camera based on device's frame data
  31190. */
  31191. _checkInputs(): void;
  31192. /**
  31193. * Updates the poseControlled values based on the input device pose.
  31194. * @param poseData Pose coming from the device
  31195. */
  31196. updateFromDevice(poseData: DevicePose): void;
  31197. /**
  31198. * WebVR's attach control will start broadcasting frames to the device.
  31199. * Note that in certain browsers (chrome for example) this function must be called
  31200. * within a user-interaction callback. Example:
  31201. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  31202. *
  31203. * @param element html element to attach the vrDevice to
  31204. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  31205. */
  31206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31207. /**
  31208. * Detaches the camera from the html element and disables VR
  31209. *
  31210. * @param element html element to detach from
  31211. */
  31212. detachControl(element: HTMLElement): void;
  31213. /**
  31214. * @returns the name of this class
  31215. */
  31216. getClassName(): string;
  31217. /**
  31218. * Calls resetPose on the vrDisplay
  31219. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  31220. */
  31221. resetToCurrentRotation(): void;
  31222. /**
  31223. * Updates the rig cameras (left and right eye)
  31224. */
  31225. _updateRigCameras(): void;
  31226. private _workingVector;
  31227. private _oneVector;
  31228. private _workingMatrix;
  31229. private updateCacheCalled;
  31230. /**
  31231. * Updates the cached values of the camera
  31232. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  31233. */
  31234. _updateCache(ignoreParentClass?: boolean): void;
  31235. /**
  31236. * Updates the current device position and rotation in the babylon world
  31237. */
  31238. update(): void;
  31239. /**
  31240. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  31241. * @returns an identity matrix
  31242. */
  31243. _getViewMatrix(): Matrix;
  31244. /**
  31245. * This function is called by the two RIG cameras.
  31246. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  31247. */
  31248. protected _getWebVRViewMatrix(): Matrix;
  31249. protected _getWebVRProjectionMatrix(): Matrix;
  31250. private _onGamepadConnectedObserver;
  31251. private _onGamepadDisconnectedObserver;
  31252. /**
  31253. * Initializes the controllers and their meshes
  31254. */
  31255. initControllers(): void;
  31256. }
  31257. }
  31258. declare module BABYLON {
  31259. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31260. camera: ArcRotateCamera;
  31261. gamepad: Nullable<Gamepad>;
  31262. private _onGamepadConnectedObserver;
  31263. private _onGamepadDisconnectedObserver;
  31264. gamepadRotationSensibility: number;
  31265. gamepadMoveSensibility: number;
  31266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31267. detachControl(element: Nullable<HTMLElement>): void;
  31268. checkInputs(): void;
  31269. getClassName(): string;
  31270. getSimpleName(): string;
  31271. }
  31272. }
  31273. declare module BABYLON {
  31274. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31275. camera: ArcRotateCamera;
  31276. private _keys;
  31277. keysUp: number[];
  31278. keysDown: number[];
  31279. keysLeft: number[];
  31280. keysRight: number[];
  31281. keysReset: number[];
  31282. panningSensibility: number;
  31283. zoomingSensibility: number;
  31284. useAltToZoom: boolean;
  31285. private _ctrlPressed;
  31286. private _altPressed;
  31287. private _onCanvasBlurObserver;
  31288. private _onKeyboardObserver;
  31289. private _engine;
  31290. private _scene;
  31291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31292. detachControl(element: Nullable<HTMLElement>): void;
  31293. checkInputs(): void;
  31294. getClassName(): string;
  31295. getSimpleName(): string;
  31296. }
  31297. }
  31298. declare module BABYLON {
  31299. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31300. camera: ArcRotateCamera;
  31301. private _wheel;
  31302. private _observer;
  31303. wheelPrecision: number;
  31304. /**
  31305. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31306. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31307. */
  31308. wheelDeltaPercentage: number;
  31309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31310. detachControl(element: Nullable<HTMLElement>): void;
  31311. getClassName(): string;
  31312. getSimpleName(): string;
  31313. }
  31314. }
  31315. declare module BABYLON {
  31316. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31317. camera: ArcRotateCamera;
  31318. buttons: number[];
  31319. angularSensibilityX: number;
  31320. angularSensibilityY: number;
  31321. pinchPrecision: number;
  31322. /**
  31323. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31324. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31325. */
  31326. pinchDeltaPercentage: number;
  31327. panningSensibility: number;
  31328. multiTouchPanning: boolean;
  31329. multiTouchPanAndZoom: boolean;
  31330. private _isPanClick;
  31331. pinchInwards: boolean;
  31332. private _pointerInput;
  31333. private _observer;
  31334. private _onMouseMove;
  31335. private _onGestureStart;
  31336. private _onGesture;
  31337. private _MSGestureHandler;
  31338. private _onLostFocus;
  31339. private _onContextMenu;
  31340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31341. detachControl(element: Nullable<HTMLElement>): void;
  31342. getClassName(): string;
  31343. getSimpleName(): string;
  31344. }
  31345. }
  31346. declare module BABYLON {
  31347. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  31348. camera: ArcRotateCamera;
  31349. alphaCorrection: number;
  31350. betaCorrection: number;
  31351. gammaCorrection: number;
  31352. private _alpha;
  31353. private _gamma;
  31354. private _dirty;
  31355. private _deviceOrientationHandler;
  31356. constructor();
  31357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31358. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  31359. checkInputs(): void;
  31360. detachControl(element: Nullable<HTMLElement>): void;
  31361. getClassName(): string;
  31362. getSimpleName(): string;
  31363. }
  31364. }
  31365. declare module BABYLON {
  31366. /**
  31367. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  31368. * Screen rotation is taken into account.
  31369. */
  31370. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  31371. private _camera;
  31372. private _screenOrientationAngle;
  31373. private _constantTranform;
  31374. private _screenQuaternion;
  31375. private _alpha;
  31376. private _beta;
  31377. private _gamma;
  31378. constructor();
  31379. camera: FreeCamera;
  31380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31381. private _orientationChanged;
  31382. private _deviceOrientation;
  31383. detachControl(element: Nullable<HTMLElement>): void;
  31384. checkInputs(): void;
  31385. getClassName(): string;
  31386. getSimpleName(): string;
  31387. }
  31388. }
  31389. declare module BABYLON {
  31390. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  31391. camera: FreeCamera;
  31392. gamepad: Nullable<Gamepad>;
  31393. private _onGamepadConnectedObserver;
  31394. private _onGamepadDisconnectedObserver;
  31395. gamepadAngularSensibility: number;
  31396. gamepadMoveSensibility: number;
  31397. private _cameraTransform;
  31398. private _deltaTransform;
  31399. private _vector3;
  31400. private _vector2;
  31401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31402. detachControl(element: Nullable<HTMLElement>): void;
  31403. checkInputs(): void;
  31404. getClassName(): string;
  31405. getSimpleName(): string;
  31406. }
  31407. }
  31408. declare module BABYLON {
  31409. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  31410. camera: FreeCamera;
  31411. private _keys;
  31412. private _onCanvasBlurObserver;
  31413. private _onKeyboardObserver;
  31414. private _engine;
  31415. private _scene;
  31416. keysUp: number[];
  31417. keysDown: number[];
  31418. keysLeft: number[];
  31419. keysRight: number[];
  31420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31421. detachControl(element: Nullable<HTMLElement>): void;
  31422. checkInputs(): void;
  31423. getClassName(): string;
  31424. _onLostFocus(e: FocusEvent): void;
  31425. getSimpleName(): string;
  31426. }
  31427. }
  31428. declare module BABYLON {
  31429. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  31430. touchEnabled: boolean;
  31431. camera: FreeCamera;
  31432. buttons: number[];
  31433. angularSensibility: number;
  31434. private _pointerInput;
  31435. private _onMouseMove;
  31436. private _observer;
  31437. private previousPosition;
  31438. constructor(touchEnabled?: boolean);
  31439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31440. detachControl(element: Nullable<HTMLElement>): void;
  31441. getClassName(): string;
  31442. getSimpleName(): string;
  31443. }
  31444. }
  31445. declare module BABYLON {
  31446. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  31447. camera: FreeCamera;
  31448. private _offsetX;
  31449. private _offsetY;
  31450. private _pointerPressed;
  31451. private _pointerInput;
  31452. private _observer;
  31453. private _onLostFocus;
  31454. touchAngularSensibility: number;
  31455. touchMoveSensibility: number;
  31456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31457. detachControl(element: Nullable<HTMLElement>): void;
  31458. checkInputs(): void;
  31459. getClassName(): string;
  31460. getSimpleName(): string;
  31461. }
  31462. }
  31463. declare module BABYLON {
  31464. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  31465. camera: FreeCamera;
  31466. private _leftjoystick;
  31467. private _rightjoystick;
  31468. getLeftJoystick(): VirtualJoystick;
  31469. getRightJoystick(): VirtualJoystick;
  31470. checkInputs(): void;
  31471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31472. detachControl(element: Nullable<HTMLElement>): void;
  31473. getClassName(): string;
  31474. getSimpleName(): string;
  31475. }
  31476. }
  31477. declare module BABYLON {
  31478. interface IOctreeContainer<T> {
  31479. blocks: Array<OctreeBlock<T>>;
  31480. }
  31481. class Octree<T> {
  31482. maxDepth: number;
  31483. blocks: Array<OctreeBlock<T>>;
  31484. dynamicContent: T[];
  31485. private _maxBlockCapacity;
  31486. private _selectionContent;
  31487. private _creationFunc;
  31488. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  31489. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  31490. addMesh(entry: T): void;
  31491. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  31492. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  31493. intersectsRay(ray: Ray): SmartArray<T>;
  31494. 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;
  31495. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  31496. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  31497. }
  31498. }
  31499. declare module BABYLON {
  31500. class OctreeBlock<T> {
  31501. entries: T[];
  31502. blocks: Array<OctreeBlock<T>>;
  31503. private _depth;
  31504. private _maxDepth;
  31505. private _capacity;
  31506. private _minPoint;
  31507. private _maxPoint;
  31508. private _boundingVectors;
  31509. private _creationFunc;
  31510. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  31511. readonly capacity: number;
  31512. readonly minPoint: Vector3;
  31513. readonly maxPoint: Vector3;
  31514. addEntry(entry: T): void;
  31515. addEntries(entries: T[]): void;
  31516. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31517. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31518. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  31519. createInnerBlocks(): void;
  31520. }
  31521. }
  31522. declare module BABYLON {
  31523. /**
  31524. * Google Daydream controller
  31525. */
  31526. class DaydreamController extends WebVRController {
  31527. /**
  31528. * Base Url for the controller model.
  31529. */
  31530. static MODEL_BASE_URL: string;
  31531. /**
  31532. * File name for the controller model.
  31533. */
  31534. static MODEL_FILENAME: string;
  31535. /**
  31536. * Gamepad Id prefix used to identify Daydream Controller.
  31537. */
  31538. static readonly GAMEPAD_ID_PREFIX: string;
  31539. /**
  31540. * Creates a new DaydreamController from a gamepad
  31541. * @param vrGamepad the gamepad that the controller should be created from
  31542. */
  31543. constructor(vrGamepad: any);
  31544. /**
  31545. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31546. * @param scene scene in which to add meshes
  31547. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31548. */
  31549. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31550. /**
  31551. * Called once for each button that changed state since the last frame
  31552. * @param buttonIdx Which button index changed
  31553. * @param state New state of the button
  31554. * @param changes Which properties on the state changed since last frame
  31555. */
  31556. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31557. }
  31558. }
  31559. declare module BABYLON {
  31560. /**
  31561. * Gear VR Controller
  31562. */
  31563. class GearVRController extends WebVRController {
  31564. /**
  31565. * Base Url for the controller model.
  31566. */
  31567. static MODEL_BASE_URL: string;
  31568. /**
  31569. * File name for the controller model.
  31570. */
  31571. static MODEL_FILENAME: string;
  31572. /**
  31573. * Gamepad Id prefix used to identify this controller.
  31574. */
  31575. static readonly GAMEPAD_ID_PREFIX: string;
  31576. private readonly _buttonIndexToObservableNameMap;
  31577. /**
  31578. * Creates a new GearVRController from a gamepad
  31579. * @param vrGamepad the gamepad that the controller should be created from
  31580. */
  31581. constructor(vrGamepad: any);
  31582. /**
  31583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31584. * @param scene scene in which to add meshes
  31585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31586. */
  31587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31588. /**
  31589. * Called once for each button that changed state since the last frame
  31590. * @param buttonIdx Which button index changed
  31591. * @param state New state of the button
  31592. * @param changes Which properties on the state changed since last frame
  31593. */
  31594. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31595. }
  31596. }
  31597. declare module BABYLON {
  31598. /**
  31599. * Generic Controller
  31600. */
  31601. class GenericController extends WebVRController {
  31602. /**
  31603. * Base Url for the controller model.
  31604. */
  31605. static readonly MODEL_BASE_URL: string;
  31606. /**
  31607. * File name for the controller model.
  31608. */
  31609. static readonly MODEL_FILENAME: string;
  31610. /**
  31611. * Creates a new GenericController from a gamepad
  31612. * @param vrGamepad the gamepad that the controller should be created from
  31613. */
  31614. constructor(vrGamepad: any);
  31615. /**
  31616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31617. * @param scene scene in which to add meshes
  31618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31619. */
  31620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31621. /**
  31622. * Called once for each button that changed state since the last frame
  31623. * @param buttonIdx Which button index changed
  31624. * @param state New state of the button
  31625. * @param changes Which properties on the state changed since last frame
  31626. */
  31627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31628. }
  31629. }
  31630. declare module BABYLON {
  31631. /**
  31632. * Oculus Touch Controller
  31633. */
  31634. class OculusTouchController extends WebVRController {
  31635. /**
  31636. * Base Url for the controller model.
  31637. */
  31638. static MODEL_BASE_URL: string;
  31639. /**
  31640. * File name for the left controller model.
  31641. */
  31642. static MODEL_LEFT_FILENAME: string;
  31643. /**
  31644. * File name for the right controller model.
  31645. */
  31646. static MODEL_RIGHT_FILENAME: string;
  31647. /**
  31648. * Fired when the secondary trigger on this controller is modified
  31649. */
  31650. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31651. /**
  31652. * Fired when the thumb rest on this controller is modified
  31653. */
  31654. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  31655. /**
  31656. * Creates a new OculusTouchController from a gamepad
  31657. * @param vrGamepad the gamepad that the controller should be created from
  31658. */
  31659. constructor(vrGamepad: any);
  31660. /**
  31661. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31662. * @param scene scene in which to add meshes
  31663. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31664. */
  31665. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31666. /**
  31667. * Fired when the A button on this controller is modified
  31668. */
  31669. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31670. /**
  31671. * Fired when the B button on this controller is modified
  31672. */
  31673. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31674. /**
  31675. * Fired when the X button on this controller is modified
  31676. */
  31677. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31678. /**
  31679. * Fired when the Y button on this controller is modified
  31680. */
  31681. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31682. /**
  31683. * Called once for each button that changed state since the last frame
  31684. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  31685. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  31686. * 2) secondary trigger (same)
  31687. * 3) A (right) X (left), touch, pressed = value
  31688. * 4) B / Y
  31689. * 5) thumb rest
  31690. * @param buttonIdx Which button index changed
  31691. * @param state New state of the button
  31692. * @param changes Which properties on the state changed since last frame
  31693. */
  31694. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31695. }
  31696. }
  31697. declare module BABYLON {
  31698. /**
  31699. * Defines the types of pose enabled controllers that are supported
  31700. */
  31701. enum PoseEnabledControllerType {
  31702. /**
  31703. * HTC Vive
  31704. */
  31705. VIVE = 0,
  31706. /**
  31707. * Oculus Rift
  31708. */
  31709. OCULUS = 1,
  31710. /**
  31711. * Windows mixed reality
  31712. */
  31713. WINDOWS = 2,
  31714. /**
  31715. * Samsung gear VR
  31716. */
  31717. GEAR_VR = 3,
  31718. /**
  31719. * Google Daydream
  31720. */
  31721. DAYDREAM = 4,
  31722. /**
  31723. * Generic
  31724. */
  31725. GENERIC = 5,
  31726. }
  31727. /**
  31728. * Defines the MutableGamepadButton interface for the state of a gamepad button
  31729. */
  31730. interface MutableGamepadButton {
  31731. /**
  31732. * Value of the button/trigger
  31733. */
  31734. value: number;
  31735. /**
  31736. * If the button/trigger is currently touched
  31737. */
  31738. touched: boolean;
  31739. /**
  31740. * If the button/trigger is currently pressed
  31741. */
  31742. pressed: boolean;
  31743. }
  31744. /**
  31745. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  31746. * @hidden
  31747. */
  31748. interface ExtendedGamepadButton extends GamepadButton {
  31749. /**
  31750. * If the button/trigger is currently pressed
  31751. */
  31752. readonly pressed: boolean;
  31753. /**
  31754. * If the button/trigger is currently touched
  31755. */
  31756. readonly touched: boolean;
  31757. /**
  31758. * Value of the button/trigger
  31759. */
  31760. readonly value: number;
  31761. }
  31762. /**
  31763. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31764. */
  31765. class PoseEnabledControllerHelper {
  31766. /**
  31767. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  31768. * @param vrGamepad the gamepad to initialized
  31769. * @returns a vr controller of the type the gamepad identified as
  31770. */
  31771. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  31772. }
  31773. /**
  31774. * Defines the PoseEnabledController object that contains state of a vr capable controller
  31775. */
  31776. class PoseEnabledController extends Gamepad implements PoseControlled {
  31777. private _deviceRoomPosition;
  31778. private _deviceRoomRotationQuaternion;
  31779. /**
  31780. * The device position in babylon space
  31781. */
  31782. devicePosition: Vector3;
  31783. /**
  31784. * The device rotation in babylon space
  31785. */
  31786. deviceRotationQuaternion: Quaternion;
  31787. /**
  31788. * The scale factor of the device in babylon space
  31789. */
  31790. deviceScaleFactor: number;
  31791. /**
  31792. * (Likely devicePosition should be used instead) The device position in its room space
  31793. */
  31794. position: Vector3;
  31795. /**
  31796. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  31797. */
  31798. rotationQuaternion: Quaternion;
  31799. /**
  31800. * The type of controller (Eg. Windows mixed reality)
  31801. */
  31802. controllerType: PoseEnabledControllerType;
  31803. protected _calculatedPosition: Vector3;
  31804. private _calculatedRotation;
  31805. /**
  31806. * The raw pose from the device
  31807. */
  31808. rawPose: DevicePose;
  31809. /**
  31810. * Internal, the mesh attached to the controller
  31811. */
  31812. _mesh: Nullable<AbstractMesh>;
  31813. private _poseControlledCamera;
  31814. private _leftHandSystemQuaternion;
  31815. /**
  31816. * Internal, matrix used to convert room space to babylon space
  31817. */
  31818. _deviceToWorld: Matrix;
  31819. /**
  31820. * Node to be used when casting a ray from the controller
  31821. */
  31822. _pointingPoseNode: Nullable<AbstractMesh>;
  31823. /**
  31824. * Name of the child mesh that can be used to cast a ray from the controller
  31825. */
  31826. static readonly POINTING_POSE: string;
  31827. /**
  31828. * Creates a new PoseEnabledController from a gamepad
  31829. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  31830. */
  31831. constructor(browserGamepad: any);
  31832. private _workingMatrix;
  31833. /**
  31834. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  31835. */
  31836. update(): void;
  31837. /**
  31838. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  31839. * @param poseData raw pose fromthe device
  31840. */
  31841. updateFromDevice(poseData: DevicePose): void;
  31842. /**
  31843. * @hidden
  31844. */
  31845. _meshAttachedObservable: Observable<AbstractMesh>;
  31846. /**
  31847. * Attaches a mesh to the controller
  31848. * @param mesh the mesh to be attached
  31849. */
  31850. attachToMesh(mesh: AbstractMesh): void;
  31851. /**
  31852. * Attaches the controllers mesh to a camera
  31853. * @param camera the camera the mesh should be attached to
  31854. */
  31855. attachToPoseControlledCamera(camera: TargetCamera): void;
  31856. /**
  31857. * Disposes of the controller
  31858. */
  31859. dispose(): void;
  31860. /**
  31861. * The mesh that is attached to the controller
  31862. */
  31863. readonly mesh: Nullable<AbstractMesh>;
  31864. /**
  31865. * Gets the ray of the controller in the direction the controller is pointing
  31866. * @param length the length the resulting ray should be
  31867. * @returns a ray in the direction the controller is pointing
  31868. */
  31869. getForwardRay(length?: number): Ray;
  31870. }
  31871. }
  31872. declare module BABYLON {
  31873. /**
  31874. * Vive Controller
  31875. */
  31876. class ViveController extends WebVRController {
  31877. /**
  31878. * Base Url for the controller model.
  31879. */
  31880. static MODEL_BASE_URL: string;
  31881. /**
  31882. * File name for the controller model.
  31883. */
  31884. static MODEL_FILENAME: string;
  31885. /**
  31886. * Creates a new ViveController from a gamepad
  31887. * @param vrGamepad the gamepad that the controller should be created from
  31888. */
  31889. constructor(vrGamepad: any);
  31890. /**
  31891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31892. * @param scene scene in which to add meshes
  31893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31894. */
  31895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31896. /**
  31897. * Fired when the left button on this controller is modified
  31898. */
  31899. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31900. /**
  31901. * Fired when the right button on this controller is modified
  31902. */
  31903. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31904. /**
  31905. * Fired when the menu button on this controller is modified
  31906. */
  31907. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31908. /**
  31909. * Called once for each button that changed state since the last frame
  31910. * Vive mapping:
  31911. * 0: touchpad
  31912. * 1: trigger
  31913. * 2: left AND right buttons
  31914. * 3: menu button
  31915. * @param buttonIdx Which button index changed
  31916. * @param state New state of the button
  31917. * @param changes Which properties on the state changed since last frame
  31918. */
  31919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31920. }
  31921. }
  31922. declare module BABYLON {
  31923. /**
  31924. * Defines the WebVRController object that represents controllers tracked in 3D space
  31925. */
  31926. abstract class WebVRController extends PoseEnabledController {
  31927. /**
  31928. * Internal, the default controller model for the controller
  31929. */
  31930. protected _defaultModel: AbstractMesh;
  31931. /**
  31932. * Fired when the trigger state has changed
  31933. */
  31934. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31935. /**
  31936. * Fired when the main button state has changed
  31937. */
  31938. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31939. /**
  31940. * Fired when the secondary button state has changed
  31941. */
  31942. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31943. /**
  31944. * Fired when the pad state has changed
  31945. */
  31946. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  31947. /**
  31948. * Fired when controllers stick values have changed
  31949. */
  31950. onPadValuesChangedObservable: Observable<StickValues>;
  31951. /**
  31952. * Array of button availible on the controller
  31953. */
  31954. protected _buttons: Array<MutableGamepadButton>;
  31955. private _onButtonStateChange;
  31956. /**
  31957. * Fired when a controller button's state has changed
  31958. * @param callback the callback containing the button that was modified
  31959. */
  31960. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  31961. /**
  31962. * X and Y axis corrisponding to the controllers joystick
  31963. */
  31964. pad: StickValues;
  31965. /**
  31966. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31967. */
  31968. hand: string;
  31969. /**
  31970. * The default controller model for the controller
  31971. */
  31972. readonly defaultModel: AbstractMesh;
  31973. /**
  31974. * Creates a new WebVRController from a gamepad
  31975. * @param vrGamepad the gamepad that the WebVRController should be created from
  31976. */
  31977. constructor(vrGamepad: any);
  31978. /**
  31979. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31980. */
  31981. update(): void;
  31982. /**
  31983. * Function to be called when a button is modified
  31984. */
  31985. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31986. /**
  31987. * Loads a mesh and attaches it to the controller
  31988. * @param scene the scene the mesh should be added to
  31989. * @param meshLoaded callback for when the mesh has been loaded
  31990. */
  31991. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31992. private _setButtonValue(newState, currentState, buttonIndex);
  31993. private _changes;
  31994. private _checkChanges(newState, currentState);
  31995. /**
  31996. * Disposes of th webVRCOntroller
  31997. */
  31998. dispose(): void;
  31999. }
  32000. }
  32001. declare module BABYLON {
  32002. /**
  32003. * Defines the WindowsMotionController object that the state of the windows motion controller
  32004. */
  32005. class WindowsMotionController extends WebVRController {
  32006. /**
  32007. * The base url used to load the left and right controller models
  32008. */
  32009. static MODEL_BASE_URL: string;
  32010. /**
  32011. * The name of the left controller model file
  32012. */
  32013. static MODEL_LEFT_FILENAME: string;
  32014. /**
  32015. * The name of the right controller model file
  32016. */
  32017. static MODEL_RIGHT_FILENAME: string;
  32018. /**
  32019. * The controller name prefix for this controller type
  32020. */
  32021. static readonly GAMEPAD_ID_PREFIX: string;
  32022. /**
  32023. * The controller id pattern for this controller type
  32024. */
  32025. private static readonly GAMEPAD_ID_PATTERN;
  32026. private _loadedMeshInfo;
  32027. private readonly _mapping;
  32028. /**
  32029. * Fired when the trackpad on this controller is clicked
  32030. */
  32031. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  32032. /**
  32033. * Fired when the trackpad on this controller is modified
  32034. */
  32035. onTrackpadValuesChangedObservable: Observable<StickValues>;
  32036. /**
  32037. * The current x and y values of this controller's trackpad
  32038. */
  32039. trackpad: StickValues;
  32040. /**
  32041. * Creates a new WindowsMotionController from a gamepad
  32042. * @param vrGamepad the gamepad that the controller should be created from
  32043. */
  32044. constructor(vrGamepad: any);
  32045. /**
  32046. * Fired when the trigger on this controller is modified
  32047. */
  32048. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32049. /**
  32050. * Fired when the menu button on this controller is modified
  32051. */
  32052. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32053. /**
  32054. * Fired when the grip button on this controller is modified
  32055. */
  32056. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32057. /**
  32058. * Fired when the thumbstick button on this controller is modified
  32059. */
  32060. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32061. /**
  32062. * Fired when the touchpad button on this controller is modified
  32063. */
  32064. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32065. /**
  32066. * Fired when the touchpad values on this controller are modified
  32067. */
  32068. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  32069. private _updateTrackpad();
  32070. /**
  32071. * Called once per frame by the engine.
  32072. */
  32073. update(): void;
  32074. /**
  32075. * Called once for each button that changed state since the last frame
  32076. * @param buttonIdx Which button index changed
  32077. * @param state New state of the button
  32078. * @param changes Which properties on the state changed since last frame
  32079. */
  32080. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32081. /**
  32082. * Moves the buttons on the controller mesh based on their current state
  32083. * @param buttonName the name of the button to move
  32084. * @param buttonValue the value of the button which determines the buttons new position
  32085. */
  32086. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  32087. /**
  32088. * Moves the axis on the controller mesh based on its current state
  32089. * @param axis the index of the axis
  32090. * @param axisValue the value of the axis which determines the meshes new position
  32091. * @hidden
  32092. */
  32093. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  32094. /**
  32095. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32096. * @param scene scene in which to add meshes
  32097. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32098. */
  32099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  32100. /**
  32101. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  32102. * can be transformed by button presses and axes values, based on this._mapping.
  32103. *
  32104. * @param scene scene in which the meshes exist
  32105. * @param meshes list of meshes that make up the controller model to process
  32106. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  32107. */
  32108. private processModel(scene, meshes);
  32109. private createMeshInfo(rootNode);
  32110. /**
  32111. * Gets the ray of the controller in the direction the controller is pointing
  32112. * @param length the length the resulting ray should be
  32113. * @returns a ray in the direction the controller is pointing
  32114. */
  32115. getForwardRay(length?: number): Ray;
  32116. /**
  32117. * Disposes of the controller
  32118. */
  32119. dispose(): void;
  32120. }
  32121. }
  32122. declare module BABYLON {
  32123. /**
  32124. * Interface to implement to create a shadow generator compatible with BJS.
  32125. */
  32126. interface IShadowGenerator {
  32127. /**
  32128. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32129. * @returns The render target texture if present otherwise, null
  32130. */
  32131. getShadowMap(): Nullable<RenderTargetTexture>;
  32132. /**
  32133. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32134. * @returns The render target texture if the shadow map is present otherwise, null
  32135. */
  32136. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32137. /**
  32138. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32139. * @param subMesh The submesh we want to render in the shadow map
  32140. * @param useInstances Defines wether will draw in the map using instances
  32141. * @returns true if ready otherwise, false
  32142. */
  32143. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32144. /**
  32145. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32146. * @param defines Defines of the material we want to update
  32147. * @param lightIndex Index of the light in the enabled light list of the material
  32148. */
  32149. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  32150. /**
  32151. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32152. * defined in the generator but impacting the effect).
  32153. * It implies the unifroms available on the materials are the standard BJS ones.
  32154. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32155. * @param effect The effect we are binfing the information for
  32156. */
  32157. bindShadowLight(lightIndex: string, effect: Effect): void;
  32158. /**
  32159. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32160. * (eq to shadow prjection matrix * light transform matrix)
  32161. * @returns The transform matrix used to create the shadow map
  32162. */
  32163. getTransformMatrix(): Matrix;
  32164. /**
  32165. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32166. * Cube and 2D textures for instance.
  32167. */
  32168. recreateShadowMap(): void;
  32169. /**
  32170. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32171. * @param onCompiled Callback triggered at the and of the effects compilation
  32172. * @param options Sets of optional options forcing the compilation with different modes
  32173. */
  32174. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32175. useInstances: boolean;
  32176. }>): void;
  32177. /**
  32178. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32179. * @param options Sets of optional options forcing the compilation with different modes
  32180. * @returns A promise that resolves when the compilation completes
  32181. */
  32182. forceCompilationAsync(options?: Partial<{
  32183. useInstances: boolean;
  32184. }>): Promise<void>;
  32185. /**
  32186. * Serializes the shadow generator setup to a json object.
  32187. * @returns The serialized JSON object
  32188. */
  32189. serialize(): any;
  32190. /**
  32191. * Disposes the Shadow map and related Textures and effects.
  32192. */
  32193. dispose(): void;
  32194. }
  32195. /**
  32196. * Default implementation IShadowGenerator.
  32197. * This is the main object responsible of generating shadows in the framework.
  32198. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  32199. */
  32200. class ShadowGenerator implements IShadowGenerator {
  32201. /**
  32202. * Shadow generator mode None: no filtering applied.
  32203. */
  32204. static readonly FILTER_NONE: number;
  32205. /**
  32206. * Shadow generator mode ESM: Exponential Shadow Mapping.
  32207. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32208. */
  32209. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  32210. /**
  32211. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  32212. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  32213. */
  32214. static readonly FILTER_POISSONSAMPLING: number;
  32215. /**
  32216. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  32217. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32218. */
  32219. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  32220. /**
  32221. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  32222. * edge artifacts on steep falloff.
  32223. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32224. */
  32225. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  32226. /**
  32227. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  32228. * edge artifacts on steep falloff.
  32229. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32230. */
  32231. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  32232. /**
  32233. * Shadow generator mode PCF: Percentage Closer Filtering
  32234. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  32235. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  32236. */
  32237. static readonly FILTER_PCF: number;
  32238. /**
  32239. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  32240. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  32241. * Contact Hardening
  32242. */
  32243. static readonly FILTER_PCSS: number;
  32244. /**
  32245. * Reserved for PCF and PCSS
  32246. * Highest Quality.
  32247. *
  32248. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  32249. *
  32250. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  32251. */
  32252. static readonly QUALITY_HIGH: number;
  32253. /**
  32254. * Reserved for PCF and PCSS
  32255. * Good tradeoff for quality/perf cross devices
  32256. *
  32257. * Execute PCF on a 3*3 kernel.
  32258. *
  32259. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  32260. */
  32261. static readonly QUALITY_MEDIUM: number;
  32262. /**
  32263. * Reserved for PCF and PCSS
  32264. * The lowest quality but the fastest.
  32265. *
  32266. * Execute PCF on a 1*1 kernel.
  32267. *
  32268. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  32269. */
  32270. static readonly QUALITY_LOW: number;
  32271. private _bias;
  32272. /**
  32273. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  32274. */
  32275. /**
  32276. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  32277. */
  32278. bias: number;
  32279. private _normalBias;
  32280. /**
  32281. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  32282. */
  32283. /**
  32284. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  32285. */
  32286. normalBias: number;
  32287. private _blurBoxOffset;
  32288. /**
  32289. * Gets the blur box offset: offset applied during the blur pass.
  32290. * Only usefull if useKernelBlur = false
  32291. */
  32292. /**
  32293. * Sets the blur box offset: offset applied during the blur pass.
  32294. * Only usefull if useKernelBlur = false
  32295. */
  32296. blurBoxOffset: number;
  32297. private _blurScale;
  32298. /**
  32299. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  32300. * 2 means half of the size.
  32301. */
  32302. /**
  32303. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  32304. * 2 means half of the size.
  32305. */
  32306. blurScale: number;
  32307. private _blurKernel;
  32308. /**
  32309. * Gets the blur kernel: kernel size of the blur pass.
  32310. * Only usefull if useKernelBlur = true
  32311. */
  32312. /**
  32313. * Sets the blur kernel: kernel size of the blur pass.
  32314. * Only usefull if useKernelBlur = true
  32315. */
  32316. blurKernel: number;
  32317. private _useKernelBlur;
  32318. /**
  32319. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  32320. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  32321. */
  32322. /**
  32323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  32324. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  32325. */
  32326. useKernelBlur: boolean;
  32327. private _depthScale;
  32328. /**
  32329. * Gets the depth scale used in ESM mode.
  32330. */
  32331. /**
  32332. * Sets the depth scale used in ESM mode.
  32333. * This can override the scale stored on the light.
  32334. */
  32335. depthScale: number;
  32336. private _filter;
  32337. /**
  32338. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  32339. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  32340. */
  32341. /**
  32342. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  32343. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  32344. */
  32345. filter: number;
  32346. /**
  32347. * Gets if the current filter is set to Poisson Sampling.
  32348. */
  32349. /**
  32350. * Sets the current filter to Poisson Sampling.
  32351. */
  32352. usePoissonSampling: boolean;
  32353. /**
  32354. * Gets if the current filter is set to VSM.
  32355. * DEPRECATED. Should use useExponentialShadowMap instead.
  32356. */
  32357. /**
  32358. * Sets the current filter is to VSM.
  32359. * DEPRECATED. Should use useExponentialShadowMap instead.
  32360. */
  32361. useVarianceShadowMap: boolean;
  32362. /**
  32363. * Gets if the current filter is set to blurred VSM.
  32364. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  32365. */
  32366. /**
  32367. * Sets the current filter is to blurred VSM.
  32368. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  32369. */
  32370. useBlurVarianceShadowMap: boolean;
  32371. /**
  32372. * Gets if the current filter is set to ESM.
  32373. */
  32374. /**
  32375. * Sets the current filter is to ESM.
  32376. */
  32377. useExponentialShadowMap: boolean;
  32378. /**
  32379. * Gets if the current filter is set to filtered ESM.
  32380. */
  32381. /**
  32382. * Gets if the current filter is set to filtered ESM.
  32383. */
  32384. useBlurExponentialShadowMap: boolean;
  32385. /**
  32386. * Gets if the current filter is set to "close ESM" (using the inverse of the
  32387. * exponential to prevent steep falloff artifacts).
  32388. */
  32389. /**
  32390. * Sets the current filter to "close ESM" (using the inverse of the
  32391. * exponential to prevent steep falloff artifacts).
  32392. */
  32393. useCloseExponentialShadowMap: boolean;
  32394. /**
  32395. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  32396. * exponential to prevent steep falloff artifacts).
  32397. */
  32398. /**
  32399. * Sets the current filter to filtered "close ESM" (using the inverse of the
  32400. * exponential to prevent steep falloff artifacts).
  32401. */
  32402. useBlurCloseExponentialShadowMap: boolean;
  32403. /**
  32404. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  32405. */
  32406. /**
  32407. * Sets the current filter to "PCF" (percentage closer filtering).
  32408. */
  32409. usePercentageCloserFiltering: boolean;
  32410. private _filteringQuality;
  32411. /**
  32412. * Gets the PCF or PCSS Quality.
  32413. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  32414. */
  32415. /**
  32416. * Sets the PCF or PCSS Quality.
  32417. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  32418. */
  32419. filteringQuality: number;
  32420. /**
  32421. * Gets if the current filter is set to "PCSS" (contact hardening).
  32422. */
  32423. /**
  32424. * Sets the current filter to "PCSS" (contact hardening).
  32425. */
  32426. useContactHardeningShadow: boolean;
  32427. private _contactHardeningLightSizeUVRatio;
  32428. /**
  32429. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  32430. * Using a ratio helps keeping shape stability independently of the map size.
  32431. *
  32432. * It does not account for the light projection as it was having too much
  32433. * instability during the light setup or during light position changes.
  32434. *
  32435. * Only valid if useContactHardeningShadow is true.
  32436. */
  32437. /**
  32438. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  32439. * Using a ratio helps keeping shape stability independently of the map size.
  32440. *
  32441. * It does not account for the light projection as it was having too much
  32442. * instability during the light setup or during light position changes.
  32443. *
  32444. * Only valid if useContactHardeningShadow is true.
  32445. */
  32446. contactHardeningLightSizeUVRatio: number;
  32447. private _darkness;
  32448. /**
  32449. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  32450. * 0 means strongest and 1 would means no shadow.
  32451. * @returns the darkness.
  32452. */
  32453. getDarkness(): number;
  32454. /**
  32455. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  32456. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  32457. * @returns the shadow generator allowing fluent coding.
  32458. */
  32459. setDarkness(darkness: number): ShadowGenerator;
  32460. private _transparencyShadow;
  32461. /**
  32462. * Sets the ability to have transparent shadow (boolean).
  32463. * @param transparent True if transparent else False
  32464. * @returns the shadow generator allowing fluent coding
  32465. */
  32466. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  32467. private _shadowMap;
  32468. private _shadowMap2;
  32469. /**
  32470. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32471. * @returns The render target texture if present otherwise, null
  32472. */
  32473. getShadowMap(): Nullable<RenderTargetTexture>;
  32474. /**
  32475. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32476. * @returns The render target texture if the shadow map is present otherwise, null
  32477. */
  32478. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32479. /**
  32480. * Helper function to add a mesh and its descendants to the list of shadow casters.
  32481. * @param mesh Mesh to add
  32482. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  32483. * @returns the Shadow Generator itself
  32484. */
  32485. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32486. /**
  32487. * Helper function to remove a mesh and its descendants from the list of shadow casters
  32488. * @param mesh Mesh to remove
  32489. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  32490. * @returns the Shadow Generator itself
  32491. */
  32492. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32493. /**
  32494. * Controls the extent to which the shadows fade out at the edge of the frustum
  32495. * Used only by directionals and spots
  32496. */
  32497. frustumEdgeFalloff: number;
  32498. private _light;
  32499. /**
  32500. * Returns the associated light object.
  32501. * @returns the light generating the shadow
  32502. */
  32503. getLight(): IShadowLight;
  32504. /**
  32505. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  32506. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  32507. * It might on the other hand introduce peter panning.
  32508. */
  32509. forceBackFacesOnly: boolean;
  32510. private _scene;
  32511. private _lightDirection;
  32512. private _effect;
  32513. private _viewMatrix;
  32514. private _projectionMatrix;
  32515. private _transformMatrix;
  32516. private _cachedPosition;
  32517. private _cachedDirection;
  32518. private _cachedDefines;
  32519. private _currentRenderID;
  32520. private _boxBlurPostprocess;
  32521. private _kernelBlurXPostprocess;
  32522. private _kernelBlurYPostprocess;
  32523. private _blurPostProcesses;
  32524. private _mapSize;
  32525. private _currentFaceIndex;
  32526. private _currentFaceIndexCache;
  32527. private _textureType;
  32528. private _defaultTextureMatrix;
  32529. /**
  32530. * Creates a ShadowGenerator object.
  32531. * A ShadowGenerator is the required tool to use the shadows.
  32532. * Each light casting shadows needs to use its own ShadowGenerator.
  32533. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  32534. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  32535. * @param light The light object generating the shadows.
  32536. * @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.
  32537. */
  32538. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  32539. private _initializeGenerator();
  32540. private _initializeShadowMap();
  32541. private _initializeBlurRTTAndPostProcesses();
  32542. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  32543. private _renderSubMeshForShadowMap(subMesh);
  32544. private _applyFilterValues();
  32545. /**
  32546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32547. * @param onCompiled Callback triggered at the and of the effects compilation
  32548. * @param options Sets of optional options forcing the compilation with different modes
  32549. */
  32550. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32551. useInstances: boolean;
  32552. }>): void;
  32553. /**
  32554. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32555. * @param options Sets of optional options forcing the compilation with different modes
  32556. * @returns A promise that resolves when the compilation completes
  32557. */
  32558. forceCompilationAsync(options?: Partial<{
  32559. useInstances: boolean;
  32560. }>): Promise<void>;
  32561. /**
  32562. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32563. * @param subMesh The submesh we want to render in the shadow map
  32564. * @param useInstances Defines wether will draw in the map using instances
  32565. * @returns true if ready otherwise, false
  32566. */
  32567. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32568. /**
  32569. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32570. * @param defines Defines of the material we want to update
  32571. * @param lightIndex Index of the light in the enabled light list of the material
  32572. */
  32573. prepareDefines(defines: any, lightIndex: number): void;
  32574. /**
  32575. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32576. * defined in the generator but impacting the effect).
  32577. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32578. * @param effect The effect we are binfing the information for
  32579. */
  32580. bindShadowLight(lightIndex: string, effect: Effect): void;
  32581. /**
  32582. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32583. * (eq to shadow prjection matrix * light transform matrix)
  32584. * @returns The transform matrix used to create the shadow map
  32585. */
  32586. getTransformMatrix(): Matrix;
  32587. /**
  32588. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32589. * Cube and 2D textures for instance.
  32590. */
  32591. recreateShadowMap(): void;
  32592. private _disposeBlurPostProcesses();
  32593. private _disposeRTTandPostProcesses();
  32594. /**
  32595. * Disposes the ShadowGenerator.
  32596. * Returns nothing.
  32597. */
  32598. dispose(): void;
  32599. /**
  32600. * Serializes the shadow generator setup to a json object.
  32601. * @returns The serialized JSON object
  32602. */
  32603. serialize(): any;
  32604. /**
  32605. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  32606. * @param parsedShadowGenerator The JSON object to parse
  32607. * @param scene The scene to create the shadow map for
  32608. * @returns The parsed shadow generator
  32609. */
  32610. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  32611. }
  32612. }
  32613. declare module BABYLON {
  32614. }
  32615. declare module BABYLON {
  32616. /**
  32617. * Background material used to create an efficient environement around your scene.
  32618. */
  32619. class BackgroundMaterial extends PushMaterial {
  32620. /**
  32621. * Standard reflectance value at parallel view angle.
  32622. */
  32623. static StandardReflectance0: number;
  32624. /**
  32625. * Standard reflectance value at grazing angle.
  32626. */
  32627. static StandardReflectance90: number;
  32628. protected _primaryColor: Color3;
  32629. /**
  32630. * Key light Color (multiply against the environement texture)
  32631. */
  32632. primaryColor: Color3;
  32633. protected __perceptualColor: Nullable<Color3>;
  32634. /**
  32635. * Experimental Internal Use Only.
  32636. *
  32637. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  32638. * This acts as a helper to set the primary color to a more "human friendly" value.
  32639. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  32640. * output color as close as possible from the chosen value.
  32641. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  32642. * part of lighting setup.)
  32643. */
  32644. _perceptualColor: Nullable<Color3>;
  32645. protected _primaryColorShadowLevel: float;
  32646. /**
  32647. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  32648. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  32649. */
  32650. primaryColorShadowLevel: float;
  32651. protected _primaryColorHighlightLevel: float;
  32652. /**
  32653. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  32654. * The primary color is used at the level chosen to define what the white area would look.
  32655. */
  32656. primaryColorHighlightLevel: float;
  32657. protected _reflectionTexture: Nullable<BaseTexture>;
  32658. /**
  32659. * Reflection Texture used in the material.
  32660. * Should be author in a specific way for the best result (refer to the documentation).
  32661. */
  32662. reflectionTexture: Nullable<BaseTexture>;
  32663. protected _reflectionBlur: float;
  32664. /**
  32665. * Reflection Texture level of blur.
  32666. *
  32667. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  32668. * texture twice.
  32669. */
  32670. reflectionBlur: float;
  32671. protected _diffuseTexture: Nullable<BaseTexture>;
  32672. /**
  32673. * Diffuse Texture used in the material.
  32674. * Should be author in a specific way for the best result (refer to the documentation).
  32675. */
  32676. diffuseTexture: Nullable<BaseTexture>;
  32677. protected _shadowLights: Nullable<IShadowLight[]>;
  32678. /**
  32679. * Specify the list of lights casting shadow on the material.
  32680. * All scene shadow lights will be included if null.
  32681. */
  32682. shadowLights: Nullable<IShadowLight[]>;
  32683. protected _shadowLevel: float;
  32684. /**
  32685. * Helps adjusting the shadow to a softer level if required.
  32686. * 0 means black shadows and 1 means no shadows.
  32687. */
  32688. shadowLevel: float;
  32689. protected _sceneCenter: Vector3;
  32690. /**
  32691. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  32692. * It is usually zero but might be interesting to modify according to your setup.
  32693. */
  32694. sceneCenter: Vector3;
  32695. protected _opacityFresnel: boolean;
  32696. /**
  32697. * This helps specifying that the material is falling off to the sky box at grazing angle.
  32698. * This helps ensuring a nice transition when the camera goes under the ground.
  32699. */
  32700. opacityFresnel: boolean;
  32701. protected _reflectionFresnel: boolean;
  32702. /**
  32703. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  32704. * This helps adding a mirror texture on the ground.
  32705. */
  32706. reflectionFresnel: boolean;
  32707. protected _reflectionFalloffDistance: number;
  32708. /**
  32709. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  32710. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  32711. */
  32712. reflectionFalloffDistance: number;
  32713. protected _reflectionAmount: number;
  32714. /**
  32715. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  32716. */
  32717. reflectionAmount: number;
  32718. protected _reflectionReflectance0: number;
  32719. /**
  32720. * This specifies the weight of the reflection at grazing angle.
  32721. */
  32722. reflectionReflectance0: number;
  32723. protected _reflectionReflectance90: number;
  32724. /**
  32725. * This specifies the weight of the reflection at a perpendicular point of view.
  32726. */
  32727. reflectionReflectance90: number;
  32728. /**
  32729. * Sets the reflection reflectance fresnel values according to the default standard
  32730. * empirically know to work well :-)
  32731. */
  32732. reflectionStandardFresnelWeight: number;
  32733. protected _useRGBColor: boolean;
  32734. /**
  32735. * Helps to directly use the maps channels instead of their level.
  32736. */
  32737. useRGBColor: boolean;
  32738. protected _enableNoise: boolean;
  32739. /**
  32740. * This helps reducing the banding effect that could occur on the background.
  32741. */
  32742. enableNoise: boolean;
  32743. /**
  32744. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  32745. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  32746. * Recommended to be keep at 1.0 except for special cases.
  32747. */
  32748. fovMultiplier: number;
  32749. private _fovMultiplier;
  32750. /**
  32751. * Enable the FOV adjustment feature controlled by fovMultiplier.
  32752. */
  32753. useEquirectangularFOV: boolean;
  32754. private _maxSimultaneousLights;
  32755. /**
  32756. * Number of Simultaneous lights allowed on the material.
  32757. */
  32758. maxSimultaneousLights: int;
  32759. /**
  32760. * Default configuration related to image processing available in the Background Material.
  32761. */
  32762. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32763. /**
  32764. * Keep track of the image processing observer to allow dispose and replace.
  32765. */
  32766. private _imageProcessingObserver;
  32767. /**
  32768. * Attaches a new image processing configuration to the PBR Material.
  32769. * @param configuration (if null the scene configuration will be use)
  32770. */
  32771. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32772. /**
  32773. * Gets the image processing configuration used either in this material.
  32774. */
  32775. /**
  32776. * Sets the Default image processing configuration used either in the this material.
  32777. *
  32778. * If sets to null, the scene one is in use.
  32779. */
  32780. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  32781. /**
  32782. * Gets wether the color curves effect is enabled.
  32783. */
  32784. /**
  32785. * Sets wether the color curves effect is enabled.
  32786. */
  32787. cameraColorCurvesEnabled: boolean;
  32788. /**
  32789. * Gets wether the color grading effect is enabled.
  32790. */
  32791. /**
  32792. * Gets wether the color grading effect is enabled.
  32793. */
  32794. cameraColorGradingEnabled: boolean;
  32795. /**
  32796. * Gets wether tonemapping is enabled or not.
  32797. */
  32798. /**
  32799. * Sets wether tonemapping is enabled or not
  32800. */
  32801. cameraToneMappingEnabled: boolean;
  32802. /**
  32803. * The camera exposure used on this material.
  32804. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32805. * This corresponds to a photographic exposure.
  32806. */
  32807. /**
  32808. * The camera exposure used on this material.
  32809. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32810. * This corresponds to a photographic exposure.
  32811. */
  32812. cameraExposure: float;
  32813. /**
  32814. * Gets The camera contrast used on this material.
  32815. */
  32816. /**
  32817. * Sets The camera contrast used on this material.
  32818. */
  32819. cameraContrast: float;
  32820. /**
  32821. * Gets the Color Grading 2D Lookup Texture.
  32822. */
  32823. /**
  32824. * Sets the Color Grading 2D Lookup Texture.
  32825. */
  32826. cameraColorGradingTexture: Nullable<BaseTexture>;
  32827. /**
  32828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32830. * 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;
  32831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32832. */
  32833. /**
  32834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32836. * 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;
  32837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32838. */
  32839. cameraColorCurves: Nullable<ColorCurves>;
  32840. /**
  32841. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  32842. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  32843. */
  32844. switchToBGR: boolean;
  32845. private _renderTargets;
  32846. private _reflectionControls;
  32847. private _white;
  32848. private _primaryShadowColor;
  32849. private _primaryHighlightColor;
  32850. /**
  32851. * Instantiates a Background Material in the given scene
  32852. * @param name The friendly name of the material
  32853. * @param scene The scene to add the material to
  32854. */
  32855. constructor(name: string, scene: Scene);
  32856. /**
  32857. * The entire material has been created in order to prevent overdraw.
  32858. * @returns false
  32859. */
  32860. needAlphaTesting(): boolean;
  32861. /**
  32862. * The entire material has been created in order to prevent overdraw.
  32863. * @returns true if blending is enable
  32864. */
  32865. needAlphaBlending(): boolean;
  32866. /**
  32867. * Checks wether the material is ready to be rendered for a given mesh.
  32868. * @param mesh The mesh to render
  32869. * @param subMesh The submesh to check against
  32870. * @param useInstances Specify wether or not the material is used with instances
  32871. * @returns true if all the dependencies are ready (Textures, Effects...)
  32872. */
  32873. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32874. /**
  32875. * Compute the primary color according to the chosen perceptual color.
  32876. */
  32877. private _computePrimaryColorFromPerceptualColor();
  32878. /**
  32879. * Compute the highlights and shadow colors according to their chosen levels.
  32880. */
  32881. private _computePrimaryColors();
  32882. /**
  32883. * Build the uniform buffer used in the material.
  32884. */
  32885. buildUniformLayout(): void;
  32886. /**
  32887. * Unbind the material.
  32888. */
  32889. unbind(): void;
  32890. /**
  32891. * Bind only the world matrix to the material.
  32892. * @param world The world matrix to bind.
  32893. */
  32894. bindOnlyWorldMatrix(world: Matrix): void;
  32895. /**
  32896. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  32897. * @param world The world matrix to bind.
  32898. * @param subMesh The submesh to bind for.
  32899. */
  32900. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32901. /**
  32902. * Dispose the material.
  32903. * @param forceDisposeEffect Force disposal of the associated effect.
  32904. * @param forceDisposeTextures Force disposal of the associated textures.
  32905. */
  32906. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32907. /**
  32908. * Clones the material.
  32909. * @param name The cloned name.
  32910. * @returns The cloned material.
  32911. */
  32912. clone(name: string): BackgroundMaterial;
  32913. /**
  32914. * Serializes the current material to its JSON representation.
  32915. * @returns The JSON representation.
  32916. */
  32917. serialize(): any;
  32918. /**
  32919. * Gets the class name of the material
  32920. * @returns "BackgroundMaterial"
  32921. */
  32922. getClassName(): string;
  32923. /**
  32924. * Parse a JSON input to create back a background material.
  32925. * @param source The JSON data to parse
  32926. * @param scene The scene to create the parsed material in
  32927. * @param rootUrl The root url of the assets the material depends upon
  32928. * @returns the instantiated BackgroundMaterial.
  32929. */
  32930. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  32931. }
  32932. }
  32933. declare module BABYLON {
  32934. /**
  32935. * The Physically based material base class of BJS.
  32936. *
  32937. * This offers the main features of a standard PBR material.
  32938. * For more information, please refer to the documentation :
  32939. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32940. */
  32941. abstract class PBRBaseMaterial extends PushMaterial {
  32942. /**
  32943. * Intensity of the direct lights e.g. the four lights available in your scene.
  32944. * This impacts both the direct diffuse and specular highlights.
  32945. */
  32946. protected _directIntensity: number;
  32947. /**
  32948. * Intensity of the emissive part of the material.
  32949. * This helps controlling the emissive effect without modifying the emissive color.
  32950. */
  32951. protected _emissiveIntensity: number;
  32952. /**
  32953. * Intensity of the environment e.g. how much the environment will light the object
  32954. * either through harmonics for rough material or through the refelction for shiny ones.
  32955. */
  32956. protected _environmentIntensity: number;
  32957. /**
  32958. * This is a special control allowing the reduction of the specular highlights coming from the
  32959. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32960. */
  32961. protected _specularIntensity: number;
  32962. /**
  32963. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32964. */
  32965. private _lightingInfos;
  32966. /**
  32967. * Debug Control allowing disabling the bump map on this material.
  32968. */
  32969. protected _disableBumpMap: boolean;
  32970. /**
  32971. * AKA Diffuse Texture in standard nomenclature.
  32972. */
  32973. protected _albedoTexture: BaseTexture;
  32974. /**
  32975. * AKA Occlusion Texture in other nomenclature.
  32976. */
  32977. protected _ambientTexture: BaseTexture;
  32978. /**
  32979. * AKA Occlusion Texture Intensity in other nomenclature.
  32980. */
  32981. protected _ambientTextureStrength: number;
  32982. /**
  32983. * Stores the alpha values in a texture.
  32984. */
  32985. protected _opacityTexture: BaseTexture;
  32986. /**
  32987. * Stores the reflection values in a texture.
  32988. */
  32989. protected _reflectionTexture: BaseTexture;
  32990. /**
  32991. * Stores the refraction values in a texture.
  32992. */
  32993. protected _refractionTexture: BaseTexture;
  32994. /**
  32995. * Stores the emissive values in a texture.
  32996. */
  32997. protected _emissiveTexture: BaseTexture;
  32998. /**
  32999. * AKA Specular texture in other nomenclature.
  33000. */
  33001. protected _reflectivityTexture: BaseTexture;
  33002. /**
  33003. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33004. */
  33005. protected _metallicTexture: BaseTexture;
  33006. /**
  33007. * Specifies the metallic scalar of the metallic/roughness workflow.
  33008. * Can also be used to scale the metalness values of the metallic texture.
  33009. */
  33010. protected _metallic: number;
  33011. /**
  33012. * Specifies the roughness scalar of the metallic/roughness workflow.
  33013. * Can also be used to scale the roughness values of the metallic texture.
  33014. */
  33015. protected _roughness: number;
  33016. /**
  33017. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33018. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33019. */
  33020. protected _microSurfaceTexture: BaseTexture;
  33021. /**
  33022. * Stores surface normal data used to displace a mesh in a texture.
  33023. */
  33024. protected _bumpTexture: BaseTexture;
  33025. /**
  33026. * Stores the pre-calculated light information of a mesh in a texture.
  33027. */
  33028. protected _lightmapTexture: BaseTexture;
  33029. /**
  33030. * The color of a material in ambient lighting.
  33031. */
  33032. protected _ambientColor: Color3;
  33033. /**
  33034. * AKA Diffuse Color in other nomenclature.
  33035. */
  33036. protected _albedoColor: Color3;
  33037. /**
  33038. * AKA Specular Color in other nomenclature.
  33039. */
  33040. protected _reflectivityColor: Color3;
  33041. /**
  33042. * The color applied when light is reflected from a material.
  33043. */
  33044. protected _reflectionColor: Color3;
  33045. /**
  33046. * The color applied when light is emitted from a material.
  33047. */
  33048. protected _emissiveColor: Color3;
  33049. /**
  33050. * AKA Glossiness in other nomenclature.
  33051. */
  33052. protected _microSurface: number;
  33053. /**
  33054. * source material index of refraction (IOR)' / 'destination material IOR.
  33055. */
  33056. protected _indexOfRefraction: number;
  33057. /**
  33058. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33059. */
  33060. protected _invertRefractionY: boolean;
  33061. /**
  33062. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33063. * Materials half opaque for instance using refraction could benefit from this control.
  33064. */
  33065. protected _linkRefractionWithTransparency: boolean;
  33066. /**
  33067. * Specifies that the material will use the light map as a show map.
  33068. */
  33069. protected _useLightmapAsShadowmap: boolean;
  33070. /**
  33071. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33072. * makes the reflect vector face the model (under horizon).
  33073. */
  33074. protected _useHorizonOcclusion: boolean;
  33075. /**
  33076. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33077. * too much the area relying on ambient texture to define their ambient occlusion.
  33078. */
  33079. protected _useRadianceOcclusion: boolean;
  33080. /**
  33081. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33082. */
  33083. protected _useAlphaFromAlbedoTexture: boolean;
  33084. /**
  33085. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33086. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33087. */
  33088. protected _useSpecularOverAlpha: boolean;
  33089. /**
  33090. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33091. */
  33092. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33093. /**
  33094. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33095. */
  33096. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  33097. /**
  33098. * Specifies if the metallic texture contains the roughness information in its green channel.
  33099. */
  33100. protected _useRoughnessFromMetallicTextureGreen: boolean;
  33101. /**
  33102. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33103. */
  33104. protected _useMetallnessFromMetallicTextureBlue: boolean;
  33105. /**
  33106. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33107. */
  33108. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  33109. /**
  33110. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33111. */
  33112. protected _useAmbientInGrayScale: boolean;
  33113. /**
  33114. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33115. * The material will try to infer what glossiness each pixel should be.
  33116. */
  33117. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  33118. /**
  33119. * BJS is using an harcoded light falloff based on a manually sets up range.
  33120. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33121. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33122. */
  33123. protected _usePhysicalLightFalloff: boolean;
  33124. /**
  33125. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33126. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33127. */
  33128. protected _useRadianceOverAlpha: boolean;
  33129. /**
  33130. * Allows using an object space normal map (instead of tangent space).
  33131. */
  33132. protected _useObjectSpaceNormalMap: boolean;
  33133. /**
  33134. * Allows using the bump map in parallax mode.
  33135. */
  33136. protected _useParallax: boolean;
  33137. /**
  33138. * Allows using the bump map in parallax occlusion mode.
  33139. */
  33140. protected _useParallaxOcclusion: boolean;
  33141. /**
  33142. * Controls the scale bias of the parallax mode.
  33143. */
  33144. protected _parallaxScaleBias: number;
  33145. /**
  33146. * If sets to true, disables all the lights affecting the material.
  33147. */
  33148. protected _disableLighting: boolean;
  33149. /**
  33150. * Number of Simultaneous lights allowed on the material.
  33151. */
  33152. protected _maxSimultaneousLights: number;
  33153. /**
  33154. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  33155. */
  33156. protected _invertNormalMapX: boolean;
  33157. /**
  33158. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  33159. */
  33160. protected _invertNormalMapY: boolean;
  33161. /**
  33162. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33163. */
  33164. protected _twoSidedLighting: boolean;
  33165. /**
  33166. * Defines the alpha limits in alpha test mode.
  33167. */
  33168. protected _alphaCutOff: number;
  33169. /**
  33170. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33171. */
  33172. protected _forceAlphaTest: boolean;
  33173. /**
  33174. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33175. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33176. */
  33177. protected _useAlphaFresnel: boolean;
  33178. /**
  33179. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33180. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33181. */
  33182. protected _useLinearAlphaFresnel: boolean;
  33183. /**
  33184. * The transparency mode of the material.
  33185. */
  33186. protected _transparencyMode: Nullable<number>;
  33187. /**
  33188. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  33189. * from cos thetav and roughness:
  33190. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  33191. */
  33192. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  33193. /**
  33194. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33195. */
  33196. protected _forceIrradianceInFragment: boolean;
  33197. /**
  33198. * Force normal to face away from face.
  33199. */
  33200. protected _forceNormalForward: boolean;
  33201. /**
  33202. * Enables specular anti aliasing in the PBR shader.
  33203. * It will both interacts on the Geometry for analytical and IBL lighting.
  33204. * It also prefilter the roughness map based on the bump values.
  33205. */
  33206. protected _enableSpecularAntiAliasing: boolean;
  33207. /**
  33208. * Default configuration related to image processing available in the PBR Material.
  33209. */
  33210. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33211. /**
  33212. * Keep track of the image processing observer to allow dispose and replace.
  33213. */
  33214. private _imageProcessingObserver;
  33215. /**
  33216. * Attaches a new image processing configuration to the PBR Material.
  33217. * @param configuration
  33218. */
  33219. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33220. /**
  33221. * Stores the available render targets.
  33222. */
  33223. private _renderTargets;
  33224. /**
  33225. * Sets the global ambient color for the material used in lighting calculations.
  33226. */
  33227. private _globalAmbientColor;
  33228. /**
  33229. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  33230. */
  33231. private _useLogarithmicDepth;
  33232. /**
  33233. * If set to true, no lighting calculations will be applied.
  33234. */
  33235. private _unlit;
  33236. /**
  33237. * Instantiates a new PBRMaterial instance.
  33238. *
  33239. * @param name The material name
  33240. * @param scene The scene the material will be use in.
  33241. */
  33242. constructor(name: string, scene: Scene);
  33243. /**
  33244. * Gets the name of the material class.
  33245. */
  33246. getClassName(): string;
  33247. /**
  33248. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  33249. */
  33250. /**
  33251. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  33252. */
  33253. useLogarithmicDepth: boolean;
  33254. /**
  33255. * Gets the current transparency mode.
  33256. */
  33257. /**
  33258. * Sets the transparency mode of the material.
  33259. *
  33260. * | Value | Type | Description |
  33261. * | ----- | ----------------------------------- | ----------- |
  33262. * | 0 | OPAQUE | |
  33263. * | 1 | ALPHATEST | |
  33264. * | 2 | ALPHABLEND | |
  33265. * | 3 | ALPHATESTANDBLEND | |
  33266. *
  33267. */
  33268. transparencyMode: Nullable<number>;
  33269. /**
  33270. * Returns true if alpha blending should be disabled.
  33271. */
  33272. private readonly _disableAlphaBlending;
  33273. /**
  33274. * Specifies whether or not this material should be rendered in alpha blend mode.
  33275. */
  33276. needAlphaBlending(): boolean;
  33277. /**
  33278. * Specifies if the mesh will require alpha blending.
  33279. * @param mesh - BJS mesh.
  33280. */
  33281. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  33282. /**
  33283. * Specifies whether or not this material should be rendered in alpha test mode.
  33284. */
  33285. needAlphaTesting(): boolean;
  33286. /**
  33287. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  33288. */
  33289. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  33290. /**
  33291. * Gets the texture used for the alpha test.
  33292. */
  33293. getAlphaTestTexture(): BaseTexture;
  33294. /**
  33295. * Stores the reflectivity values based on metallic roughness workflow.
  33296. */
  33297. private static _scaledReflectivity;
  33298. /**
  33299. * Specifies that the submesh is ready to be used.
  33300. * @param mesh - BJS mesh.
  33301. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  33302. * @param useInstances - Specifies that instances should be used.
  33303. * @returns - boolean indicating that the submesh is ready or not.
  33304. */
  33305. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  33306. /**
  33307. * Specifies if the material uses metallic roughness workflow.
  33308. * @returns boolean specifiying if the material uses metallic roughness workflow.
  33309. */
  33310. isMetallicWorkflow(): boolean;
  33311. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  33312. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  33313. /**
  33314. * Force shader compilation
  33315. */
  33316. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  33317. clipPlane: boolean;
  33318. }>): void;
  33319. /**
  33320. * Initializes the uniform buffer layout for the shader.
  33321. */
  33322. buildUniformLayout(): void;
  33323. /**
  33324. * Unbinds the textures.
  33325. */
  33326. unbind(): void;
  33327. /**
  33328. * Binds the submesh data.
  33329. * @param world - The world matrix.
  33330. * @param mesh - The BJS mesh.
  33331. * @param subMesh - A submesh of the BJS mesh.
  33332. */
  33333. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  33334. /**
  33335. * Returns the animatable textures.
  33336. * @returns - Array of animatable textures.
  33337. */
  33338. getAnimatables(): IAnimatable[];
  33339. /**
  33340. * Returns the texture used for reflections.
  33341. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  33342. */
  33343. private _getReflectionTexture();
  33344. /**
  33345. * Returns the texture used for refraction or null if none is used.
  33346. * @returns - Refection texture if present. If no refraction texture and refraction
  33347. * is linked with transparency, returns environment texture. Otherwise, returns null.
  33348. */
  33349. private _getRefractionTexture();
  33350. /**
  33351. * Disposes the resources of the material.
  33352. * @param forceDisposeEffect - Forces the disposal of effects.
  33353. * @param forceDisposeTextures - Forces the disposal of all textures.
  33354. */
  33355. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  33356. }
  33357. }
  33358. declare module BABYLON {
  33359. /**
  33360. * The Physically based simple base material of BJS.
  33361. *
  33362. * This enables better naming and convention enforcements on top of the pbrMaterial.
  33363. * It is used as the base class for both the specGloss and metalRough conventions.
  33364. */
  33365. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  33366. /**
  33367. * Number of Simultaneous lights allowed on the material.
  33368. */
  33369. maxSimultaneousLights: number;
  33370. /**
  33371. * If sets to true, disables all the lights affecting the material.
  33372. */
  33373. disableLighting: boolean;
  33374. /**
  33375. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  33376. */
  33377. environmentTexture: BaseTexture;
  33378. /**
  33379. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33380. */
  33381. invertNormalMapX: boolean;
  33382. /**
  33383. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33384. */
  33385. invertNormalMapY: boolean;
  33386. /**
  33387. * Normal map used in the model.
  33388. */
  33389. normalTexture: BaseTexture;
  33390. /**
  33391. * Emissivie color used to self-illuminate the model.
  33392. */
  33393. emissiveColor: Color3;
  33394. /**
  33395. * Emissivie texture used to self-illuminate the model.
  33396. */
  33397. emissiveTexture: BaseTexture;
  33398. /**
  33399. * Occlusion Channel Strenght.
  33400. */
  33401. occlusionStrength: number;
  33402. /**
  33403. * Occlusion Texture of the material (adding extra occlusion effects).
  33404. */
  33405. occlusionTexture: BaseTexture;
  33406. /**
  33407. * Defines the alpha limits in alpha test mode.
  33408. */
  33409. alphaCutOff: number;
  33410. /**
  33411. * Gets the current double sided mode.
  33412. */
  33413. /**
  33414. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33415. */
  33416. doubleSided: boolean;
  33417. lightmapTexture: BaseTexture;
  33418. useLightmapAsShadowmap: boolean;
  33419. /**
  33420. * Return the active textures of the material.
  33421. */
  33422. getActiveTextures(): BaseTexture[];
  33423. hasTexture(texture: BaseTexture): boolean;
  33424. /**
  33425. * Instantiates a new PBRMaterial instance.
  33426. *
  33427. * @param name The material name
  33428. * @param scene The scene the material will be use in.
  33429. */
  33430. constructor(name: string, scene: Scene);
  33431. getClassName(): string;
  33432. }
  33433. }
  33434. declare module BABYLON {
  33435. /**
  33436. * The Physically based material of BJS.
  33437. *
  33438. * This offers the main features of a standard PBR material.
  33439. * For more information, please refer to the documentation :
  33440. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33441. */
  33442. class PBRMaterial extends PBRBaseMaterial {
  33443. private static _PBRMATERIAL_OPAQUE;
  33444. /**
  33445. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  33446. */
  33447. static readonly PBRMATERIAL_OPAQUE: number;
  33448. /**
  33449. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  33450. */
  33451. private static _PBRMATERIAL_ALPHATEST;
  33452. /**
  33453. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  33454. */
  33455. static readonly PBRMATERIAL_ALPHATEST: number;
  33456. /**
  33457. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33458. */
  33459. private static _PBRMATERIAL_ALPHABLEND;
  33460. /**
  33461. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33462. */
  33463. static readonly PBRMATERIAL_ALPHABLEND: number;
  33464. /**
  33465. * 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.
  33466. * They are also discarded below the alpha cutoff threshold to improve performances.
  33467. */
  33468. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  33469. /**
  33470. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33471. * They are also discarded below the alpha cutoff threshold to improve performances.
  33472. */
  33473. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  33474. /**
  33475. * Intensity of the direct lights e.g. the four lights available in your scene.
  33476. * This impacts both the direct diffuse and specular highlights.
  33477. */
  33478. directIntensity: number;
  33479. /**
  33480. * Intensity of the emissive part of the material.
  33481. * This helps controlling the emissive effect without modifying the emissive color.
  33482. */
  33483. emissiveIntensity: number;
  33484. /**
  33485. * Intensity of the environment e.g. how much the environment will light the object
  33486. * either through harmonics for rough material or through the refelction for shiny ones.
  33487. */
  33488. environmentIntensity: number;
  33489. /**
  33490. * This is a special control allowing the reduction of the specular highlights coming from the
  33491. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33492. */
  33493. specularIntensity: number;
  33494. /**
  33495. * Debug Control allowing disabling the bump map on this material.
  33496. */
  33497. disableBumpMap: boolean;
  33498. /**
  33499. * AKA Diffuse Texture in standard nomenclature.
  33500. */
  33501. albedoTexture: BaseTexture;
  33502. /**
  33503. * AKA Occlusion Texture in other nomenclature.
  33504. */
  33505. ambientTexture: BaseTexture;
  33506. /**
  33507. * AKA Occlusion Texture Intensity in other nomenclature.
  33508. */
  33509. ambientTextureStrength: number;
  33510. /**
  33511. * Stores the alpha values in a texture.
  33512. */
  33513. opacityTexture: BaseTexture;
  33514. /**
  33515. * Stores the reflection values in a texture.
  33516. */
  33517. reflectionTexture: Nullable<BaseTexture>;
  33518. /**
  33519. * Stores the emissive values in a texture.
  33520. */
  33521. emissiveTexture: BaseTexture;
  33522. /**
  33523. * AKA Specular texture in other nomenclature.
  33524. */
  33525. reflectivityTexture: BaseTexture;
  33526. /**
  33527. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33528. */
  33529. metallicTexture: BaseTexture;
  33530. /**
  33531. * Specifies the metallic scalar of the metallic/roughness workflow.
  33532. * Can also be used to scale the metalness values of the metallic texture.
  33533. */
  33534. metallic: number;
  33535. /**
  33536. * Specifies the roughness scalar of the metallic/roughness workflow.
  33537. * Can also be used to scale the roughness values of the metallic texture.
  33538. */
  33539. roughness: number;
  33540. /**
  33541. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33542. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33543. */
  33544. microSurfaceTexture: BaseTexture;
  33545. /**
  33546. * Stores surface normal data used to displace a mesh in a texture.
  33547. */
  33548. bumpTexture: BaseTexture;
  33549. /**
  33550. * Stores the pre-calculated light information of a mesh in a texture.
  33551. */
  33552. lightmapTexture: BaseTexture;
  33553. /**
  33554. * Stores the refracted light information in a texture.
  33555. */
  33556. refractionTexture: BaseTexture;
  33557. /**
  33558. * The color of a material in ambient lighting.
  33559. */
  33560. ambientColor: Color3;
  33561. /**
  33562. * AKA Diffuse Color in other nomenclature.
  33563. */
  33564. albedoColor: Color3;
  33565. /**
  33566. * AKA Specular Color in other nomenclature.
  33567. */
  33568. reflectivityColor: Color3;
  33569. /**
  33570. * The color reflected from the material.
  33571. */
  33572. reflectionColor: Color3;
  33573. /**
  33574. * The color emitted from the material.
  33575. */
  33576. emissiveColor: Color3;
  33577. /**
  33578. * AKA Glossiness in other nomenclature.
  33579. */
  33580. microSurface: number;
  33581. /**
  33582. * source material index of refraction (IOR)' / 'destination material IOR.
  33583. */
  33584. indexOfRefraction: number;
  33585. /**
  33586. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33587. */
  33588. invertRefractionY: boolean;
  33589. /**
  33590. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33591. * Materials half opaque for instance using refraction could benefit from this control.
  33592. */
  33593. linkRefractionWithTransparency: boolean;
  33594. useLightmapAsShadowmap: boolean;
  33595. /**
  33596. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33597. */
  33598. useAlphaFromAlbedoTexture: boolean;
  33599. /**
  33600. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33601. */
  33602. forceAlphaTest: boolean;
  33603. /**
  33604. * Defines the alpha limits in alpha test mode.
  33605. */
  33606. alphaCutOff: number;
  33607. /**
  33608. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33609. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33610. */
  33611. useSpecularOverAlpha: boolean;
  33612. /**
  33613. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33614. */
  33615. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33616. /**
  33617. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33618. */
  33619. useRoughnessFromMetallicTextureAlpha: boolean;
  33620. /**
  33621. * Specifies if the metallic texture contains the roughness information in its green channel.
  33622. */
  33623. useRoughnessFromMetallicTextureGreen: boolean;
  33624. /**
  33625. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33626. */
  33627. useMetallnessFromMetallicTextureBlue: boolean;
  33628. /**
  33629. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33630. */
  33631. useAmbientOcclusionFromMetallicTextureRed: boolean;
  33632. /**
  33633. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33634. */
  33635. useAmbientInGrayScale: boolean;
  33636. /**
  33637. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33638. * The material will try to infer what glossiness each pixel should be.
  33639. */
  33640. useAutoMicroSurfaceFromReflectivityMap: boolean;
  33641. /**
  33642. * BJS is using an harcoded light falloff based on a manually sets up range.
  33643. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33644. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33645. */
  33646. usePhysicalLightFalloff: boolean;
  33647. /**
  33648. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33649. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33650. */
  33651. useRadianceOverAlpha: boolean;
  33652. /**
  33653. * Allows using an object space normal map (instead of tangent space).
  33654. */
  33655. useObjectSpaceNormalMap: boolean;
  33656. /**
  33657. * Allows using the bump map in parallax mode.
  33658. */
  33659. useParallax: boolean;
  33660. /**
  33661. * Allows using the bump map in parallax occlusion mode.
  33662. */
  33663. useParallaxOcclusion: boolean;
  33664. /**
  33665. * Controls the scale bias of the parallax mode.
  33666. */
  33667. parallaxScaleBias: number;
  33668. /**
  33669. * If sets to true, disables all the lights affecting the material.
  33670. */
  33671. disableLighting: boolean;
  33672. /**
  33673. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33674. */
  33675. forceIrradianceInFragment: boolean;
  33676. /**
  33677. * Number of Simultaneous lights allowed on the material.
  33678. */
  33679. maxSimultaneousLights: number;
  33680. /**
  33681. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33682. */
  33683. invertNormalMapX: boolean;
  33684. /**
  33685. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33686. */
  33687. invertNormalMapY: boolean;
  33688. /**
  33689. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33690. */
  33691. twoSidedLighting: boolean;
  33692. /**
  33693. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33694. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33695. */
  33696. useAlphaFresnel: boolean;
  33697. /**
  33698. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33699. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33700. */
  33701. useLinearAlphaFresnel: boolean;
  33702. /**
  33703. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33704. * And/Or occlude the blended part.
  33705. */
  33706. environmentBRDFTexture: Nullable<BaseTexture>;
  33707. /**
  33708. * Force normal to face away from face.
  33709. */
  33710. forceNormalForward: boolean;
  33711. /**
  33712. * Enables specular anti aliasing in the PBR shader.
  33713. * It will both interacts on the Geometry for analytical and IBL lighting.
  33714. * It also prefilter the roughness map based on the bump values.
  33715. */
  33716. enableSpecularAntiAliasing: boolean;
  33717. /**
  33718. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33719. * makes the reflect vector face the model (under horizon).
  33720. */
  33721. useHorizonOcclusion: boolean;
  33722. /**
  33723. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33724. * too much the area relying on ambient texture to define their ambient occlusion.
  33725. */
  33726. useRadianceOcclusion: boolean;
  33727. /**
  33728. * If set to true, no lighting calculations will be applied.
  33729. */
  33730. unlit: boolean;
  33731. /**
  33732. * Gets the image processing configuration used either in this material.
  33733. */
  33734. /**
  33735. * Sets the Default image processing configuration used either in the this material.
  33736. *
  33737. * If sets to null, the scene one is in use.
  33738. */
  33739. imageProcessingConfiguration: ImageProcessingConfiguration;
  33740. /**
  33741. * Gets wether the color curves effect is enabled.
  33742. */
  33743. /**
  33744. * Sets wether the color curves effect is enabled.
  33745. */
  33746. cameraColorCurvesEnabled: boolean;
  33747. /**
  33748. * Gets wether the color grading effect is enabled.
  33749. */
  33750. /**
  33751. * Gets wether the color grading effect is enabled.
  33752. */
  33753. cameraColorGradingEnabled: boolean;
  33754. /**
  33755. * Gets wether tonemapping is enabled or not.
  33756. */
  33757. /**
  33758. * Sets wether tonemapping is enabled or not
  33759. */
  33760. cameraToneMappingEnabled: boolean;
  33761. /**
  33762. * The camera exposure used on this material.
  33763. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33764. * This corresponds to a photographic exposure.
  33765. */
  33766. /**
  33767. * The camera exposure used on this material.
  33768. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33769. * This corresponds to a photographic exposure.
  33770. */
  33771. cameraExposure: number;
  33772. /**
  33773. * Gets The camera contrast used on this material.
  33774. */
  33775. /**
  33776. * Sets The camera contrast used on this material.
  33777. */
  33778. cameraContrast: number;
  33779. /**
  33780. * Gets the Color Grading 2D Lookup Texture.
  33781. */
  33782. /**
  33783. * Sets the Color Grading 2D Lookup Texture.
  33784. */
  33785. cameraColorGradingTexture: Nullable<BaseTexture>;
  33786. /**
  33787. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33788. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33789. * 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;
  33790. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33791. */
  33792. /**
  33793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33795. * 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;
  33796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33797. */
  33798. cameraColorCurves: Nullable<ColorCurves>;
  33799. /**
  33800. * Instantiates a new PBRMaterial instance.
  33801. *
  33802. * @param name The material name
  33803. * @param scene The scene the material will be use in.
  33804. */
  33805. constructor(name: string, scene: Scene);
  33806. /**
  33807. * Returns the name of this material class.
  33808. */
  33809. getClassName(): string;
  33810. /**
  33811. * Returns an array of the actively used textures.
  33812. * @returns - Array of BaseTextures
  33813. */
  33814. getActiveTextures(): BaseTexture[];
  33815. /**
  33816. * Checks to see if a texture is used in the material.
  33817. * @param texture - Base texture to use.
  33818. * @returns - Boolean specifying if a texture is used in the material.
  33819. */
  33820. hasTexture(texture: BaseTexture): boolean;
  33821. /**
  33822. * Makes a duplicate of the current material.
  33823. * @param name - name to use for the new material.
  33824. */
  33825. clone(name: string): PBRMaterial;
  33826. /**
  33827. * Serializes this PBR Material.
  33828. * @returns - An object with the serialized material.
  33829. */
  33830. serialize(): any;
  33831. /**
  33832. * Parses a PBR Material from a serialized object.
  33833. * @param source - Serialized object.
  33834. * @param scene - BJS scene instance.
  33835. * @param rootUrl - url for the scene object
  33836. * @returns - PBRMaterial
  33837. */
  33838. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  33839. }
  33840. }
  33841. declare module BABYLON {
  33842. /**
  33843. * The PBR material of BJS following the metal roughness convention.
  33844. *
  33845. * This fits to the PBR convention in the GLTF definition:
  33846. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  33847. */
  33848. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  33849. /**
  33850. * The base color has two different interpretations depending on the value of metalness.
  33851. * When the material is a metal, the base color is the specific measured reflectance value
  33852. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  33853. * of the material.
  33854. */
  33855. baseColor: Color3;
  33856. /**
  33857. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  33858. * well as opacity information in the alpha channel.
  33859. */
  33860. baseTexture: BaseTexture;
  33861. /**
  33862. * Specifies the metallic scalar value of the material.
  33863. * Can also be used to scale the metalness values of the metallic texture.
  33864. */
  33865. metallic: number;
  33866. /**
  33867. * Specifies the roughness scalar value of the material.
  33868. * Can also be used to scale the roughness values of the metallic texture.
  33869. */
  33870. roughness: number;
  33871. /**
  33872. * Texture containing both the metallic value in the B channel and the
  33873. * roughness value in the G channel to keep better precision.
  33874. */
  33875. metallicRoughnessTexture: BaseTexture;
  33876. /**
  33877. * Instantiates a new PBRMetalRoughnessMaterial instance.
  33878. *
  33879. * @param name The material name
  33880. * @param scene The scene the material will be use in.
  33881. */
  33882. constructor(name: string, scene: Scene);
  33883. /**
  33884. * Return the currrent class name of the material.
  33885. */
  33886. getClassName(): string;
  33887. /**
  33888. * Return the active textures of the material.
  33889. */
  33890. getActiveTextures(): BaseTexture[];
  33891. /**
  33892. * Checks to see if a texture is used in the material.
  33893. * @param texture - Base texture to use.
  33894. * @returns - Boolean specifying if a texture is used in the material.
  33895. */
  33896. hasTexture(texture: BaseTexture): boolean;
  33897. /**
  33898. * Makes a duplicate of the current material.
  33899. * @param name - name to use for the new material.
  33900. */
  33901. clone(name: string): PBRMetallicRoughnessMaterial;
  33902. /**
  33903. * Serialize the material to a parsable JSON object.
  33904. */
  33905. serialize(): any;
  33906. /**
  33907. * Parses a JSON object correponding to the serialize function.
  33908. */
  33909. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33910. }
  33911. }
  33912. declare module BABYLON {
  33913. /**
  33914. * The PBR material of BJS following the specular glossiness convention.
  33915. *
  33916. * This fits to the PBR convention in the GLTF definition:
  33917. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33918. */
  33919. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33920. /**
  33921. * Specifies the diffuse color of the material.
  33922. */
  33923. diffuseColor: Color3;
  33924. /**
  33925. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33926. * channel.
  33927. */
  33928. diffuseTexture: BaseTexture;
  33929. /**
  33930. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33931. */
  33932. specularColor: Color3;
  33933. /**
  33934. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33935. */
  33936. glossiness: number;
  33937. /**
  33938. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33939. */
  33940. specularGlossinessTexture: BaseTexture;
  33941. /**
  33942. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33943. *
  33944. * @param name The material name
  33945. * @param scene The scene the material will be use in.
  33946. */
  33947. constructor(name: string, scene: Scene);
  33948. /**
  33949. * Return the currrent class name of the material.
  33950. */
  33951. getClassName(): string;
  33952. /**
  33953. * Return the active textures of the material.
  33954. */
  33955. getActiveTextures(): BaseTexture[];
  33956. /**
  33957. * Checks to see if a texture is used in the material.
  33958. * @param texture - Base texture to use.
  33959. * @returns - Boolean specifying if a texture is used in the material.
  33960. */
  33961. hasTexture(texture: BaseTexture): boolean;
  33962. /**
  33963. * Makes a duplicate of the current material.
  33964. * @param name - name to use for the new material.
  33965. */
  33966. clone(name: string): PBRSpecularGlossinessMaterial;
  33967. /**
  33968. * Serialize the material to a parsable JSON object.
  33969. */
  33970. serialize(): any;
  33971. /**
  33972. * Parses a JSON object correponding to the serialize function.
  33973. */
  33974. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33975. }
  33976. }
  33977. declare module BABYLON {
  33978. class BaseTexture {
  33979. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33980. name: string;
  33981. private _hasAlpha;
  33982. hasAlpha: boolean;
  33983. getAlphaFromRGB: boolean;
  33984. level: number;
  33985. coordinatesIndex: number;
  33986. private _coordinatesMode;
  33987. /**
  33988. * How a texture is mapped.
  33989. *
  33990. * | Value | Type | Description |
  33991. * | ----- | ----------------------------------- | ----------- |
  33992. * | 0 | EXPLICIT_MODE | |
  33993. * | 1 | SPHERICAL_MODE | |
  33994. * | 2 | PLANAR_MODE | |
  33995. * | 3 | CUBIC_MODE | |
  33996. * | 4 | PROJECTION_MODE | |
  33997. * | 5 | SKYBOX_MODE | |
  33998. * | 6 | INVCUBIC_MODE | |
  33999. * | 7 | EQUIRECTANGULAR_MODE | |
  34000. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34001. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34002. */
  34003. coordinatesMode: number;
  34004. /**
  34005. * | Value | Type | Description |
  34006. * | ----- | ------------------ | ----------- |
  34007. * | 0 | CLAMP_ADDRESSMODE | |
  34008. * | 1 | WRAP_ADDRESSMODE | |
  34009. * | 2 | MIRROR_ADDRESSMODE | |
  34010. */
  34011. wrapU: number;
  34012. /**
  34013. * | Value | Type | Description |
  34014. * | ----- | ------------------ | ----------- |
  34015. * | 0 | CLAMP_ADDRESSMODE | |
  34016. * | 1 | WRAP_ADDRESSMODE | |
  34017. * | 2 | MIRROR_ADDRESSMODE | |
  34018. */
  34019. wrapV: number;
  34020. /**
  34021. * | Value | Type | Description |
  34022. * | ----- | ------------------ | ----------- |
  34023. * | 0 | CLAMP_ADDRESSMODE | |
  34024. * | 1 | WRAP_ADDRESSMODE | |
  34025. * | 2 | MIRROR_ADDRESSMODE | |
  34026. */
  34027. wrapR: number;
  34028. anisotropicFilteringLevel: number;
  34029. isCube: boolean;
  34030. is3D: boolean;
  34031. gammaSpace: boolean;
  34032. /**
  34033. * Gets whether or not the texture contains RGBD data.
  34034. */
  34035. readonly isRGBD: boolean;
  34036. invertZ: boolean;
  34037. lodLevelInAlpha: boolean;
  34038. lodGenerationOffset: number;
  34039. lodGenerationScale: number;
  34040. isRenderTarget: boolean;
  34041. readonly uid: string;
  34042. toString(): string;
  34043. getClassName(): string;
  34044. animations: Animation[];
  34045. /**
  34046. * An event triggered when the texture is disposed.
  34047. */
  34048. onDisposeObservable: Observable<BaseTexture>;
  34049. private _onDisposeObserver;
  34050. onDispose: () => void;
  34051. delayLoadState: number;
  34052. private _scene;
  34053. _texture: Nullable<InternalTexture>;
  34054. private _uid;
  34055. readonly isBlocking: boolean;
  34056. constructor(scene: Nullable<Scene>);
  34057. getScene(): Nullable<Scene>;
  34058. getTextureMatrix(): Matrix;
  34059. getReflectionTextureMatrix(): Matrix;
  34060. getInternalTexture(): Nullable<InternalTexture>;
  34061. isReadyOrNotBlocking(): boolean;
  34062. isReady(): boolean;
  34063. private _cachedSize;
  34064. getSize(): ISize;
  34065. getBaseSize(): ISize;
  34066. scale(ratio: number): void;
  34067. readonly canRescale: boolean;
  34068. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  34069. _rebuild(): void;
  34070. delayLoad(): void;
  34071. clone(): Nullable<BaseTexture>;
  34072. readonly textureType: number;
  34073. readonly textureFormat: number;
  34074. /**
  34075. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34076. * This will returns an RGBA array buffer containing either in values (0-255) or
  34077. * float values (0-1) depending of the underlying buffer type.
  34078. * @param faceIndex The face of the texture to read (in case of cube texture)
  34079. * @param level The LOD level of the texture to read (in case of Mip Maps)
  34080. * @returns The Array buffer containing the pixels data.
  34081. */
  34082. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  34083. releaseInternalTexture(): void;
  34084. sphericalPolynomial: Nullable<SphericalPolynomial>;
  34085. readonly _lodTextureHigh: Nullable<BaseTexture>;
  34086. readonly _lodTextureMid: Nullable<BaseTexture>;
  34087. readonly _lodTextureLow: Nullable<BaseTexture>;
  34088. dispose(): void;
  34089. serialize(): any;
  34090. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34091. }
  34092. }
  34093. declare module BABYLON {
  34094. /**
  34095. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  34096. * It can help converting any input color in a desired output one. This can then be used to create effects
  34097. * from sepia, black and white to sixties or futuristic rendering...
  34098. *
  34099. * The only supported format is currently 3dl.
  34100. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  34101. */
  34102. class ColorGradingTexture extends BaseTexture {
  34103. /**
  34104. * The current texture matrix. (will always be identity in color grading texture)
  34105. */
  34106. private _textureMatrix;
  34107. /**
  34108. * The texture URL.
  34109. */
  34110. url: string;
  34111. /**
  34112. * Empty line regex stored for GC.
  34113. */
  34114. private static _noneEmptyLineRegex;
  34115. private _engine;
  34116. /**
  34117. * Instantiates a ColorGradingTexture from the following parameters.
  34118. *
  34119. * @param url The location of the color gradind data (currently only supporting 3dl)
  34120. * @param scene The scene the texture will be used in
  34121. */
  34122. constructor(url: string, scene: Scene);
  34123. /**
  34124. * Returns the texture matrix used in most of the material.
  34125. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  34126. */
  34127. getTextureMatrix(): Matrix;
  34128. /**
  34129. * Occurs when the file being loaded is a .3dl LUT file.
  34130. */
  34131. private load3dlTexture();
  34132. /**
  34133. * Starts the loading process of the texture.
  34134. */
  34135. private loadTexture();
  34136. /**
  34137. * Clones the color gradind texture.
  34138. */
  34139. clone(): ColorGradingTexture;
  34140. /**
  34141. * Called during delayed load for textures.
  34142. */
  34143. delayLoad(): void;
  34144. /**
  34145. * Parses a color grading texture serialized by Babylon.
  34146. * @param parsedTexture The texture information being parsedTexture
  34147. * @param scene The scene to load the texture in
  34148. * @param rootUrl The root url of the data assets to load
  34149. * @return A color gradind texture
  34150. */
  34151. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  34152. /**
  34153. * Serializes the LUT texture to json format.
  34154. */
  34155. serialize(): any;
  34156. }
  34157. }
  34158. declare module BABYLON {
  34159. class CubeTexture extends BaseTexture {
  34160. url: string;
  34161. coordinatesMode: number;
  34162. /**
  34163. * Gets or sets the center of the bounding box associated with the cube texture
  34164. * It must define where the camera used to render the texture was set
  34165. */
  34166. boundingBoxPosition: Vector3;
  34167. private _boundingBoxSize;
  34168. /**
  34169. * Gets or sets the size of the bounding box associated with the cube texture
  34170. * When defined, the cubemap will switch to local mode
  34171. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34172. * @example https://www.babylonjs-playground.com/#RNASML
  34173. */
  34174. boundingBoxSize: Vector3;
  34175. protected _rotationY: number;
  34176. /**
  34177. * Gets texture matrix rotation angle around Y axis radians.
  34178. */
  34179. /**
  34180. * Sets texture matrix rotation angle around Y axis in radians.
  34181. */
  34182. rotationY: number;
  34183. private _noMipmap;
  34184. private _files;
  34185. private _extensions;
  34186. private _textureMatrix;
  34187. private _format;
  34188. private _createPolynomials;
  34189. /** @hidden */
  34190. readonly _prefiltered: boolean;
  34191. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  34192. /**
  34193. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  34194. * @param url defines the url of the prefiltered texture
  34195. * @param scene defines the scene the texture is attached to
  34196. * @param forcedExtension defines the extension of the file if different from the url
  34197. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  34198. * @return the prefiltered texture
  34199. */
  34200. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  34201. /**
  34202. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  34203. * as prefiltered data.
  34204. * @param rootUrl defines the url of the texture or the root name of the six images
  34205. * @param scene defines the scene the texture is attached to
  34206. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  34207. * @param noMipmap defines if mipmaps should be created or not
  34208. * @param files defines the six files to load for the different faces
  34209. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  34210. * @param onError defines a callback triggered in case of error during load
  34211. * @param format defines the internal format to use for the texture once loaded
  34212. * @param prefiltered defines whether or not the texture is created from prefiltered data
  34213. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  34214. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  34215. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  34216. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  34217. * @return the cube texture
  34218. */
  34219. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  34220. delayLoad(): void;
  34221. getReflectionTextureMatrix(): Matrix;
  34222. setReflectionTextureMatrix(value: Matrix): void;
  34223. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  34224. clone(): CubeTexture;
  34225. }
  34226. }
  34227. declare module BABYLON {
  34228. /**
  34229. * A class extending {BABYLON.Texture} allowing drawing on a texture
  34230. * @see http://doc.babylonjs.com/how_to/dynamictexture
  34231. */
  34232. class DynamicTexture extends Texture {
  34233. private _generateMipMaps;
  34234. private _canvas;
  34235. private _context;
  34236. private _engine;
  34237. /**
  34238. * Creates a {BABYLON.DynamicTexture}
  34239. * @param name defines the name of the texture
  34240. * @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
  34241. * @param scene defines the scene where you want the texture
  34242. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  34243. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  34244. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  34245. */
  34246. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  34247. /**
  34248. * Gets the current state of canRescale
  34249. */
  34250. readonly canRescale: boolean;
  34251. private _recreate(textureSize);
  34252. /**
  34253. * Scales the texture
  34254. * @param ratio the scale factor to apply to both width and height
  34255. */
  34256. scale(ratio: number): void;
  34257. /**
  34258. * Resizes the texture
  34259. * @param width the new width
  34260. * @param height the new height
  34261. */
  34262. scaleTo(width: number, height: number): void;
  34263. /**
  34264. * Gets the context of the canvas used by the texture
  34265. * @returns the canvas context of the dynamic texture
  34266. */
  34267. getContext(): CanvasRenderingContext2D;
  34268. /**
  34269. * Clears the texture
  34270. */
  34271. clear(): void;
  34272. /**
  34273. * Updates the texture
  34274. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  34275. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  34276. */
  34277. update(invertY?: boolean, premulAlpha?: boolean): void;
  34278. /**
  34279. * Draws text onto the texture
  34280. * @param text defines the text to be drawn
  34281. * @param x defines the placement of the text from the left
  34282. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  34283. * @param font defines the font to be used with font-style, font-size, font-name
  34284. * @param color defines the color used for the text
  34285. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  34286. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  34287. * @param update defines whether texture is immediately update (default is true)
  34288. */
  34289. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  34290. /**
  34291. * Clones the texture
  34292. * @returns the clone of the texture.
  34293. */
  34294. clone(): DynamicTexture;
  34295. /** @hidden */
  34296. _rebuild(): void;
  34297. }
  34298. }
  34299. declare module BABYLON {
  34300. /**
  34301. * This represents a texture coming from an HDR input.
  34302. *
  34303. * The only supported format is currently panorama picture stored in RGBE format.
  34304. * Example of such files can be found on HDRLib: http://hdrlib.com/
  34305. */
  34306. class HDRCubeTexture extends BaseTexture {
  34307. private static _facesMapping;
  34308. private _generateHarmonics;
  34309. private _noMipmap;
  34310. private _textureMatrix;
  34311. private _size;
  34312. private _onLoad;
  34313. private _onError;
  34314. /**
  34315. * The texture URL.
  34316. */
  34317. url: string;
  34318. /**
  34319. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  34320. */
  34321. coordinatesMode: number;
  34322. protected _isBlocking: boolean;
  34323. /**
  34324. * Gets wether or not the texture is blocking during loading.
  34325. */
  34326. /**
  34327. * Sets wether or not the texture is blocking during loading.
  34328. */
  34329. isBlocking: boolean;
  34330. protected _rotationY: number;
  34331. /**
  34332. * Gets texture matrix rotation angle around Y axis radians.
  34333. */
  34334. /**
  34335. * Sets texture matrix rotation angle around Y axis in radians.
  34336. */
  34337. rotationY: number;
  34338. /**
  34339. * Gets or sets the center of the bounding box associated with the cube texture
  34340. * It must define where the camera used to render the texture was set
  34341. */
  34342. boundingBoxPosition: Vector3;
  34343. private _boundingBoxSize;
  34344. /**
  34345. * Gets or sets the size of the bounding box associated with the cube texture
  34346. * When defined, the cubemap will switch to local mode
  34347. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34348. * @example https://www.babylonjs-playground.com/#RNASML
  34349. */
  34350. boundingBoxSize: Vector3;
  34351. /**
  34352. * Instantiates an HDRTexture from the following parameters.
  34353. *
  34354. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  34355. * @param scene The scene the texture will be used in
  34356. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  34357. * @param noMipmap Forces to not generate the mipmap if true
  34358. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  34359. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  34360. * @param reserved Reserved flag for internal use.
  34361. */
  34362. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  34363. /**
  34364. * Occurs when the file is raw .hdr file.
  34365. */
  34366. private loadTexture();
  34367. clone(): HDRCubeTexture;
  34368. delayLoad(): void;
  34369. getReflectionTextureMatrix(): Matrix;
  34370. setReflectionTextureMatrix(value: Matrix): void;
  34371. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  34372. serialize(): any;
  34373. }
  34374. }
  34375. declare module BABYLON {
  34376. /**
  34377. * Class used to store data associated with WebGL texture data for the engine
  34378. * This class should not be used directly
  34379. */
  34380. class InternalTexture implements IInternalTextureTracker {
  34381. /**
  34382. * The source of the texture data is unknown
  34383. */
  34384. static DATASOURCE_UNKNOWN: number;
  34385. /**
  34386. * Texture data comes from an URL
  34387. */
  34388. static DATASOURCE_URL: number;
  34389. /**
  34390. * Texture data is only used for temporary storage
  34391. */
  34392. static DATASOURCE_TEMP: number;
  34393. /**
  34394. * Texture data comes from raw data (ArrayBuffer)
  34395. */
  34396. static DATASOURCE_RAW: number;
  34397. /**
  34398. * Texture content is dynamic (video or dynamic texture)
  34399. */
  34400. static DATASOURCE_DYNAMIC: number;
  34401. /**
  34402. * Texture content is generated by rendering to it
  34403. */
  34404. static DATASOURCE_RENDERTARGET: number;
  34405. /**
  34406. * Texture content is part of a multi render target process
  34407. */
  34408. static DATASOURCE_MULTIRENDERTARGET: number;
  34409. /**
  34410. * Texture data comes from a cube data file
  34411. */
  34412. static DATASOURCE_CUBE: number;
  34413. /**
  34414. * Texture data comes from a raw cube data
  34415. */
  34416. static DATASOURCE_CUBERAW: number;
  34417. /**
  34418. * Texture data come from a prefiltered cube data file
  34419. */
  34420. static DATASOURCE_CUBEPREFILTERED: number;
  34421. /**
  34422. * Texture content is raw 3D data
  34423. */
  34424. static DATASOURCE_RAW3D: number;
  34425. /**
  34426. * Texture content is a depth texture
  34427. */
  34428. static DATASOURCE_DEPTHTEXTURE: number;
  34429. /**
  34430. * Defines if the texture is ready
  34431. */
  34432. isReady: boolean;
  34433. /**
  34434. * Defines if the texture is a cube texture
  34435. */
  34436. isCube: boolean;
  34437. /**
  34438. * Defines if the texture contains 3D data
  34439. */
  34440. is3D: boolean;
  34441. /**
  34442. * Gets the URL used to load this texture
  34443. */
  34444. url: string;
  34445. /**
  34446. * Gets the sampling mode of the texture
  34447. */
  34448. samplingMode: number;
  34449. /**
  34450. * Gets a boolean indicating if the texture needs mipmaps generation
  34451. */
  34452. generateMipMaps: boolean;
  34453. /**
  34454. * Gets the number of samples used by the texture (WebGL2+ only)
  34455. */
  34456. samples: number;
  34457. /**
  34458. * Gets the type of the texture
  34459. */
  34460. type: number;
  34461. /**
  34462. * Gets the format of the texture
  34463. */
  34464. format: number;
  34465. /**
  34466. * Observable called when the texture is loaded
  34467. */
  34468. onLoadedObservable: Observable<InternalTexture>;
  34469. /**
  34470. * Gets the width of the texture
  34471. */
  34472. width: number;
  34473. /**
  34474. * Gets the height of the texture
  34475. */
  34476. height: number;
  34477. /**
  34478. * Gets the depth of the texture
  34479. */
  34480. depth: number;
  34481. /**
  34482. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  34483. */
  34484. baseWidth: number;
  34485. /**
  34486. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  34487. */
  34488. baseHeight: number;
  34489. /**
  34490. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  34491. */
  34492. baseDepth: number;
  34493. /**
  34494. * Gets a boolean indicating if the texture is inverted on Y axis
  34495. */
  34496. invertY: boolean;
  34497. /**
  34498. * Gets or set the previous tracker in the list
  34499. */
  34500. previous: Nullable<IInternalTextureTracker>;
  34501. /**
  34502. * Gets or set the next tracker in the list
  34503. */
  34504. next: Nullable<IInternalTextureTracker>;
  34505. /** @hidden */
  34506. _initialSlot: number;
  34507. /** @hidden */
  34508. _designatedSlot: number;
  34509. /** @hidden */
  34510. _dataSource: number;
  34511. /** @hidden */
  34512. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34513. /** @hidden */
  34514. _bufferView: Nullable<ArrayBufferView>;
  34515. /** @hidden */
  34516. _bufferViewArray: Nullable<ArrayBufferView[]>;
  34517. /** @hidden */
  34518. _size: number;
  34519. /** @hidden */
  34520. _extension: string;
  34521. /** @hidden */
  34522. _files: Nullable<string[]>;
  34523. /** @hidden */
  34524. _workingCanvas: HTMLCanvasElement;
  34525. /** @hidden */
  34526. _workingContext: CanvasRenderingContext2D;
  34527. /** @hidden */
  34528. _framebuffer: Nullable<WebGLFramebuffer>;
  34529. /** @hidden */
  34530. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  34531. /** @hidden */
  34532. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  34533. /** @hidden */
  34534. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  34535. /** @hidden */
  34536. _attachments: Nullable<number[]>;
  34537. /** @hidden */
  34538. _cachedCoordinatesMode: Nullable<number>;
  34539. /** @hidden */
  34540. _cachedWrapU: Nullable<number>;
  34541. /** @hidden */
  34542. _cachedWrapV: Nullable<number>;
  34543. /** @hidden */
  34544. _cachedWrapR: Nullable<number>;
  34545. /** @hidden */
  34546. _cachedAnisotropicFilteringLevel: Nullable<number>;
  34547. /** @hidden */
  34548. _isDisabled: boolean;
  34549. /** @hidden */
  34550. _compression: Nullable<string>;
  34551. /** @hidden */
  34552. _generateStencilBuffer: boolean;
  34553. /** @hidden */
  34554. _generateDepthBuffer: boolean;
  34555. /** @hidden */
  34556. _comparisonFunction: number;
  34557. /** @hidden */
  34558. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  34559. /** @hidden */
  34560. _lodGenerationScale: number;
  34561. /** @hidden */
  34562. _lodGenerationOffset: number;
  34563. /** @hidden */
  34564. _lodTextureHigh: BaseTexture;
  34565. /** @hidden */
  34566. _lodTextureMid: BaseTexture;
  34567. /** @hidden */
  34568. _lodTextureLow: BaseTexture;
  34569. /** @hidden */
  34570. _isRGBD: boolean;
  34571. /** @hidden */
  34572. _webGLTexture: Nullable<WebGLTexture>;
  34573. /** @hidden */
  34574. _references: number;
  34575. private _engine;
  34576. /**
  34577. * Gets the Engine the texture belongs to.
  34578. * @returns The babylon engine
  34579. */
  34580. getEngine(): Engine;
  34581. /**
  34582. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  34583. */
  34584. readonly dataSource: number;
  34585. /**
  34586. * Creates a new InternalTexture
  34587. * @param engine defines the engine to use
  34588. * @param dataSource defines the type of data that will be used
  34589. */
  34590. constructor(engine: Engine, dataSource: number);
  34591. /**
  34592. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  34593. */
  34594. incrementReferences(): void;
  34595. /**
  34596. * Change the size of the texture (not the size of the content)
  34597. * @param width defines the new width
  34598. * @param height defines the new height
  34599. * @param depth defines the new depth (1 by default)
  34600. */
  34601. updateSize(width: int, height: int, depth?: int): void;
  34602. /** @hidden */
  34603. _rebuild(): void;
  34604. _swapAndDie(target: InternalTexture): void;
  34605. /**
  34606. * Dispose the current allocated resources
  34607. */
  34608. dispose(): void;
  34609. }
  34610. }
  34611. declare module BABYLON {
  34612. /**
  34613. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  34614. */
  34615. interface IInternalTextureTracker {
  34616. /**
  34617. * Gets or set the previous tracker in the list
  34618. */
  34619. previous: Nullable<IInternalTextureTracker>;
  34620. /**
  34621. * Gets or set the next tracker in the list
  34622. */
  34623. next: Nullable<IInternalTextureTracker>;
  34624. }
  34625. /**
  34626. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  34627. */
  34628. class DummyInternalTextureTracker {
  34629. /**
  34630. * Gets or set the previous tracker in the list
  34631. */
  34632. previous: Nullable<IInternalTextureTracker>;
  34633. /**
  34634. * Gets or set the next tracker in the list
  34635. */
  34636. next: Nullable<IInternalTextureTracker>;
  34637. }
  34638. }
  34639. declare module BABYLON {
  34640. class MirrorTexture extends RenderTargetTexture {
  34641. private scene;
  34642. mirrorPlane: Plane;
  34643. private _transformMatrix;
  34644. private _mirrorMatrix;
  34645. private _savedViewMatrix;
  34646. private _blurX;
  34647. private _blurY;
  34648. private _adaptiveBlurKernel;
  34649. private _blurKernelX;
  34650. private _blurKernelY;
  34651. private _blurRatio;
  34652. blurRatio: number;
  34653. adaptiveBlurKernel: number;
  34654. blurKernel: number;
  34655. blurKernelX: number;
  34656. blurKernelY: number;
  34657. private _autoComputeBlurKernel();
  34658. protected _onRatioRescale(): void;
  34659. private _updateGammaSpace();
  34660. private _imageProcessingConfigChangeObserver;
  34661. constructor(name: string, size: number | {
  34662. width: number;
  34663. height: number;
  34664. } | {
  34665. ratio: number;
  34666. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  34667. private _preparePostProcesses();
  34668. clone(): MirrorTexture;
  34669. serialize(): any;
  34670. dispose(): void;
  34671. }
  34672. }
  34673. declare module BABYLON {
  34674. interface IMultiRenderTargetOptions {
  34675. generateMipMaps?: boolean;
  34676. types?: number[];
  34677. samplingModes?: number[];
  34678. generateDepthBuffer?: boolean;
  34679. generateStencilBuffer?: boolean;
  34680. generateDepthTexture?: boolean;
  34681. textureCount?: number;
  34682. doNotChangeAspectRatio?: boolean;
  34683. defaultType?: number;
  34684. }
  34685. class MultiRenderTarget extends RenderTargetTexture {
  34686. private _internalTextures;
  34687. private _textures;
  34688. readonly isSupported: boolean;
  34689. private _multiRenderTargetOptions;
  34690. readonly textures: Texture[];
  34691. readonly depthTexture: Texture;
  34692. wrapU: number;
  34693. wrapV: number;
  34694. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  34695. _rebuild(): void;
  34696. private _createInternalTextures();
  34697. private _createTextures();
  34698. samples: number;
  34699. resize(size: any): void;
  34700. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34701. dispose(): void;
  34702. releaseInternalTextures(): void;
  34703. }
  34704. }
  34705. declare module BABYLON {
  34706. class RawTexture extends Texture {
  34707. format: number;
  34708. private _engine;
  34709. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  34710. update(data: ArrayBufferView): void;
  34711. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34712. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34714. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34715. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34716. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  34717. }
  34718. }
  34719. declare module BABYLON {
  34720. /**
  34721. * Class used to store 3D textures containing user data
  34722. */
  34723. class RawTexture3D extends Texture {
  34724. /** Gets or sets the texture format to use */
  34725. format: number;
  34726. private _engine;
  34727. /**
  34728. * Create a new RawTexture3D
  34729. * @param data defines the data of the texture
  34730. * @param width defines the width of the texture
  34731. * @param height defines the height of the texture
  34732. * @param depth defines the depth of the texture
  34733. * @param format defines the texture format to use
  34734. * @param scene defines the hosting scene
  34735. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  34736. * @param invertY defines if texture must be stored with Y axis inverted
  34737. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  34738. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  34739. */
  34740. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  34741. /** Gets or sets the texture format to use */
  34742. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  34743. /**
  34744. * Update the texture with new data
  34745. * @param data defines the data to store in the texture
  34746. */
  34747. update(data: ArrayBufferView): void;
  34748. }
  34749. }
  34750. declare module BABYLON {
  34751. /**
  34752. * Creates a refraction texture used by refraction channel of the standard material.
  34753. * @param name the texture name
  34754. * @param size size of the underlying texture
  34755. * @param scene root scene
  34756. */
  34757. class RefractionTexture extends RenderTargetTexture {
  34758. refractionPlane: Plane;
  34759. depth: number;
  34760. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  34761. clone(): RefractionTexture;
  34762. serialize(): any;
  34763. }
  34764. }
  34765. declare module BABYLON {
  34766. class RenderTargetTexture extends Texture {
  34767. isCube: boolean;
  34768. static _REFRESHRATE_RENDER_ONCE: number;
  34769. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34770. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34771. static readonly REFRESHRATE_RENDER_ONCE: number;
  34772. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  34773. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  34774. /**
  34775. * Use this predicate to dynamically define the list of mesh you want to render.
  34776. * If set, the renderList property will be overwritten.
  34777. */
  34778. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  34779. /**
  34780. * Use this list to define the list of mesh you want to render.
  34781. */
  34782. renderList: Nullable<Array<AbstractMesh>>;
  34783. renderParticles: boolean;
  34784. renderSprites: boolean;
  34785. coordinatesMode: number;
  34786. activeCamera: Nullable<Camera>;
  34787. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  34788. useCameraPostProcesses: boolean;
  34789. ignoreCameraViewport: boolean;
  34790. private _postProcessManager;
  34791. private _postProcesses;
  34792. private _resizeObserver;
  34793. /**
  34794. * An event triggered when the texture is unbind.
  34795. */
  34796. onBeforeBindObservable: Observable<RenderTargetTexture>;
  34797. /**
  34798. * An event triggered when the texture is unbind.
  34799. */
  34800. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  34801. private _onAfterUnbindObserver;
  34802. onAfterUnbind: () => void;
  34803. /**
  34804. * An event triggered before rendering the texture
  34805. */
  34806. onBeforeRenderObservable: Observable<number>;
  34807. private _onBeforeRenderObserver;
  34808. onBeforeRender: (faceIndex: number) => void;
  34809. /**
  34810. * An event triggered after rendering the texture
  34811. */
  34812. onAfterRenderObservable: Observable<number>;
  34813. private _onAfterRenderObserver;
  34814. onAfterRender: (faceIndex: number) => void;
  34815. /**
  34816. * An event triggered after the texture clear
  34817. */
  34818. onClearObservable: Observable<Engine>;
  34819. private _onClearObserver;
  34820. onClear: (Engine: Engine) => void;
  34821. clearColor: Color4;
  34822. protected _size: number | {
  34823. width: number;
  34824. height: number;
  34825. };
  34826. protected _initialSizeParameter: number | {
  34827. width: number;
  34828. height: number;
  34829. } | {
  34830. ratio: number;
  34831. };
  34832. protected _sizeRatio: Nullable<number>;
  34833. _generateMipMaps: boolean;
  34834. protected _renderingManager: RenderingManager;
  34835. _waitingRenderList: string[];
  34836. protected _doNotChangeAspectRatio: boolean;
  34837. protected _currentRefreshId: number;
  34838. protected _refreshRate: number;
  34839. protected _textureMatrix: Matrix;
  34840. protected _samples: number;
  34841. protected _renderTargetOptions: RenderTargetCreationOptions;
  34842. readonly renderTargetOptions: RenderTargetCreationOptions;
  34843. protected _engine: Engine;
  34844. protected _onRatioRescale(): void;
  34845. /**
  34846. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  34847. * It must define where the camera used to render the texture is set
  34848. */
  34849. boundingBoxPosition: Vector3;
  34850. private _boundingBoxSize;
  34851. /**
  34852. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  34853. * When defined, the cubemap will switch to local mode
  34854. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34855. * @example https://www.babylonjs-playground.com/#RNASML
  34856. */
  34857. boundingBoxSize: Vector3;
  34858. /**
  34859. * In case the RTT has been created with a depth texture, get the associated
  34860. * depth texture.
  34861. * Otherwise, return null.
  34862. */
  34863. depthStencilTexture: Nullable<InternalTexture>;
  34864. /**
  34865. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  34866. * or used a shadow, depth texture...
  34867. * @param name The friendly name of the texture
  34868. * @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)
  34869. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  34870. * @param generateMipMaps True if mip maps need to be generated after render.
  34871. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  34872. * @param type The type of the buffer in the RTT (int, half float, float...)
  34873. * @param isCube True if a cube texture needs to be created
  34874. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  34875. * @param generateDepthBuffer True to generate a depth buffer
  34876. * @param generateStencilBuffer True to generate a stencil buffer
  34877. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  34878. */
  34879. constructor(name: string, size: number | {
  34880. width: number;
  34881. height: number;
  34882. } | {
  34883. ratio: number;
  34884. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  34885. /**
  34886. * Creates a depth stencil texture.
  34887. * This is only available in WebGL 2 or with the depth texture extension available.
  34888. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  34889. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  34890. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  34891. */
  34892. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  34893. private _processSizeParameter(size);
  34894. samples: number;
  34895. resetRefreshCounter(): void;
  34896. refreshRate: number;
  34897. addPostProcess(postProcess: PostProcess): void;
  34898. clearPostProcesses(dispose?: boolean): void;
  34899. removePostProcess(postProcess: PostProcess): void;
  34900. _shouldRender(): boolean;
  34901. getRenderSize(): number;
  34902. getRenderWidth(): number;
  34903. getRenderHeight(): number;
  34904. readonly canRescale: boolean;
  34905. scale(ratio: number): void;
  34906. getReflectionTextureMatrix(): Matrix;
  34907. resize(size: number | {
  34908. width: number;
  34909. height: number;
  34910. } | {
  34911. ratio: number;
  34912. }): void;
  34913. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  34914. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  34915. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34916. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  34917. /**
  34918. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34919. * This allowed control for front to back rendering or reversly depending of the special needs.
  34920. *
  34921. * @param renderingGroupId The rendering group id corresponding to its index
  34922. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34923. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34924. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34925. */
  34926. 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;
  34927. /**
  34928. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34929. *
  34930. * @param renderingGroupId The rendering group id corresponding to its index
  34931. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34932. */
  34933. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34934. clone(): RenderTargetTexture;
  34935. serialize(): any;
  34936. disposeFramebufferObjects(): void;
  34937. dispose(): void;
  34938. _rebuild(): void;
  34939. /**
  34940. * Clear the info related to rendering groups preventing retention point in material dispose.
  34941. */
  34942. freeRenderingGroups(): void;
  34943. }
  34944. }
  34945. declare module BABYLON {
  34946. class Texture extends BaseTexture {
  34947. static NEAREST_SAMPLINGMODE: number;
  34948. static NEAREST_NEAREST_MIPLINEAR: number;
  34949. static BILINEAR_SAMPLINGMODE: number;
  34950. static LINEAR_LINEAR_MIPNEAREST: number;
  34951. static TRILINEAR_SAMPLINGMODE: number;
  34952. static LINEAR_LINEAR_MIPLINEAR: number;
  34953. static NEAREST_NEAREST_MIPNEAREST: number;
  34954. static NEAREST_LINEAR_MIPNEAREST: number;
  34955. static NEAREST_LINEAR_MIPLINEAR: number;
  34956. static NEAREST_LINEAR: number;
  34957. static NEAREST_NEAREST: number;
  34958. static LINEAR_NEAREST_MIPNEAREST: number;
  34959. static LINEAR_NEAREST_MIPLINEAR: number;
  34960. static LINEAR_LINEAR: number;
  34961. static LINEAR_NEAREST: number;
  34962. static EXPLICIT_MODE: number;
  34963. static SPHERICAL_MODE: number;
  34964. static PLANAR_MODE: number;
  34965. static CUBIC_MODE: number;
  34966. static PROJECTION_MODE: number;
  34967. static SKYBOX_MODE: number;
  34968. static INVCUBIC_MODE: number;
  34969. static EQUIRECTANGULAR_MODE: number;
  34970. static FIXED_EQUIRECTANGULAR_MODE: number;
  34971. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34972. static CLAMP_ADDRESSMODE: number;
  34973. static WRAP_ADDRESSMODE: number;
  34974. static MIRROR_ADDRESSMODE: number;
  34975. /**
  34976. * 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
  34977. */
  34978. static UseSerializedUrlIfAny: boolean;
  34979. url: Nullable<string>;
  34980. uOffset: number;
  34981. vOffset: number;
  34982. uScale: number;
  34983. vScale: number;
  34984. uAng: number;
  34985. vAng: number;
  34986. wAng: number;
  34987. /**
  34988. * Defines the center of rotation (U)
  34989. */
  34990. uRotationCenter: number;
  34991. /**
  34992. * Defines the center of rotation (V)
  34993. */
  34994. vRotationCenter: number;
  34995. /**
  34996. * Defines the center of rotation (W)
  34997. */
  34998. wRotationCenter: number;
  34999. readonly noMipmap: boolean;
  35000. private _noMipmap;
  35001. _invertY: boolean;
  35002. private _rowGenerationMatrix;
  35003. private _cachedTextureMatrix;
  35004. private _projectionModeMatrix;
  35005. private _t0;
  35006. private _t1;
  35007. private _t2;
  35008. private _cachedUOffset;
  35009. private _cachedVOffset;
  35010. private _cachedUScale;
  35011. private _cachedVScale;
  35012. private _cachedUAng;
  35013. private _cachedVAng;
  35014. private _cachedWAng;
  35015. private _cachedProjectionMatrixId;
  35016. private _cachedCoordinatesMode;
  35017. _samplingMode: number;
  35018. /** @hidden */
  35019. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35020. private _deleteBuffer;
  35021. protected _format: Nullable<number>;
  35022. private _delayedOnLoad;
  35023. private _delayedOnError;
  35024. protected _onLoadObservable: Nullable<Observable<Texture>>;
  35025. protected _isBlocking: boolean;
  35026. isBlocking: boolean;
  35027. readonly samplingMode: number;
  35028. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  35029. /**
  35030. * Update the url (and optional buffer) of this texture if url was null during construction.
  35031. * @param url the url of the texture
  35032. * @param buffer the buffer of the texture (defaults to null)
  35033. */
  35034. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  35035. delayLoad(): void;
  35036. updateSamplingMode(samplingMode: number): void;
  35037. private _prepareRowForTextureGeneration(x, y, z, t);
  35038. getTextureMatrix(): Matrix;
  35039. getReflectionTextureMatrix(): Matrix;
  35040. clone(): Texture;
  35041. readonly onLoadObservable: Observable<Texture>;
  35042. serialize(): any;
  35043. getClassName(): string;
  35044. dispose(): void;
  35045. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  35046. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  35047. 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;
  35048. }
  35049. }
  35050. declare module BABYLON {
  35051. /**
  35052. * Settings for finer control over video usage
  35053. */
  35054. interface VideoTextureSettings {
  35055. /**
  35056. * Applies `autoplay` to video, if specified
  35057. */
  35058. autoPlay?: boolean;
  35059. /**
  35060. * Applies `loop` to video, if specified
  35061. */
  35062. loop?: boolean;
  35063. /**
  35064. * Automatically updates internal texture from video at every frame in the render loop
  35065. */
  35066. autoUpdateTexture: boolean;
  35067. /**
  35068. * Image src displayed during the video loading or until the user interacts with the video.
  35069. */
  35070. poster?: string;
  35071. }
  35072. class VideoTexture extends Texture {
  35073. /**
  35074. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35075. */
  35076. readonly autoUpdateTexture: boolean;
  35077. /**
  35078. * The video instance used by the texture internally
  35079. */
  35080. readonly video: HTMLVideoElement;
  35081. private _onUserActionRequestedObservable;
  35082. readonly onUserActionRequestedObservable: Observable<Texture>;
  35083. private _generateMipMaps;
  35084. private _engine;
  35085. private _stillImageCaptured;
  35086. /**
  35087. * Creates a video texture.
  35088. * Sample : https://doc.babylonjs.com/how_to/video_texture
  35089. * @param {string | null} name optional name, will detect from video source, if not defined
  35090. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  35091. * @param {BABYLON.Scene} scene is obviously the current scene.
  35092. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35093. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  35094. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35095. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  35096. */
  35097. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35098. private _getName(src);
  35099. private _getVideo(src);
  35100. private _createInternalTexture;
  35101. private reset;
  35102. /**
  35103. * Internal method to initiate `update`.
  35104. */
  35105. _rebuild(): void;
  35106. /**
  35107. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35108. */
  35109. update(): void;
  35110. /**
  35111. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35112. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35113. */
  35114. updateTexture(isVisible: boolean): void;
  35115. protected _updateInternalTexture: (e?: Event | undefined) => void;
  35116. /**
  35117. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35118. * @param url New url.
  35119. */
  35120. updateURL(url: string): void;
  35121. dispose(): void;
  35122. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35123. minWidth: number;
  35124. maxWidth: number;
  35125. minHeight: number;
  35126. maxHeight: number;
  35127. deviceId: string;
  35128. }): void;
  35129. }
  35130. }
  35131. declare var DracoDecoderModule: any;
  35132. declare var WebAssembly: any;
  35133. declare module BABYLON {
  35134. /**
  35135. * Configuration for Draco compression
  35136. */
  35137. interface IDracoCompressionConfiguration {
  35138. /**
  35139. * Configuration for the decoder.
  35140. */
  35141. decoder?: {
  35142. /**
  35143. * The url to the WebAssembly module.
  35144. */
  35145. wasmUrl?: string;
  35146. /**
  35147. * The url to the WebAssembly binary.
  35148. */
  35149. wasmBinaryUrl?: string;
  35150. /**
  35151. * The url to the fallback JavaScript module.
  35152. */
  35153. fallbackUrl?: string;
  35154. };
  35155. }
  35156. /**
  35157. * Draco compression (https://google.github.io/draco/)
  35158. *
  35159. * This class wraps the Draco module.
  35160. *
  35161. * **Encoder**
  35162. *
  35163. * The encoder is not currently implemented.
  35164. *
  35165. * **Decoder**
  35166. *
  35167. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  35168. *
  35169. * To update the configuration, use the following code:
  35170. * ```javascript
  35171. * BABYLON.DracoCompression.Configuration = {
  35172. * decoder: {
  35173. * wasmUrl: "<url to the WebAssembly library>",
  35174. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  35175. * fallbackUrl: "<url to the fallback JavaScript library>",
  35176. * }
  35177. * };
  35178. * ```
  35179. *
  35180. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  35181. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  35182. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  35183. *
  35184. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  35185. * ```javascript
  35186. * var dracoCompression = new BABYLON.DracoCompression();
  35187. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  35188. * [BABYLON.VertexBuffer.PositionKind]: 0
  35189. * });
  35190. * ```
  35191. *
  35192. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  35193. */
  35194. class DracoCompression implements IDisposable {
  35195. private static _DecoderModulePromise;
  35196. /**
  35197. * The configuration. Defaults to the following urls:
  35198. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  35199. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  35200. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  35201. */
  35202. static Configuration: IDracoCompressionConfiguration;
  35203. /**
  35204. * Returns true if the decoder is available.
  35205. */
  35206. static readonly DecoderAvailable: boolean;
  35207. /**
  35208. * Constructor
  35209. */
  35210. constructor();
  35211. /**
  35212. * Stop all async operations and release resources.
  35213. */
  35214. dispose(): void;
  35215. /**
  35216. * Decode Draco compressed mesh data to vertex data.
  35217. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  35218. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  35219. * @returns A promise that resolves with the decoded vertex data
  35220. */
  35221. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  35222. [kind: string]: number;
  35223. }): Promise<VertexData>;
  35224. private static _GetDecoderModule();
  35225. private static _LoadScriptAsync(url);
  35226. private static _LoadFileAsync(url);
  35227. }
  35228. }
  35229. declare module BABYLON {
  35230. /**
  35231. * Particle emitter emitting particles from the inside of a box.
  35232. * It emits the particles randomly between 2 given directions.
  35233. */
  35234. class BoxParticleEmitter implements IParticleEmitterType {
  35235. /**
  35236. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35237. */
  35238. direction1: Vector3;
  35239. /**
  35240. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35241. */
  35242. direction2: Vector3;
  35243. /**
  35244. * 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.
  35245. */
  35246. minEmitBox: Vector3;
  35247. /**
  35248. * 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.
  35249. */
  35250. maxEmitBox: Vector3;
  35251. /**
  35252. * Creates a new instance BoxParticleEmitter
  35253. */
  35254. constructor();
  35255. /**
  35256. * Called by the particle System when the direction is computed for the created particle.
  35257. * @param worldMatrix is the world matrix of the particle system
  35258. * @param directionToUpdate is the direction vector to update with the result
  35259. * @param particle is the particle we are computed the direction for
  35260. */
  35261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35262. /**
  35263. * Called by the particle System when the position is computed for the created particle.
  35264. * @param worldMatrix is the world matrix of the particle system
  35265. * @param positionToUpdate is the position vector to update with the result
  35266. * @param particle is the particle we are computed the position for
  35267. */
  35268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35269. /**
  35270. * Clones the current emitter and returns a copy of it
  35271. * @returns the new emitter
  35272. */
  35273. clone(): BoxParticleEmitter;
  35274. /**
  35275. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35276. * @param effect defines the update shader
  35277. */
  35278. applyToShader(effect: Effect): void;
  35279. /**
  35280. * Returns a string to use to update the GPU particles update shader
  35281. * @returns a string containng the defines string
  35282. */
  35283. getEffectDefines(): string;
  35284. /**
  35285. * Returns the string "BoxEmitter"
  35286. * @returns a string containing the class name
  35287. */
  35288. getClassName(): string;
  35289. /**
  35290. * Serializes the particle system to a JSON object.
  35291. * @returns the JSON object
  35292. */
  35293. serialize(): any;
  35294. /**
  35295. * Parse properties from a JSON object
  35296. * @param serializationObject defines the JSON object
  35297. */
  35298. parse(serializationObject: any): void;
  35299. }
  35300. }
  35301. declare module BABYLON {
  35302. /**
  35303. * Particle emitter emitting particles from the inside of a cone.
  35304. * It emits the particles alongside the cone volume from the base to the particle.
  35305. * The emission direction might be randomized.
  35306. */
  35307. class ConeParticleEmitter implements IParticleEmitterType {
  35308. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35309. directionRandomizer: number;
  35310. private _radius;
  35311. private _angle;
  35312. private _height;
  35313. /**
  35314. * Gets or sets the radius of the emission cone
  35315. */
  35316. radius: number;
  35317. /**
  35318. * Gets or sets the angle of the emission cone
  35319. */
  35320. angle: number;
  35321. private _buildHeight();
  35322. /**
  35323. * Creates a new instance ConeParticleEmitter
  35324. * @param radius the radius of the emission cone (1 by default)
  35325. * @param angles the cone base angle (PI by default)
  35326. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  35327. */
  35328. constructor(radius?: number, angle?: number,
  35329. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35330. directionRandomizer?: number);
  35331. /**
  35332. * Called by the particle System when the direction is computed for the created particle.
  35333. * @param worldMatrix is the world matrix of the particle system
  35334. * @param directionToUpdate is the direction vector to update with the result
  35335. * @param particle is the particle we are computed the direction for
  35336. */
  35337. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35338. /**
  35339. * Called by the particle System when the position is computed for the created particle.
  35340. * @param worldMatrix is the world matrix of the particle system
  35341. * @param positionToUpdate is the position vector to update with the result
  35342. * @param particle is the particle we are computed the position for
  35343. */
  35344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35345. /**
  35346. * Clones the current emitter and returns a copy of it
  35347. * @returns the new emitter
  35348. */
  35349. clone(): ConeParticleEmitter;
  35350. /**
  35351. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35352. * @param effect defines the update shader
  35353. */
  35354. applyToShader(effect: Effect): void;
  35355. /**
  35356. * Returns a string to use to update the GPU particles update shader
  35357. * @returns a string containng the defines string
  35358. */
  35359. getEffectDefines(): string;
  35360. /**
  35361. * Returns the string "BoxEmitter"
  35362. * @returns a string containing the class name
  35363. */
  35364. getClassName(): string;
  35365. /**
  35366. * Serializes the particle system to a JSON object.
  35367. * @returns the JSON object
  35368. */
  35369. serialize(): any;
  35370. /**
  35371. * Parse properties from a JSON object
  35372. * @param serializationObject defines the JSON object
  35373. */
  35374. parse(serializationObject: any): void;
  35375. }
  35376. }
  35377. declare module BABYLON {
  35378. /**
  35379. * Particle emitter represents a volume emitting particles.
  35380. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  35381. */
  35382. interface IParticleEmitterType {
  35383. /**
  35384. * Called by the particle System when the direction is computed for the created particle.
  35385. * @param worldMatrix is the world matrix of the particle system
  35386. * @param directionToUpdate is the direction vector to update with the result
  35387. * @param particle is the particle we are computed the direction for
  35388. */
  35389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35390. /**
  35391. * Called by the particle System when the position is computed for the created particle.
  35392. * @param worldMatrix is the world matrix of the particle system
  35393. * @param positionToUpdate is the position vector to update with the result
  35394. * @param particle is the particle we are computed the position for
  35395. */
  35396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35397. /**
  35398. * Clones the current emitter and returns a copy of it
  35399. * @returns the new emitter
  35400. */
  35401. clone(): IParticleEmitterType;
  35402. /**
  35403. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35404. * @param effect defines the update shader
  35405. */
  35406. applyToShader(effect: Effect): void;
  35407. /**
  35408. * Returns a string to use to update the GPU particles update shader
  35409. * @returns the effect defines string
  35410. */
  35411. getEffectDefines(): string;
  35412. /**
  35413. * Returns a string representing the class name
  35414. * @returns a string containing the class name
  35415. */
  35416. getClassName(): string;
  35417. /**
  35418. * Serializes the particle system to a JSON object.
  35419. * @returns the JSON object
  35420. */
  35421. serialize(): any;
  35422. /**
  35423. * Parse properties from a JSON object
  35424. * @param serializationObject defines the JSON object
  35425. */
  35426. parse(serializationObject: any): void;
  35427. }
  35428. }
  35429. declare module BABYLON {
  35430. /**
  35431. * Particle emitter emitting particles from the inside of a sphere.
  35432. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  35433. */
  35434. class SphereParticleEmitter implements IParticleEmitterType {
  35435. /**
  35436. * The radius of the emission sphere.
  35437. */
  35438. radius: number;
  35439. /**
  35440. * How much to randomize the particle direction [0-1].
  35441. */
  35442. directionRandomizer: number;
  35443. /**
  35444. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  35445. */
  35446. radiusRange: number;
  35447. /**
  35448. * Creates a new instance SphereParticleEmitter
  35449. * @param radius the radius of the emission sphere (1 by default)
  35450. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  35451. */
  35452. constructor(
  35453. /**
  35454. * The radius of the emission sphere.
  35455. */
  35456. radius?: number,
  35457. /**
  35458. * How much to randomize the particle direction [0-1].
  35459. */
  35460. directionRandomizer?: number);
  35461. /**
  35462. * Called by the particle System when the direction is computed for the created particle.
  35463. * @param worldMatrix is the world matrix of the particle system
  35464. * @param directionToUpdate is the direction vector to update with the result
  35465. * @param particle is the particle we are computed the direction for
  35466. */
  35467. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35468. /**
  35469. * Called by the particle System when the position is computed for the created particle.
  35470. * @param worldMatrix is the world matrix of the particle system
  35471. * @param positionToUpdate is the position vector to update with the result
  35472. * @param particle is the particle we are computed the position for
  35473. */
  35474. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35475. /**
  35476. * Clones the current emitter and returns a copy of it
  35477. * @returns the new emitter
  35478. */
  35479. clone(): SphereParticleEmitter;
  35480. /**
  35481. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35482. * @param effect defines the update shader
  35483. */
  35484. applyToShader(effect: Effect): void;
  35485. /**
  35486. * Returns a string to use to update the GPU particles update shader
  35487. * @returns a string containng the defines string
  35488. */
  35489. getEffectDefines(): string;
  35490. /**
  35491. * Returns the string "SphereParticleEmitter"
  35492. * @returns a string containing the class name
  35493. */
  35494. getClassName(): string;
  35495. /**
  35496. * Serializes the particle system to a JSON object.
  35497. * @returns the JSON object
  35498. */
  35499. serialize(): any;
  35500. /**
  35501. * Parse properties from a JSON object
  35502. * @param serializationObject defines the JSON object
  35503. */
  35504. parse(serializationObject: any): void;
  35505. }
  35506. /**
  35507. * Particle emitter emitting particles from the inside of a sphere.
  35508. * It emits the particles randomly between two vectors.
  35509. */
  35510. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  35511. /**
  35512. * The min limit of the emission direction.
  35513. */
  35514. direction1: Vector3;
  35515. /**
  35516. * The max limit of the emission direction.
  35517. */
  35518. direction2: Vector3;
  35519. /**
  35520. * Creates a new instance SphereDirectedParticleEmitter
  35521. * @param radius the radius of the emission sphere (1 by default)
  35522. * @param direction1 the min limit of the emission direction (up vector by default)
  35523. * @param direction2 the max limit of the emission direction (up vector by default)
  35524. */
  35525. constructor(radius?: number,
  35526. /**
  35527. * The min limit of the emission direction.
  35528. */
  35529. direction1?: Vector3,
  35530. /**
  35531. * The max limit of the emission direction.
  35532. */
  35533. direction2?: Vector3);
  35534. /**
  35535. * Called by the particle System when the direction is computed for the created particle.
  35536. * @param worldMatrix is the world matrix of the particle system
  35537. * @param directionToUpdate is the direction vector to update with the result
  35538. * @param particle is the particle we are computed the direction for
  35539. */
  35540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35541. /**
  35542. * Clones the current emitter and returns a copy of it
  35543. * @returns the new emitter
  35544. */
  35545. clone(): SphereDirectedParticleEmitter;
  35546. /**
  35547. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35548. * @param effect defines the update shader
  35549. */
  35550. applyToShader(effect: Effect): void;
  35551. /**
  35552. * Returns a string to use to update the GPU particles update shader
  35553. * @returns a string containng the defines string
  35554. */
  35555. getEffectDefines(): string;
  35556. /**
  35557. * Returns the string "SphereDirectedParticleEmitter"
  35558. * @returns a string containing the class name
  35559. */
  35560. getClassName(): string;
  35561. /**
  35562. * Serializes the particle system to a JSON object.
  35563. * @returns the JSON object
  35564. */
  35565. serialize(): any;
  35566. /**
  35567. * Parse properties from a JSON object
  35568. * @param serializationObject defines the JSON object
  35569. */
  35570. parse(serializationObject: any): void;
  35571. }
  35572. }
  35573. declare module BABYLON {
  35574. class CannonJSPlugin implements IPhysicsEnginePlugin {
  35575. private _useDeltaForWorldStep;
  35576. world: any;
  35577. name: string;
  35578. private _physicsMaterials;
  35579. private _fixedTimeStep;
  35580. BJSCANNON: any;
  35581. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  35582. setGravity(gravity: Vector3): void;
  35583. setTimeStep(timeStep: number): void;
  35584. getTimeStep(): number;
  35585. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35586. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35587. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35588. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35589. private _processChildMeshes(mainImpostor);
  35590. removePhysicsBody(impostor: PhysicsImpostor): void;
  35591. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35592. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35593. private _addMaterial(name, friction, restitution);
  35594. private _checkWithEpsilon(value);
  35595. private _createShape(impostor);
  35596. private _createHeightmap(object, pointDepth?);
  35597. private _minus90X;
  35598. private _plus90X;
  35599. private _tmpPosition;
  35600. private _tmpDeltaPosition;
  35601. private _tmpUnityRotation;
  35602. private _updatePhysicsBodyTransformation(impostor);
  35603. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35604. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35605. isSupported(): boolean;
  35606. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35607. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35608. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35609. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35610. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35611. getBodyMass(impostor: PhysicsImpostor): number;
  35612. getBodyFriction(impostor: PhysicsImpostor): number;
  35613. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35614. getBodyRestitution(impostor: PhysicsImpostor): number;
  35615. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35616. sleepBody(impostor: PhysicsImpostor): void;
  35617. wakeUpBody(impostor: PhysicsImpostor): void;
  35618. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35619. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  35620. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  35621. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35622. getRadius(impostor: PhysicsImpostor): number;
  35623. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35624. dispose(): void;
  35625. private _extendNamespace();
  35626. }
  35627. }
  35628. declare module BABYLON {
  35629. class OimoJSPlugin implements IPhysicsEnginePlugin {
  35630. world: any;
  35631. name: string;
  35632. BJSOIMO: any;
  35633. constructor(iterations?: number);
  35634. setGravity(gravity: Vector3): void;
  35635. setTimeStep(timeStep: number): void;
  35636. getTimeStep(): number;
  35637. private _tmpImpostorsArray;
  35638. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35639. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35640. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35641. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35642. private _tmpPositionVector;
  35643. removePhysicsBody(impostor: PhysicsImpostor): void;
  35644. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35645. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35646. isSupported(): boolean;
  35647. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35648. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35649. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35650. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35651. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35652. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35653. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35654. getBodyMass(impostor: PhysicsImpostor): number;
  35655. getBodyFriction(impostor: PhysicsImpostor): number;
  35656. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35657. getBodyRestitution(impostor: PhysicsImpostor): number;
  35658. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35659. sleepBody(impostor: PhysicsImpostor): void;
  35660. wakeUpBody(impostor: PhysicsImpostor): void;
  35661. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35662. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  35663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  35664. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35665. getRadius(impostor: PhysicsImpostor): number;
  35666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35667. dispose(): void;
  35668. }
  35669. }
  35670. declare module BABYLON {
  35671. /**
  35672. * This represents a set of one or more post processes in Babylon.
  35673. * A post process can be used to apply a shader to a texture after it is rendered.
  35674. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  35675. */
  35676. class PostProcessRenderEffect {
  35677. private _postProcesses;
  35678. private _getPostProcesses;
  35679. private _singleInstance;
  35680. private _cameras;
  35681. private _indicesForCamera;
  35682. /**
  35683. * Name of the effect
  35684. */
  35685. _name: string;
  35686. /**
  35687. * Instantiates a post process render effect.
  35688. * A post process can be used to apply a shader to a texture after it is rendered.
  35689. * @param engine The engine the effect is tied to
  35690. * @param name The name of the effect
  35691. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  35692. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  35693. */
  35694. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  35695. /**
  35696. * Checks if all the post processes in the effect are supported.
  35697. */
  35698. readonly isSupported: boolean;
  35699. /**
  35700. * Updates the current state of the effect
  35701. */
  35702. _update(): void;
  35703. /**
  35704. * Attaches the effect on cameras
  35705. * @param cameras The camera to attach to.
  35706. */
  35707. _attachCameras(cameras: Camera): void;
  35708. /**
  35709. * Attaches the effect on cameras
  35710. * @param cameras The camera to attach to.
  35711. */
  35712. _attachCameras(cameras: Camera[]): void;
  35713. /**
  35714. * Detatches the effect on cameras
  35715. * @param cameras The camera to detatch from.
  35716. */
  35717. _detachCameras(cameras: Camera): void;
  35718. /**
  35719. * Detatches the effect on cameras
  35720. * @param cameras The camera to detatch from.
  35721. */
  35722. _detachCameras(cameras: Camera[]): void;
  35723. /**
  35724. * Enables the effect on given cameras
  35725. * @param cameras The camera to enable.
  35726. */
  35727. _enable(cameras: Camera): void;
  35728. /**
  35729. * Enables the effect on given cameras
  35730. * @param cameras The camera to enable.
  35731. */
  35732. _enable(cameras: Nullable<Camera[]>): void;
  35733. /**
  35734. * Disables the effect on the given cameras
  35735. * @param cameras The camera to disable.
  35736. */
  35737. _disable(cameras: Camera): void;
  35738. /**
  35739. * Disables the effect on the given cameras
  35740. * @param cameras The camera to disable.
  35741. */
  35742. _disable(cameras: Nullable<Camera[]>): void;
  35743. /**
  35744. * Gets a list of the post processes contained in the effect.
  35745. * @param camera The camera to get the post processes on.
  35746. * @returns The list of the post processes in the effect.
  35747. */
  35748. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  35749. }
  35750. }
  35751. declare module BABYLON {
  35752. class PostProcessRenderPipeline {
  35753. private engine;
  35754. private _renderEffects;
  35755. private _renderEffectsForIsolatedPass;
  35756. protected _cameras: Camera[];
  35757. _name: string;
  35758. constructor(engine: Engine, name: string);
  35759. getClassName(): string;
  35760. readonly isSupported: boolean;
  35761. addEffect(renderEffect: PostProcessRenderEffect): void;
  35762. _rebuild(): void;
  35763. _enableEffect(renderEffectName: string, cameras: Camera): void;
  35764. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  35765. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  35766. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  35767. _attachCameras(cameras: Camera, unique: boolean): void;
  35768. _attachCameras(cameras: Camera[], unique: boolean): void;
  35769. _detachCameras(cameras: Camera): void;
  35770. _detachCameras(cameras: Nullable<Camera[]>): void;
  35771. _update(): void;
  35772. _reset(): void;
  35773. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  35774. dispose(): void;
  35775. }
  35776. }
  35777. declare module BABYLON {
  35778. class PostProcessRenderPipelineManager {
  35779. private _renderPipelines;
  35780. constructor();
  35781. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  35782. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  35783. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  35784. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  35785. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  35786. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35787. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35788. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  35789. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  35790. update(): void;
  35791. _rebuild(): void;
  35792. dispose(): void;
  35793. }
  35794. }
  35795. declare module BABYLON {
  35796. /**
  35797. * Helper class dealing with the extraction of spherical polynomial dataArray
  35798. * from a cube map.
  35799. */
  35800. class CubeMapToSphericalPolynomialTools {
  35801. private static FileFaces;
  35802. /**
  35803. * Converts a texture to the according Spherical Polynomial data.
  35804. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35805. *
  35806. * @param texture The texture to extract the information from.
  35807. * @return The Spherical Polynomial data.
  35808. */
  35809. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  35810. /**
  35811. * Converts a cubemap to the according Spherical Polynomial data.
  35812. * This extracts the first 3 orders only as they are the only one used in the lighting.
  35813. *
  35814. * @param cubeInfo The Cube map to extract the information from.
  35815. * @return The Spherical Polynomial data.
  35816. */
  35817. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  35818. }
  35819. }
  35820. declare module BABYLON {
  35821. /**
  35822. * Header information of HDR texture files.
  35823. */
  35824. interface HDRInfo {
  35825. /**
  35826. * The height of the texture in pixels.
  35827. */
  35828. height: number;
  35829. /**
  35830. * The width of the texture in pixels.
  35831. */
  35832. width: number;
  35833. /**
  35834. * The index of the beginning of the data in the binary file.
  35835. */
  35836. dataPosition: number;
  35837. }
  35838. /**
  35839. * This groups tools to convert HDR texture to native colors array.
  35840. */
  35841. class HDRTools {
  35842. private static Ldexp(mantissa, exponent);
  35843. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  35844. private static readStringLine(uint8array, startIndex);
  35845. /**
  35846. * Reads header information from an RGBE texture stored in a native array.
  35847. * More information on this format are available here:
  35848. * https://en.wikipedia.org/wiki/RGBE_image_format
  35849. *
  35850. * @param uint8array The binary file stored in native array.
  35851. * @return The header information.
  35852. */
  35853. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  35854. /**
  35855. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  35856. * This RGBE texture needs to store the information as a panorama.
  35857. *
  35858. * More information on this format are available here:
  35859. * https://en.wikipedia.org/wiki/RGBE_image_format
  35860. *
  35861. * @param buffer The binary file stored in an array buffer.
  35862. * @param size The expected size of the extracted cubemap.
  35863. * @return The Cube Map information.
  35864. */
  35865. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  35866. /**
  35867. * Returns the pixels data extracted from an RGBE texture.
  35868. * This pixels will be stored left to right up to down in the R G B order in one array.
  35869. *
  35870. * More information on this format are available here:
  35871. * https://en.wikipedia.org/wiki/RGBE_image_format
  35872. *
  35873. * @param uint8array The binary file stored in an array buffer.
  35874. * @param hdrInfo The header information of the file.
  35875. * @return The pixels data in RGB right to left up to down order.
  35876. */
  35877. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  35878. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  35879. }
  35880. }
  35881. declare module BABYLON {
  35882. /**
  35883. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  35884. */
  35885. interface CubeMapInfo {
  35886. /**
  35887. * The pixel array for the front face.
  35888. * This is stored in format, left to right, up to down format.
  35889. */
  35890. front: Nullable<ArrayBufferView>;
  35891. /**
  35892. * The pixel array for the back face.
  35893. * This is stored in format, left to right, up to down format.
  35894. */
  35895. back: Nullable<ArrayBufferView>;
  35896. /**
  35897. * The pixel array for the left face.
  35898. * This is stored in format, left to right, up to down format.
  35899. */
  35900. left: Nullable<ArrayBufferView>;
  35901. /**
  35902. * The pixel array for the right face.
  35903. * This is stored in format, left to right, up to down format.
  35904. */
  35905. right: Nullable<ArrayBufferView>;
  35906. /**
  35907. * The pixel array for the up face.
  35908. * This is stored in format, left to right, up to down format.
  35909. */
  35910. up: Nullable<ArrayBufferView>;
  35911. /**
  35912. * The pixel array for the down face.
  35913. * This is stored in format, left to right, up to down format.
  35914. */
  35915. down: Nullable<ArrayBufferView>;
  35916. /**
  35917. * The size of the cubemap stored.
  35918. *
  35919. * Each faces will be size * size pixels.
  35920. */
  35921. size: number;
  35922. /**
  35923. * The format of the texture.
  35924. *
  35925. * RGBA, RGB.
  35926. */
  35927. format: number;
  35928. /**
  35929. * The type of the texture data.
  35930. *
  35931. * UNSIGNED_INT, FLOAT.
  35932. */
  35933. type: number;
  35934. /**
  35935. * Specifies whether the texture is in gamma space.
  35936. */
  35937. gammaSpace: boolean;
  35938. }
  35939. /**
  35940. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  35941. */
  35942. class PanoramaToCubeMapTools {
  35943. private static FACE_FRONT;
  35944. private static FACE_BACK;
  35945. private static FACE_RIGHT;
  35946. private static FACE_LEFT;
  35947. private static FACE_DOWN;
  35948. private static FACE_UP;
  35949. /**
  35950. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  35951. *
  35952. * @param float32Array The source data.
  35953. * @param inputWidth The width of the input panorama.
  35954. * @param inputhHeight The height of the input panorama.
  35955. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  35956. * @return The cubemap data
  35957. */
  35958. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  35959. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  35960. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  35961. }
  35962. }
  35963. declare module BABYLON {
  35964. class CustomProceduralTexture extends ProceduralTexture {
  35965. private _animate;
  35966. private _time;
  35967. private _config;
  35968. private _texturePath;
  35969. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  35970. private loadJson(jsonUrl);
  35971. isReady(): boolean;
  35972. render(useCameraPostProcess?: boolean): void;
  35973. updateTextures(): void;
  35974. updateShaderUniforms(): void;
  35975. animate: boolean;
  35976. }
  35977. }
  35978. declare module BABYLON {
  35979. class ProceduralTexture extends Texture {
  35980. isCube: boolean;
  35981. private _size;
  35982. _generateMipMaps: boolean;
  35983. isEnabled: boolean;
  35984. private _currentRefreshId;
  35985. private _refreshRate;
  35986. onGenerated: () => void;
  35987. private _vertexBuffers;
  35988. private _indexBuffer;
  35989. private _effect;
  35990. private _uniforms;
  35991. private _samplers;
  35992. private _fragment;
  35993. _textures: {
  35994. [key: string]: Texture;
  35995. };
  35996. private _floats;
  35997. private _floatsArrays;
  35998. private _colors3;
  35999. private _colors4;
  36000. private _vectors2;
  36001. private _vectors3;
  36002. private _matrices;
  36003. private _fallbackTexture;
  36004. private _fallbackTextureUsed;
  36005. private _engine;
  36006. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  36007. private _createIndexBuffer();
  36008. _rebuild(): void;
  36009. reset(): void;
  36010. isReady(): boolean;
  36011. resetRefreshCounter(): void;
  36012. setFragment(fragment: any): void;
  36013. refreshRate: number;
  36014. _shouldRender(): boolean;
  36015. getRenderSize(): number;
  36016. resize(size: number, generateMipMaps: boolean): void;
  36017. private _checkUniform(uniformName);
  36018. setTexture(name: string, texture: Texture): ProceduralTexture;
  36019. setFloat(name: string, value: number): ProceduralTexture;
  36020. setFloats(name: string, value: number[]): ProceduralTexture;
  36021. setColor3(name: string, value: Color3): ProceduralTexture;
  36022. setColor4(name: string, value: Color4): ProceduralTexture;
  36023. setVector2(name: string, value: Vector2): ProceduralTexture;
  36024. setVector3(name: string, value: Vector3): ProceduralTexture;
  36025. setMatrix(name: string, value: Matrix): ProceduralTexture;
  36026. render(useCameraPostProcess?: boolean): void;
  36027. clone(): ProceduralTexture;
  36028. dispose(): void;
  36029. }
  36030. }
  36031. declare module BABYLON {
  36032. /**
  36033. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  36034. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  36035. */
  36036. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36037. private _scene;
  36038. private _originalCameras;
  36039. /**
  36040. * ID of the sharpen post process,
  36041. */
  36042. private readonly SharpenPostProcessId;
  36043. /**
  36044. * ID of the image processing post process;
  36045. */
  36046. readonly ImageProcessingPostProcessId: string;
  36047. /**
  36048. * ID of the Fast Approximate Anti-Aliasing post process;
  36049. */
  36050. readonly FxaaPostProcessId: string;
  36051. /**
  36052. * ID of the chromatic aberration post process,
  36053. */
  36054. private readonly ChromaticAberrationPostProcessId;
  36055. /**
  36056. * ID of the grain post process
  36057. */
  36058. private readonly GrainPostProcessId;
  36059. /**
  36060. * Sharpen post process which will apply a sharpen convolution to enhance edges
  36061. */
  36062. sharpen: SharpenPostProcess;
  36063. private _sharpenEffect;
  36064. private bloom;
  36065. /**
  36066. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  36067. */
  36068. depthOfField: DepthOfFieldEffect;
  36069. /**
  36070. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  36071. */
  36072. fxaa: FxaaPostProcess;
  36073. /**
  36074. * Image post processing pass used to perform operations such as tone mapping or color grading.
  36075. */
  36076. imageProcessing: ImageProcessingPostProcess;
  36077. /**
  36078. * Chromatic aberration post process which will shift rgb colors in the image
  36079. */
  36080. chromaticAberration: ChromaticAberrationPostProcess;
  36081. private _chromaticAberrationEffect;
  36082. /**
  36083. * Grain post process which add noise to the image
  36084. */
  36085. grain: GrainPostProcess;
  36086. private _grainEffect;
  36087. /**
  36088. * Glow post process which adds a glow to emmisive areas of the image
  36089. */
  36090. private _glowLayer;
  36091. /**
  36092. * Animations which can be used to tweak settings over a period of time
  36093. */
  36094. animations: Animation[];
  36095. private _imageProcessingConfigurationObserver;
  36096. private _sharpenEnabled;
  36097. private _bloomEnabled;
  36098. private _depthOfFieldEnabled;
  36099. private _depthOfFieldBlurLevel;
  36100. private _fxaaEnabled;
  36101. private _imageProcessingEnabled;
  36102. private _defaultPipelineTextureType;
  36103. private _bloomScale;
  36104. private _chromaticAberrationEnabled;
  36105. private _grainEnabled;
  36106. private _buildAllowed;
  36107. /**
  36108. * Enable or disable the sharpen process from the pipeline
  36109. */
  36110. sharpenEnabled: boolean;
  36111. private _resizeObserver;
  36112. private _hardwareScaleLevel;
  36113. private _bloomKernel;
  36114. /**
  36115. * Specifies the size of the bloom blur kernel, relative to the final output size
  36116. */
  36117. bloomKernel: number;
  36118. /**
  36119. * Specifies the weight of the bloom in the final rendering
  36120. */
  36121. private _bloomWeight;
  36122. /**
  36123. * Specifies the luma threshold for the area that will be blurred by the bloom
  36124. */
  36125. private _bloomThreshold;
  36126. private _hdr;
  36127. /**
  36128. * The strength of the bloom.
  36129. */
  36130. bloomWeight: number;
  36131. /**
  36132. * The strength of the bloom.
  36133. */
  36134. bloomThreshold: number;
  36135. /**
  36136. * The scale of the bloom, lower value will provide better performance.
  36137. */
  36138. bloomScale: number;
  36139. /**
  36140. * Enable or disable the bloom from the pipeline
  36141. */
  36142. bloomEnabled: boolean;
  36143. private _rebuildBloom();
  36144. /**
  36145. * If the depth of field is enabled.
  36146. */
  36147. depthOfFieldEnabled: boolean;
  36148. /**
  36149. * Blur level of the depth of field effect. (Higher blur will effect performance)
  36150. */
  36151. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  36152. /**
  36153. * If the anti aliasing is enabled.
  36154. */
  36155. fxaaEnabled: boolean;
  36156. private _samples;
  36157. /**
  36158. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  36159. */
  36160. samples: number;
  36161. /**
  36162. * If image processing is enabled.
  36163. */
  36164. imageProcessingEnabled: boolean;
  36165. /**
  36166. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  36167. */
  36168. glowLayerEnabled: boolean;
  36169. /**
  36170. * Enable or disable the chromaticAberration process from the pipeline
  36171. */
  36172. chromaticAberrationEnabled: boolean;
  36173. /**
  36174. * Enable or disable the grain process from the pipeline
  36175. */
  36176. grainEnabled: boolean;
  36177. /**
  36178. * @constructor
  36179. * @param {string} name - The rendering pipeline name (default: "")
  36180. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  36181. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  36182. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  36183. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  36184. */
  36185. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  36186. /**
  36187. * Force the compilation of the entire pipeline.
  36188. */
  36189. prepare(): void;
  36190. private _hasCleared;
  36191. private _prevPostProcess;
  36192. private _prevPrevPostProcess;
  36193. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  36194. private _buildPipeline();
  36195. private _disposePostProcesses(disposeNonRecreated?);
  36196. /**
  36197. * Dispose of the pipeline and stop all post processes
  36198. */
  36199. dispose(): void;
  36200. /**
  36201. * Serialize the rendering pipeline (Used when exporting)
  36202. * @returns the serialized object
  36203. */
  36204. serialize(): any;
  36205. /**
  36206. * Parse the serialized pipeline
  36207. * @param source Source pipeline.
  36208. * @param scene The scene to load the pipeline to.
  36209. * @param rootUrl The URL of the serialized pipeline.
  36210. * @returns An instantiated pipeline from the serialized object.
  36211. */
  36212. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  36213. }
  36214. }
  36215. declare module BABYLON {
  36216. class LensRenderingPipeline extends PostProcessRenderPipeline {
  36217. /**
  36218. * The chromatic aberration PostProcess id in the pipeline
  36219. */
  36220. LensChromaticAberrationEffect: string;
  36221. /**
  36222. * The highlights enhancing PostProcess id in the pipeline
  36223. */
  36224. HighlightsEnhancingEffect: string;
  36225. /**
  36226. * The depth-of-field PostProcess id in the pipeline
  36227. */
  36228. LensDepthOfFieldEffect: string;
  36229. private _scene;
  36230. private _depthTexture;
  36231. private _grainTexture;
  36232. private _chromaticAberrationPostProcess;
  36233. private _highlightsPostProcess;
  36234. private _depthOfFieldPostProcess;
  36235. private _edgeBlur;
  36236. private _grainAmount;
  36237. private _chromaticAberration;
  36238. private _distortion;
  36239. private _highlightsGain;
  36240. private _highlightsThreshold;
  36241. private _dofDistance;
  36242. private _dofAperture;
  36243. private _dofDarken;
  36244. private _dofPentagon;
  36245. private _blurNoise;
  36246. /**
  36247. * @constructor
  36248. *
  36249. * Effect parameters are as follow:
  36250. * {
  36251. * chromatic_aberration: number; // from 0 to x (1 for realism)
  36252. * edge_blur: number; // from 0 to x (1 for realism)
  36253. * distortion: number; // from 0 to x (1 for realism)
  36254. * grain_amount: number; // from 0 to 1
  36255. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  36256. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  36257. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  36258. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  36259. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  36260. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  36261. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  36262. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  36263. * }
  36264. * Note: if an effect parameter is unset, effect is disabled
  36265. *
  36266. * @param {string} name - The rendering pipeline name
  36267. * @param {object} parameters - An object containing all parameters (see above)
  36268. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36269. * @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)
  36270. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36271. */
  36272. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  36273. setEdgeBlur(amount: number): void;
  36274. disableEdgeBlur(): void;
  36275. setGrainAmount(amount: number): void;
  36276. disableGrain(): void;
  36277. setChromaticAberration(amount: number): void;
  36278. disableChromaticAberration(): void;
  36279. setEdgeDistortion(amount: number): void;
  36280. disableEdgeDistortion(): void;
  36281. setFocusDistance(amount: number): void;
  36282. disableDepthOfField(): void;
  36283. setAperture(amount: number): void;
  36284. setDarkenOutOfFocus(amount: number): void;
  36285. enablePentagonBokeh(): void;
  36286. disablePentagonBokeh(): void;
  36287. enableNoiseBlur(): void;
  36288. disableNoiseBlur(): void;
  36289. setHighlightsGain(amount: number): void;
  36290. setHighlightsThreshold(amount: number): void;
  36291. disableHighlights(): void;
  36292. /**
  36293. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  36294. */
  36295. dispose(disableDepthRender?: boolean): void;
  36296. private _createChromaticAberrationPostProcess(ratio);
  36297. private _createHighlightsPostProcess(ratio);
  36298. private _createDepthOfFieldPostProcess(ratio);
  36299. private _createGrainTexture();
  36300. }
  36301. }
  36302. declare module BABYLON {
  36303. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  36304. /**
  36305. * The PassPostProcess id in the pipeline that contains the original scene color
  36306. */
  36307. SSAOOriginalSceneColorEffect: string;
  36308. /**
  36309. * The SSAO PostProcess id in the pipeline
  36310. */
  36311. SSAORenderEffect: string;
  36312. /**
  36313. * The horizontal blur PostProcess id in the pipeline
  36314. */
  36315. SSAOBlurHRenderEffect: string;
  36316. /**
  36317. * The vertical blur PostProcess id in the pipeline
  36318. */
  36319. SSAOBlurVRenderEffect: string;
  36320. /**
  36321. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  36322. */
  36323. SSAOCombineRenderEffect: string;
  36324. /**
  36325. * The output strength of the SSAO post-process. Default value is 1.0.
  36326. */
  36327. totalStrength: number;
  36328. /**
  36329. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  36330. */
  36331. maxZ: number;
  36332. /**
  36333. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  36334. */
  36335. minZAspect: number;
  36336. /**
  36337. * Number of samples used for the SSAO calculations. Default value is 8
  36338. */
  36339. private _samples;
  36340. /**
  36341. * Ratio object used for SSAO ratio and blur ratio
  36342. */
  36343. private _ratio;
  36344. /**
  36345. * Dynamically generated sphere sampler.
  36346. */
  36347. private _sampleSphere;
  36348. /**
  36349. * Blur filter offsets
  36350. */
  36351. private _samplerOffsets;
  36352. samples: number;
  36353. /**
  36354. * Are we using bilateral blur ?
  36355. */
  36356. private _expensiveBlur;
  36357. expensiveBlur: boolean;
  36358. /**
  36359. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  36360. */
  36361. radius: number;
  36362. /**
  36363. * The base color of the SSAO post-process
  36364. * The final result is "base + ssao" between [0, 1]
  36365. */
  36366. base: number;
  36367. /**
  36368. * Support test.
  36369. */
  36370. static readonly IsSupported: boolean;
  36371. private _scene;
  36372. private _depthTexture;
  36373. private _normalTexture;
  36374. private _randomTexture;
  36375. private _originalColorPostProcess;
  36376. private _ssaoPostProcess;
  36377. private _blurHPostProcess;
  36378. private _blurVPostProcess;
  36379. private _ssaoCombinePostProcess;
  36380. private _firstUpdate;
  36381. /**
  36382. * @constructor
  36383. * @param {string} name - The rendering pipeline name
  36384. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36385. * @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 }
  36386. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36387. */
  36388. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36389. /**
  36390. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36391. */
  36392. dispose(disableGeometryBufferRenderer?: boolean): void;
  36393. private _createBlurPostProcess(ssaoRatio, blurRatio);
  36394. _rebuild(): void;
  36395. private _generateHemisphere();
  36396. private _createSSAOPostProcess(ratio);
  36397. private _createSSAOCombinePostProcess(ratio);
  36398. private _createRandomTexture();
  36399. /**
  36400. * Serialize the rendering pipeline (Used when exporting)
  36401. * @returns the serialized object
  36402. */
  36403. serialize(): any;
  36404. /**
  36405. * Parse the serialized pipeline
  36406. * @param source Source pipeline.
  36407. * @param scene The scene to load the pipeline to.
  36408. * @param rootUrl The URL of the serialized pipeline.
  36409. * @returns An instantiated pipeline from the serialized object.
  36410. */
  36411. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  36412. }
  36413. }
  36414. declare module BABYLON {
  36415. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  36416. /**
  36417. * The PassPostProcess id in the pipeline that contains the original scene color
  36418. */
  36419. SSAOOriginalSceneColorEffect: string;
  36420. /**
  36421. * The SSAO PostProcess id in the pipeline
  36422. */
  36423. SSAORenderEffect: string;
  36424. /**
  36425. * The horizontal blur PostProcess id in the pipeline
  36426. */
  36427. SSAOBlurHRenderEffect: string;
  36428. /**
  36429. * The vertical blur PostProcess id in the pipeline
  36430. */
  36431. SSAOBlurVRenderEffect: string;
  36432. /**
  36433. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  36434. */
  36435. SSAOCombineRenderEffect: string;
  36436. /**
  36437. * The output strength of the SSAO post-process. Default value is 1.0.
  36438. */
  36439. totalStrength: number;
  36440. /**
  36441. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  36442. */
  36443. radius: number;
  36444. /**
  36445. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  36446. * Must not be equal to fallOff and superior to fallOff.
  36447. * Default value is 0.975
  36448. */
  36449. area: number;
  36450. /**
  36451. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  36452. * Must not be equal to area and inferior to area.
  36453. * Default value is 0.0
  36454. */
  36455. fallOff: number;
  36456. /**
  36457. * The base color of the SSAO post-process
  36458. * The final result is "base + ssao" between [0, 1]
  36459. */
  36460. base: number;
  36461. private _scene;
  36462. private _depthTexture;
  36463. private _randomTexture;
  36464. private _originalColorPostProcess;
  36465. private _ssaoPostProcess;
  36466. private _blurHPostProcess;
  36467. private _blurVPostProcess;
  36468. private _ssaoCombinePostProcess;
  36469. private _firstUpdate;
  36470. /**
  36471. * @constructor
  36472. * @param {string} name - The rendering pipeline name
  36473. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36474. * @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 }
  36475. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36476. */
  36477. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36478. /**
  36479. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36480. */
  36481. dispose(disableDepthRender?: boolean): void;
  36482. private _createBlurPostProcess(ratio);
  36483. _rebuild(): void;
  36484. private _createSSAOPostProcess(ratio);
  36485. private _createSSAOCombinePostProcess(ratio);
  36486. private _createRandomTexture();
  36487. }
  36488. }
  36489. declare module BABYLON {
  36490. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36491. /**
  36492. * Public members
  36493. */
  36494. originalPostProcess: Nullable<PostProcess>;
  36495. downSampleX4PostProcess: Nullable<PostProcess>;
  36496. brightPassPostProcess: Nullable<PostProcess>;
  36497. blurHPostProcesses: PostProcess[];
  36498. blurVPostProcesses: PostProcess[];
  36499. textureAdderPostProcess: Nullable<PostProcess>;
  36500. volumetricLightPostProcess: Nullable<PostProcess>;
  36501. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  36502. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  36503. volumetricLightMergePostProces: Nullable<PostProcess>;
  36504. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  36505. luminancePostProcess: Nullable<PostProcess>;
  36506. luminanceDownSamplePostProcesses: PostProcess[];
  36507. hdrPostProcess: Nullable<PostProcess>;
  36508. textureAdderFinalPostProcess: Nullable<PostProcess>;
  36509. lensFlareFinalPostProcess: Nullable<PostProcess>;
  36510. hdrFinalPostProcess: Nullable<PostProcess>;
  36511. lensFlarePostProcess: Nullable<PostProcess>;
  36512. lensFlareComposePostProcess: Nullable<PostProcess>;
  36513. motionBlurPostProcess: Nullable<PostProcess>;
  36514. depthOfFieldPostProcess: Nullable<PostProcess>;
  36515. brightThreshold: number;
  36516. blurWidth: number;
  36517. horizontalBlur: boolean;
  36518. exposure: number;
  36519. lensTexture: Nullable<Texture>;
  36520. volumetricLightCoefficient: number;
  36521. volumetricLightPower: number;
  36522. volumetricLightBlurScale: number;
  36523. sourceLight: Nullable<SpotLight | DirectionalLight>;
  36524. hdrMinimumLuminance: number;
  36525. hdrDecreaseRate: number;
  36526. hdrIncreaseRate: number;
  36527. lensColorTexture: Nullable<Texture>;
  36528. lensFlareStrength: number;
  36529. lensFlareGhostDispersal: number;
  36530. lensFlareHaloWidth: number;
  36531. lensFlareDistortionStrength: number;
  36532. lensStarTexture: Nullable<Texture>;
  36533. lensFlareDirtTexture: Nullable<Texture>;
  36534. depthOfFieldDistance: number;
  36535. depthOfFieldBlurWidth: number;
  36536. motionStrength: number;
  36537. animations: Animation[];
  36538. /**
  36539. * Private members
  36540. */
  36541. private _scene;
  36542. private _currentDepthOfFieldSource;
  36543. private _basePostProcess;
  36544. private _hdrCurrentLuminance;
  36545. private _floatTextureType;
  36546. private _ratio;
  36547. private _bloomEnabled;
  36548. private _depthOfFieldEnabled;
  36549. private _vlsEnabled;
  36550. private _lensFlareEnabled;
  36551. private _hdrEnabled;
  36552. private _motionBlurEnabled;
  36553. private _motionBlurSamples;
  36554. private _volumetricLightStepsCount;
  36555. BloomEnabled: boolean;
  36556. DepthOfFieldEnabled: boolean;
  36557. LensFlareEnabled: boolean;
  36558. HDREnabled: boolean;
  36559. VLSEnabled: boolean;
  36560. MotionBlurEnabled: boolean;
  36561. volumetricLightStepsCount: number;
  36562. motionBlurSamples: number;
  36563. /**
  36564. * @constructor
  36565. * @param {string} name - The rendering pipeline name
  36566. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36567. * @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)
  36568. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  36569. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36570. */
  36571. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  36572. private _buildPipeline();
  36573. private _createDownSampleX4PostProcess(scene, ratio);
  36574. private _createBrightPassPostProcess(scene, ratio);
  36575. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  36576. private _createTextureAdderPostProcess(scene, ratio);
  36577. private _createVolumetricLightPostProcess(scene, ratio);
  36578. private _createLuminancePostProcesses(scene, textureType);
  36579. private _createHdrPostProcess(scene, ratio);
  36580. private _createLensFlarePostProcess(scene, ratio);
  36581. private _createDepthOfFieldPostProcess(scene, ratio);
  36582. private _createMotionBlurPostProcess(scene, ratio);
  36583. private _getDepthTexture();
  36584. private _disposePostProcesses();
  36585. /**
  36586. * Dispose of the pipeline and stop all post processes
  36587. */
  36588. dispose(): void;
  36589. /**
  36590. * Serialize the rendering pipeline (Used when exporting)
  36591. * @returns the serialized object
  36592. */
  36593. serialize(): any;
  36594. /**
  36595. * Parse the serialized pipeline
  36596. * @param source Source pipeline.
  36597. * @param scene The scene to load the pipeline to.
  36598. * @param rootUrl The URL of the serialized pipeline.
  36599. * @returns An instantiated pipeline from the serialized object.
  36600. */
  36601. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  36602. static LuminanceSteps: number;
  36603. }
  36604. }