babylon.d.ts 1.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349
  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: ParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * MultiMaterials to keep.
  35. */
  36. multiMaterials: MultiMaterial[];
  37. /**
  38. * Materials to keep.
  39. */
  40. materials: Material[];
  41. /**
  42. * MorphTargetManagers to keep.
  43. */
  44. morphTargetManagers: MorphTargetManager[];
  45. /**
  46. * Geometries to keep.
  47. */
  48. geometries: Geometry[];
  49. /**
  50. * TransformNodes to keep.
  51. */
  52. transformNodes: TransformNode[];
  53. /**
  54. * LensFlareSystems to keep.
  55. */
  56. lensFlareSystems: LensFlareSystem[];
  57. /**
  58. * ShadowGenerators to keep.
  59. */
  60. shadowGenerators: ShadowGenerator[];
  61. /**
  62. * ActionManagers to keep.
  63. */
  64. actionManagers: ActionManager[];
  65. /**
  66. * Sounds to keep.
  67. */
  68. sounds: Sound[];
  69. }
  70. /**
  71. * Container with a set of assets that can be added or removed from a scene.
  72. */
  73. class AssetContainer {
  74. /**
  75. * The scene the AssetContainer belongs to.
  76. */
  77. scene: Scene;
  78. /**
  79. * Cameras populated in the container.
  80. */
  81. cameras: Camera[];
  82. /**
  83. * Lights populated in the container.
  84. */
  85. lights: Light[];
  86. /**
  87. * Meshes populated in the container.
  88. */
  89. meshes: AbstractMesh[];
  90. /**
  91. * Skeletons populated in the container.
  92. */
  93. skeletons: Skeleton[];
  94. /**
  95. * ParticleSystems populated in the container.
  96. */
  97. particleSystems: IParticleSystem[];
  98. /**
  99. * Animations populated in the container.
  100. */
  101. animations: Animation[];
  102. /**
  103. * MultiMaterials populated in the container.
  104. */
  105. multiMaterials: MultiMaterial[];
  106. /**
  107. * Materials populated in the container.
  108. */
  109. materials: Material[];
  110. /**
  111. * MorphTargetManagers populated in the container.
  112. */
  113. morphTargetManagers: MorphTargetManager[];
  114. /**
  115. * Geometries populated in the container.
  116. */
  117. geometries: Geometry[];
  118. /**
  119. * TransformNodes populated in the container.
  120. */
  121. transformNodes: TransformNode[];
  122. /**
  123. * LensFlareSystems populated in the container.
  124. */
  125. lensFlareSystems: LensFlareSystem[];
  126. /**
  127. * ShadowGenerators populated in the container.
  128. */
  129. shadowGenerators: ShadowGenerator[];
  130. /**
  131. * ActionManagers populated in the container.
  132. */
  133. actionManagers: ActionManager[];
  134. /**
  135. * Sounds populated in the container.
  136. */
  137. sounds: Sound[];
  138. /**
  139. * Instantiates an AssetContainer.
  140. * @param scene The scene the AssetContainer belongs to.
  141. */
  142. constructor(scene: Scene);
  143. /**
  144. * Adds all the assets from the container to the scene.
  145. */
  146. addAllToScene(): void;
  147. /**
  148. * Removes all the assets in the container from the scene
  149. */
  150. removeAllFromScene(): void;
  151. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  152. /**
  153. * Removes all the assets contained in the scene and adds them to the container.
  154. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  155. */
  156. moveAllFromScene(keepAssets?: KeepAssets): void;
  157. }
  158. }
  159. interface Window {
  160. mozIndexedDB: IDBFactory;
  161. webkitIndexedDB: IDBFactory;
  162. msIndexedDB: IDBFactory;
  163. webkitURL: typeof URL;
  164. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  165. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  166. WebGLRenderingContext: WebGLRenderingContext;
  167. MSGesture: MSGesture;
  168. CANNON: any;
  169. AudioContext: AudioContext;
  170. webkitAudioContext: AudioContext;
  171. PointerEvent: any;
  172. Math: Math;
  173. Uint8Array: Uint8ArrayConstructor;
  174. Float32Array: Float32ArrayConstructor;
  175. mozURL: typeof URL;
  176. msURL: typeof URL;
  177. VRFrameData: any;
  178. DracoDecoderModule: any;
  179. }
  180. interface WebGLRenderingContext {
  181. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  182. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  183. vertexAttribDivisor(index: number, divisor: number): void;
  184. createVertexArray(): any;
  185. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  186. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  187. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  188. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  189. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  190. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  191. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  192. createQuery(): WebGLQuery;
  193. deleteQuery(query: WebGLQuery): void;
  194. beginQuery(target: number, query: WebGLQuery): void;
  195. endQuery(target: number): void;
  196. getQueryParameter(query: WebGLQuery, pname: number): any;
  197. getQuery(target: number, pname: number): any;
  198. MAX_SAMPLES: number;
  199. RGBA8: number;
  200. READ_FRAMEBUFFER: number;
  201. DRAW_FRAMEBUFFER: number;
  202. UNIFORM_BUFFER: number;
  203. HALF_FLOAT_OES: number;
  204. RGBA16F: number;
  205. RGBA32F: number;
  206. R32F: number;
  207. RG32F: number;
  208. RGB32F: number;
  209. RED: number;
  210. RG: number;
  211. UNSIGNED_INT_24_8: number;
  212. DEPTH24_STENCIL8: number;
  213. drawBuffers(buffers: number[]): void;
  214. readBuffer(src: number): void;
  215. readonly COLOR_ATTACHMENT0: number;
  216. readonly COLOR_ATTACHMENT1: number;
  217. readonly COLOR_ATTACHMENT2: number;
  218. readonly COLOR_ATTACHMENT3: number;
  219. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  220. ANY_SAMPLES_PASSED: number;
  221. QUERY_RESULT_AVAILABLE: number;
  222. QUERY_RESULT: number;
  223. }
  224. interface Document {
  225. mozCancelFullScreen(): void;
  226. msCancelFullScreen(): void;
  227. mozFullScreen: boolean;
  228. msIsFullScreen: boolean;
  229. fullscreen: boolean;
  230. mozPointerLockElement: HTMLElement;
  231. msPointerLockElement: HTMLElement;
  232. webkitPointerLockElement: HTMLElement;
  233. }
  234. interface HTMLCanvasElement {
  235. msRequestPointerLock?(): void;
  236. mozRequestPointerLock?(): void;
  237. webkitRequestPointerLock?(): void;
  238. }
  239. interface CanvasRenderingContext2D {
  240. msImageSmoothingEnabled: boolean;
  241. }
  242. interface WebGLBuffer {
  243. references: number;
  244. capacity: number;
  245. is32Bits: boolean;
  246. }
  247. interface WebGLProgram {
  248. transformFeedback?: WebGLTransformFeedback | null;
  249. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  250. }
  251. interface MouseEvent {
  252. mozMovementX: number;
  253. mozMovementY: number;
  254. webkitMovementX: number;
  255. webkitMovementY: number;
  256. msMovementX: number;
  257. msMovementY: number;
  258. }
  259. interface Navigator {
  260. mozGetVRDevices: (any: any) => any;
  261. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  262. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  263. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  264. webkitGetGamepads(): Gamepad[];
  265. msGetGamepads(): Gamepad[];
  266. webkitGamepads(): Gamepad[];
  267. }
  268. interface HTMLVideoElement {
  269. mozSrcObject: any;
  270. }
  271. interface Screen {
  272. orientation: string;
  273. mozOrientation: string;
  274. }
  275. interface Math {
  276. fround(x: number): number;
  277. imul(a: number, b: number): number;
  278. }
  279. interface GamepadPose {
  280. hasOrientation: boolean;
  281. hasPosition: boolean;
  282. position?: Float32Array;
  283. linearVelocity?: Float32Array;
  284. linearAcceleration?: Float32Array;
  285. orientation?: Float32Array;
  286. angularVelocity?: Float32Array;
  287. angularAcceleration?: Float32Array;
  288. }
  289. interface EXT_disjoint_timer_query {
  290. QUERY_COUNTER_BITS_EXT: number;
  291. TIME_ELAPSED_EXT: number;
  292. TIMESTAMP_EXT: number;
  293. GPU_DISJOINT_EXT: number;
  294. QUERY_RESULT_EXT: number;
  295. QUERY_RESULT_AVAILABLE_EXT: number;
  296. queryCounterEXT(query: WebGLQuery, target: number): void;
  297. createQueryEXT(): WebGLQuery;
  298. beginQueryEXT(target: number, query: WebGLQuery): void;
  299. endQueryEXT(target: number): void;
  300. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  301. deleteQueryEXT(query: WebGLQuery): void;
  302. }
  303. interface WebGLUniformLocation {
  304. _currentState: any;
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Node is the basic class for all scene objects (Mesh, Light Camera).
  309. */
  310. class Node {
  311. /**
  312. * Gets or sets the name of the node
  313. */
  314. name: string;
  315. /**
  316. * Gets or sets the id of the node
  317. */
  318. id: string;
  319. /**
  320. * Gets or sets the unique id of the node
  321. */
  322. uniqueId: number;
  323. /**
  324. * Gets or sets a string used to store user defined state for the node
  325. */
  326. state: string;
  327. /**
  328. * Gets or sets an object used to store user defined information for the node
  329. */
  330. metadata: any;
  331. /**
  332. * Gets or sets a boolean used to define if the node must be serialized
  333. */
  334. doNotSerialize: boolean;
  335. /** @ignore */
  336. _isDisposed: boolean;
  337. /**
  338. * Gets a list of {BABYLON.Animation} associated with the node
  339. */
  340. animations: Animation[];
  341. private _ranges;
  342. /**
  343. * Callback raised when the node is ready to be used
  344. */
  345. onReady: (node: Node) => void;
  346. private _isEnabled;
  347. private _isReady;
  348. /** @ignore */
  349. _currentRenderId: number;
  350. private _parentRenderId;
  351. protected _childRenderId: number;
  352. /** @ignore */
  353. _waitingParentId: Nullable<string>;
  354. private _scene;
  355. /** @ignore */
  356. _cache: any;
  357. private _parentNode;
  358. private _children;
  359. /**
  360. * Gets a boolean indicating if the node has been disposed
  361. * @returns true if the node was disposed
  362. */
  363. isDisposed(): boolean;
  364. /**
  365. * Gets or sets the parent of the node
  366. */
  367. parent: Nullable<Node>;
  368. private _animationPropertiesOverride;
  369. /**
  370. * Gets or sets the animation properties override
  371. */
  372. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  373. /**
  374. * Gets a string idenfifying the name of the class
  375. * @returns "Node" string
  376. */
  377. getClassName(): string;
  378. /**
  379. * An event triggered when the mesh is disposed
  380. * @type {BABYLON.Observable}
  381. */
  382. onDisposeObservable: Observable<Node>;
  383. private _onDisposeObserver;
  384. /**
  385. * Sets a callback that will be raised when the node will be disposed
  386. */
  387. onDispose: () => void;
  388. /**
  389. * Creates a new Node
  390. * @param {string} name - the name and id to be given to this node
  391. * @param {BABYLON.Scene} the scene this node will be added to
  392. */
  393. constructor(name: string, scene?: Nullable<Scene>);
  394. /**
  395. * Gets the scene of the node
  396. * @returns a {BABYLON.Scene}
  397. */
  398. getScene(): Scene;
  399. /**
  400. * Gets the engine of the node
  401. * @returns a {BABYLON.Engine}
  402. */
  403. getEngine(): Engine;
  404. private _behaviors;
  405. /**
  406. * Attach a behavior to the node
  407. * @see http://doc.babylonjs.com/features/behaviour
  408. * @param behavior defines the behavior to attach
  409. * @returns the current Node
  410. */
  411. addBehavior(behavior: Behavior<Node>): Node;
  412. /**
  413. * Remove an attached behavior
  414. * @see http://doc.babylonjs.com/features/behaviour
  415. * @param behavior defines the behavior to attach
  416. * @returns the current Node
  417. */
  418. removeBehavior(behavior: Behavior<Node>): Node;
  419. /**
  420. * Gets the list of attached behaviors
  421. * @see http://doc.babylonjs.com/features/behaviour
  422. */
  423. readonly behaviors: Behavior<Node>[];
  424. /**
  425. * Gets an attached behavior by name
  426. * @param name defines the name of the behavior to look for
  427. * @see http://doc.babylonjs.com/features/behaviour
  428. * @returns null if behavior was not found else the requested behavior
  429. */
  430. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  431. /**
  432. * Returns the world matrix of the node
  433. * @returns a matrix containing the node's world matrix
  434. */
  435. getWorldMatrix(): Matrix;
  436. /** @ignore */
  437. _initCache(): void;
  438. /** @ignore */
  439. updateCache(force?: boolean): void;
  440. /** @ignore */
  441. _updateCache(ignoreParentClass?: boolean): void;
  442. /** @ignore */
  443. _isSynchronized(): boolean;
  444. /** @ignore */
  445. _markSyncedWithParent(): void;
  446. /** @ignore */
  447. isSynchronizedWithParent(): boolean;
  448. /** @ignore */
  449. isSynchronized(updateCache?: boolean): boolean;
  450. /** @ignore */
  451. hasNewParent(update?: boolean): boolean;
  452. /**
  453. * Is this node ready to be used/rendered
  454. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  455. * @return true if the node is ready
  456. */
  457. isReady(completeCheck?: boolean): boolean;
  458. /**
  459. * Is this node enabled?
  460. * 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
  461. * @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
  462. * @return whether this node (and its parent) is enabled
  463. */
  464. isEnabled(checkAncestors?: boolean): boolean;
  465. /**
  466. * Set the enabled state of this node
  467. * @param value defines the new enabled state
  468. */
  469. setEnabled(value: boolean): void;
  470. /**
  471. * Is this node a descendant of the given node?
  472. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  473. * @param ancestor defines the parent node to inspect
  474. * @returns a boolean indicating if this node is a descendant of the given node
  475. */
  476. isDescendantOf(ancestor: Node): boolean;
  477. /** @ignore */
  478. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  479. /**
  480. * Will return all nodes that have this node as ascendant
  481. * @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
  482. * @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
  483. * @return all children nodes of all types
  484. */
  485. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  486. /**
  487. * Get all child-meshes of this node
  488. * @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
  489. * @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
  490. * @returns an array of {BABYLON.AbstractMesh}
  491. */
  492. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  493. /**
  494. * Get all child-transformNodes of this node
  495. * @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
  496. * @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
  497. * @returns an array of {BABYLON.TransformNode}
  498. */
  499. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  500. /**
  501. * Get all direct children of this node
  502. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  503. * @returns an array of {BABYLON.Node}
  504. */
  505. getChildren(predicate?: (node: Node) => boolean): Node[];
  506. /** @ignore */
  507. _setReady(state: boolean): void;
  508. /**
  509. * Get an animation by name
  510. * @param name defines the name of the animation to look for
  511. * @returns null if not found else the requested animation
  512. */
  513. getAnimationByName(name: string): Nullable<Animation>;
  514. /**
  515. * Creates an animation range for this node
  516. * @param name defines the name of the range
  517. * @param from defines the starting key
  518. * @param to defines the end key
  519. */
  520. createAnimationRange(name: string, from: number, to: number): void;
  521. /**
  522. * Delete a specific animation range
  523. * @param name defines the name of the range to delete
  524. * @param deleteFrames defines if animation frames from the range must be deleted as well
  525. */
  526. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  527. /**
  528. * Get an animation range by name
  529. * @param name defines the name of the animation range to look for
  530. * @returns null if not found else the requested animation range
  531. */
  532. getAnimationRange(name: string): Nullable<AnimationRange>;
  533. /**
  534. * Will start the animation sequence
  535. * @param name defines the range frames for animation sequence
  536. * @param loop defines if the animation should loop (false by default)
  537. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  538. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  539. * @returns the object created for this animation. If range does not exist, it will return null
  540. */
  541. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  542. /**
  543. * Serialize animation ranges into a JSON compatible object
  544. * @returns serialization object
  545. */
  546. serializeAnimationRanges(): any;
  547. /**
  548. * Computes the world matrix of the node
  549. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  550. * @returns the world matrix
  551. */
  552. computeWorldMatrix(force?: boolean): Matrix;
  553. /**
  554. * Releases resources associated with this node.
  555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  557. */
  558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  559. /**
  560. * Parse animation range data from a serialization object and store them into a given node
  561. * @param node defines where to store the animation ranges
  562. * @param parsedNode defines the serialization object to read data from
  563. * @param scene defines the hosting scene
  564. */
  565. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  566. }
  567. }
  568. declare module BABYLON {
  569. interface IDisposable {
  570. dispose(): void;
  571. }
  572. interface IActiveMeshCandidateProvider {
  573. getMeshes(scene: Scene): AbstractMesh[];
  574. readonly checksIsEnabled: boolean;
  575. }
  576. /**
  577. * This class is used by the onRenderingGroupObservable
  578. */
  579. class RenderingGroupInfo {
  580. /**
  581. * The Scene that being rendered
  582. */
  583. scene: Scene;
  584. /**
  585. * The camera currently used for the rendering pass
  586. */
  587. camera: Nullable<Camera>;
  588. /**
  589. * The ID of the renderingGroup being processed
  590. */
  591. renderingGroupId: number;
  592. /**
  593. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  594. */
  595. renderStage: number;
  596. /**
  597. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  598. * This stage will be fired no matter what
  599. */
  600. static STAGE_PRECLEAR: number;
  601. /**
  602. * Called before opaque object are rendered.
  603. * This stage will be fired only if there's 3D Opaque content to render
  604. */
  605. static STAGE_PREOPAQUE: number;
  606. /**
  607. * Called after the opaque objects are rendered and before the transparent ones
  608. * This stage will be fired only if there's 3D transparent content to render
  609. */
  610. static STAGE_PRETRANSPARENT: number;
  611. /**
  612. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  613. * This stage will be fired no matter what
  614. */
  615. static STAGE_POSTTRANSPARENT: number;
  616. }
  617. /**
  618. * Represents a scene to be rendered by the engine.
  619. * @see http://doc.babylonjs.com/page.php?p=21911
  620. */
  621. class Scene implements IAnimatable {
  622. private static _FOGMODE_NONE;
  623. private static _FOGMODE_EXP;
  624. private static _FOGMODE_EXP2;
  625. private static _FOGMODE_LINEAR;
  626. private static _uniqueIdCounter;
  627. static MinDeltaTime: number;
  628. static MaxDeltaTime: number;
  629. /** The fog is deactivated */
  630. static readonly FOGMODE_NONE: number;
  631. /** The fog density is following an exponential function */
  632. static readonly FOGMODE_EXP: number;
  633. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  634. static readonly FOGMODE_EXP2: number;
  635. /** The fog density is following a linear function. */
  636. static readonly FOGMODE_LINEAR: number;
  637. autoClear: boolean;
  638. autoClearDepthAndStencil: boolean;
  639. clearColor: Color4;
  640. ambientColor: Color3;
  641. _environmentBRDFTexture: BaseTexture;
  642. protected _environmentTexture: BaseTexture;
  643. /**
  644. * Texture used in all pbr material as the reflection texture.
  645. * As in the majority of the scene they are the same (exception for multi room and so on),
  646. * this is easier to reference from here than from all the materials.
  647. */
  648. /**
  649. * Texture used in all pbr material as the reflection texture.
  650. * As in the majority of the scene they are the same (exception for multi room and so on),
  651. * this is easier to set here than in all the materials.
  652. */
  653. environmentTexture: BaseTexture;
  654. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  655. /**
  656. * Default image processing configuration used either in the rendering
  657. * Forward main pass or through the imageProcessingPostProcess if present.
  658. * As in the majority of the scene they are the same (exception for multi camera),
  659. * this is easier to reference from here than from all the materials and post process.
  660. *
  661. * No setter as we it is a shared configuration, you can set the values instead.
  662. */
  663. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  664. private _forceWireframe;
  665. forceWireframe: boolean;
  666. private _forcePointsCloud;
  667. forcePointsCloud: boolean;
  668. forceShowBoundingBoxes: boolean;
  669. clipPlane: Nullable<Plane>;
  670. animationsEnabled: boolean;
  671. useConstantAnimationDeltaTime: boolean;
  672. constantlyUpdateMeshUnderPointer: boolean;
  673. hoverCursor: string;
  674. defaultCursor: string;
  675. /**
  676. * This is used to call preventDefault() on pointer down
  677. * in order to block unwanted artifacts like system double clicks
  678. */
  679. preventDefaultOnPointerDown: boolean;
  680. metadata: any;
  681. loadingPluginName: string;
  682. /**
  683. * Use this array to add regular expressions used to disable offline support for specific urls
  684. */
  685. disableOfflineSupportExceptionRules: RegExp[];
  686. private _spritePredicate;
  687. /**
  688. * An event triggered when the scene is disposed.
  689. * @type {BABYLON.Observable}
  690. */
  691. onDisposeObservable: Observable<Scene>;
  692. private _onDisposeObserver;
  693. /** A function to be executed when this scene is disposed. */
  694. onDispose: () => void;
  695. /**
  696. * An event triggered before rendering the scene (right after animations and physics)
  697. * @type {BABYLON.Observable}
  698. */
  699. onBeforeRenderObservable: Observable<Scene>;
  700. private _onBeforeRenderObserver;
  701. /** A function to be executed before rendering this scene */
  702. beforeRender: Nullable<() => void>;
  703. /**
  704. * An event triggered after rendering the scene
  705. * @type {BABYLON.Observable}
  706. */
  707. onAfterRenderObservable: Observable<Scene>;
  708. private _onAfterRenderObserver;
  709. /** A function to be executed after rendering this scene */
  710. afterRender: Nullable<() => void>;
  711. /**
  712. * An event triggered before animating the scene
  713. * @type {BABYLON.Observable}
  714. */
  715. onBeforeAnimationsObservable: Observable<Scene>;
  716. /**
  717. * An event triggered after animations processing
  718. * @type {BABYLON.Observable}
  719. */
  720. onAfterAnimationsObservable: Observable<Scene>;
  721. /**
  722. * An event triggered before draw calls are ready to be sent
  723. * @type {BABYLON.Observable}
  724. */
  725. onBeforeDrawPhaseObservable: Observable<Scene>;
  726. /**
  727. * An event triggered after draw calls have been sent
  728. * @type {BABYLON.Observable}
  729. */
  730. onAfterDrawPhaseObservable: Observable<Scene>;
  731. /**
  732. * An event triggered when physic simulation is about to be run
  733. * @type {BABYLON.Observable}
  734. */
  735. onBeforePhysicsObservable: Observable<Scene>;
  736. /**
  737. * An event triggered when physic simulation has been done
  738. * @type {BABYLON.Observable}
  739. */
  740. onAfterPhysicsObservable: Observable<Scene>;
  741. /**
  742. * An event triggered when the scene is ready
  743. * @type {BABYLON.Observable}
  744. */
  745. onReadyObservable: Observable<Scene>;
  746. /**
  747. * An event triggered before rendering a camera
  748. * @type {BABYLON.Observable}
  749. */
  750. onBeforeCameraRenderObservable: Observable<Camera>;
  751. private _onBeforeCameraRenderObserver;
  752. beforeCameraRender: () => void;
  753. /**
  754. * An event triggered after rendering a camera
  755. * @type {BABYLON.Observable}
  756. */
  757. onAfterCameraRenderObservable: Observable<Camera>;
  758. private _onAfterCameraRenderObserver;
  759. afterCameraRender: () => void;
  760. /**
  761. * An event triggered when active meshes evaluation is about to start
  762. * @type {BABYLON.Observable}
  763. */
  764. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  765. /**
  766. * An event triggered when active meshes evaluation is done
  767. * @type {BABYLON.Observable}
  768. */
  769. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  770. /**
  771. * An event triggered when particles rendering is about to start
  772. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  773. * @type {BABYLON.Observable}
  774. */
  775. onBeforeParticlesRenderingObservable: Observable<Scene>;
  776. /**
  777. * An event triggered when particles rendering is done
  778. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  779. * @type {BABYLON.Observable}
  780. */
  781. onAfterParticlesRenderingObservable: Observable<Scene>;
  782. /**
  783. * An event triggered when sprites rendering is about to start
  784. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  785. * @type {BABYLON.Observable}
  786. */
  787. onBeforeSpritesRenderingObservable: Observable<Scene>;
  788. /**
  789. * An event triggered when sprites rendering is done
  790. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  791. * @type {BABYLON.Observable}
  792. */
  793. onAfterSpritesRenderingObservable: Observable<Scene>;
  794. /**
  795. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  796. * @type {BABYLON.Observable}
  797. */
  798. onDataLoadedObservable: Observable<Scene>;
  799. /**
  800. * An event triggered when a camera is created
  801. * @type {BABYLON.Observable}
  802. */
  803. onNewCameraAddedObservable: Observable<Camera>;
  804. /**
  805. * An event triggered when a camera is removed
  806. * @type {BABYLON.Observable}
  807. */
  808. onCameraRemovedObservable: Observable<Camera>;
  809. /**
  810. * An event triggered when a light is created
  811. * @type {BABYLON.Observable}
  812. */
  813. onNewLightAddedObservable: Observable<Light>;
  814. /**
  815. * An event triggered when a light is removed
  816. * @type {BABYLON.Observable}
  817. */
  818. onLightRemovedObservable: Observable<Light>;
  819. /**
  820. * An event triggered when a geometry is created
  821. * @type {BABYLON.Observable}
  822. */
  823. onNewGeometryAddedObservable: Observable<Geometry>;
  824. /**
  825. * An event triggered when a geometry is removed
  826. * @type {BABYLON.Observable}
  827. */
  828. onGeometryRemovedObservable: Observable<Geometry>;
  829. /**
  830. * An event triggered when a transform node is created
  831. * @type {BABYLON.Observable}
  832. */
  833. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  834. /**
  835. * An event triggered when a transform node is removed
  836. * @type {BABYLON.Observable}
  837. */
  838. onTransformNodeRemovedObservable: Observable<TransformNode>;
  839. /**
  840. * An event triggered when a mesh is created
  841. * @type {BABYLON.Observable}
  842. */
  843. onNewMeshAddedObservable: Observable<AbstractMesh>;
  844. /**
  845. * An event triggered when a mesh is removed
  846. * @type {BABYLON.Observable}
  847. */
  848. onMeshRemovedObservable: Observable<AbstractMesh>;
  849. /**
  850. * An event triggered when render targets are about to be rendered
  851. * Can happen multiple times per frame.
  852. * @type {BABYLON.Observable}
  853. */
  854. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  855. /**
  856. * An event triggered when render targets were rendered.
  857. * Can happen multiple times per frame.
  858. * @type {BABYLON.Observable}
  859. */
  860. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  861. /**
  862. * An event triggered before calculating deterministic simulation step
  863. * @type {BABYLON.Observable}
  864. */
  865. onBeforeStepObservable: Observable<Scene>;
  866. /**
  867. * An event triggered after calculating deterministic simulation step
  868. * @type {BABYLON.Observable}
  869. */
  870. onAfterStepObservable: Observable<Scene>;
  871. /**
  872. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  873. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  874. * 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)
  875. */
  876. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  877. animations: Animation[];
  878. private _registeredForLateAnimationBindings;
  879. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  880. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  881. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  882. private _onPointerMove;
  883. private _onPointerDown;
  884. private _onPointerUp;
  885. /** Deprecated. Use onPointerObservable instead */
  886. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  887. /** Deprecated. Use onPointerObservable instead */
  888. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  889. /** Deprecated. Use onPointerObservable instead */
  890. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  891. /** Deprecated. Use onPointerObservable instead */
  892. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  893. private _gamepadManager;
  894. readonly gamepadManager: GamepadManager;
  895. /**
  896. * 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).
  897. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  898. */
  899. onPrePointerObservable: Observable<PointerInfoPre>;
  900. /**
  901. * Observable event triggered each time an input event is received from the rendering canvas
  902. */
  903. onPointerObservable: Observable<PointerInfo>;
  904. readonly unTranslatedPointer: Vector2;
  905. /** The distance in pixel that you have to move to prevent some events */
  906. static DragMovementThreshold: number;
  907. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  908. static LongPressDelay: number;
  909. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  910. static DoubleClickDelay: number;
  911. /** If you need to check double click without raising a single click at first click, enable this flag */
  912. static ExclusiveDoubleClickMode: boolean;
  913. private _initClickEvent;
  914. private _initActionManager;
  915. private _delayedSimpleClick;
  916. private _delayedSimpleClickTimeout;
  917. private _previousDelayedSimpleClickTimeout;
  918. private _meshPickProceed;
  919. private _previousButtonPressed;
  920. private _currentPickResult;
  921. private _previousPickResult;
  922. private _totalPointersPressed;
  923. private _doubleClickOccured;
  924. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  925. cameraToUseForPointers: Nullable<Camera>;
  926. private _pointerX;
  927. private _pointerY;
  928. private _unTranslatedPointerX;
  929. private _unTranslatedPointerY;
  930. private _startingPointerPosition;
  931. private _previousStartingPointerPosition;
  932. private _startingPointerTime;
  933. private _previousStartingPointerTime;
  934. private _timeAccumulator;
  935. private _currentStepId;
  936. private _currentInternalStep;
  937. _mirroredCameraPosition: Nullable<Vector3>;
  938. /**
  939. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  940. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  941. */
  942. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  943. /**
  944. * Observable event triggered each time an keyboard event is received from the hosting window
  945. */
  946. onKeyboardObservable: Observable<KeyboardInfo>;
  947. private _onKeyDown;
  948. private _onKeyUp;
  949. private _onCanvasFocusObserver;
  950. private _onCanvasBlurObserver;
  951. /**
  952. * use right-handed coordinate system on this scene.
  953. * @type {boolean}
  954. */
  955. private _useRightHandedSystem;
  956. useRightHandedSystem: boolean;
  957. setStepId(newStepId: number): void;
  958. getStepId(): number;
  959. getInternalStep(): number;
  960. private _fogEnabled;
  961. /**
  962. * is fog enabled on this scene.
  963. */
  964. fogEnabled: boolean;
  965. private _fogMode;
  966. fogMode: number;
  967. fogColor: Color3;
  968. fogDensity: number;
  969. fogStart: number;
  970. fogEnd: number;
  971. /**
  972. * is shadow enabled on this scene.
  973. * @type {boolean}
  974. */
  975. private _shadowsEnabled;
  976. shadowsEnabled: boolean;
  977. /**
  978. * is light enabled on this scene.
  979. * @type {boolean}
  980. */
  981. private _lightsEnabled;
  982. lightsEnabled: boolean;
  983. /**
  984. * All of the lights added to this scene.
  985. */
  986. lights: Light[];
  987. /** All of the cameras added to this scene. */
  988. cameras: Camera[];
  989. /** All of the active cameras added to this scene. */
  990. activeCameras: Camera[];
  991. /** The current active camera */
  992. activeCamera: Nullable<Camera>;
  993. /**
  994. * All of the tranform nodes added to this scene.
  995. */
  996. transformNodes: TransformNode[];
  997. /**
  998. * All of the (abstract) meshes added to this scene.
  999. */
  1000. meshes: AbstractMesh[];
  1001. /**
  1002. * All of the animation groups added to this scene.
  1003. */
  1004. animationGroups: AnimationGroup[];
  1005. private _geometries;
  1006. materials: Material[];
  1007. multiMaterials: MultiMaterial[];
  1008. private _defaultMaterial;
  1009. /** The default material used on meshes when no material is affected */
  1010. /** The default material used on meshes when no material is affected */
  1011. defaultMaterial: Material;
  1012. private _texturesEnabled;
  1013. texturesEnabled: boolean;
  1014. textures: BaseTexture[];
  1015. particlesEnabled: boolean;
  1016. particleSystems: IParticleSystem[];
  1017. spritesEnabled: boolean;
  1018. spriteManagers: SpriteManager[];
  1019. /**
  1020. * The list of layers (background and foreground) of the scene.
  1021. */
  1022. layers: Layer[];
  1023. /**
  1024. * The list of effect layers (highlights/glow) contained in the scene.
  1025. */
  1026. effectLayers: EffectLayer[];
  1027. private _skeletonsEnabled;
  1028. skeletonsEnabled: boolean;
  1029. skeletons: Skeleton[];
  1030. morphTargetManagers: MorphTargetManager[];
  1031. lensFlaresEnabled: boolean;
  1032. lensFlareSystems: LensFlareSystem[];
  1033. collisionsEnabled: boolean;
  1034. private _workerCollisions;
  1035. collisionCoordinator: ICollisionCoordinator;
  1036. /** Defines the gravity applied to this scene */
  1037. gravity: Vector3;
  1038. postProcesses: PostProcess[];
  1039. postProcessesEnabled: boolean;
  1040. postProcessManager: PostProcessManager;
  1041. private _postProcessRenderPipelineManager;
  1042. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1043. renderTargetsEnabled: boolean;
  1044. dumpNextRenderTargets: boolean;
  1045. customRenderTargets: RenderTargetTexture[];
  1046. useDelayedTextureLoading: boolean;
  1047. importedMeshesFiles: String[];
  1048. probesEnabled: boolean;
  1049. reflectionProbes: ReflectionProbe[];
  1050. database: Database;
  1051. /**
  1052. * This scene's action manager
  1053. * @type {BABYLON.ActionManager}
  1054. */
  1055. actionManager: ActionManager;
  1056. _actionManagers: ActionManager[];
  1057. private _meshesForIntersections;
  1058. proceduralTexturesEnabled: boolean;
  1059. _proceduralTextures: ProceduralTexture[];
  1060. private _mainSoundTrack;
  1061. soundTracks: SoundTrack[];
  1062. private _audioEnabled;
  1063. private _headphone;
  1064. readonly mainSoundTrack: SoundTrack;
  1065. VRHelper: VRExperienceHelper;
  1066. simplificationQueue: SimplificationQueue;
  1067. private _engine;
  1068. private _totalVertices;
  1069. _activeIndices: PerfCounter;
  1070. _activeParticles: PerfCounter;
  1071. _activeBones: PerfCounter;
  1072. private _animationRatio;
  1073. private _animationTimeLast;
  1074. private _animationTime;
  1075. animationTimeScale: number;
  1076. _cachedMaterial: Nullable<Material>;
  1077. _cachedEffect: Nullable<Effect>;
  1078. _cachedVisibility: Nullable<number>;
  1079. private _renderId;
  1080. private _executeWhenReadyTimeoutId;
  1081. private _intermediateRendering;
  1082. private _viewUpdateFlag;
  1083. private _projectionUpdateFlag;
  1084. private _alternateViewUpdateFlag;
  1085. private _alternateProjectionUpdateFlag;
  1086. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1087. private _activeRequests;
  1088. private _pendingData;
  1089. private _isDisposed;
  1090. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1091. private _activeMeshes;
  1092. private _processedMaterials;
  1093. private _renderTargets;
  1094. _activeParticleSystems: SmartArray<IParticleSystem>;
  1095. private _activeSkeletons;
  1096. private _softwareSkinnedMeshes;
  1097. private _renderingManager;
  1098. private _physicsEngine;
  1099. _activeAnimatables: Animatable[];
  1100. private _transformMatrix;
  1101. private _sceneUbo;
  1102. private _alternateSceneUbo;
  1103. private _pickWithRayInverseMatrix;
  1104. private _boundingBoxRenderer;
  1105. private _outlineRenderer;
  1106. private _viewMatrix;
  1107. private _projectionMatrix;
  1108. private _alternateViewMatrix;
  1109. private _alternateProjectionMatrix;
  1110. private _alternateTransformMatrix;
  1111. private _useAlternateCameraConfiguration;
  1112. private _alternateRendering;
  1113. _forcedViewPosition: Nullable<Vector3>;
  1114. readonly _isAlternateRenderingEnabled: boolean;
  1115. private _frustumPlanes;
  1116. readonly frustumPlanes: Plane[];
  1117. requireLightSorting: boolean;
  1118. private _selectionOctree;
  1119. private _pointerOverMesh;
  1120. private _pointerOverSprite;
  1121. private _debugLayer;
  1122. private _depthRenderer;
  1123. private _geometryBufferRenderer;
  1124. /**
  1125. * Gets the current geometry buffer associated to the scene.
  1126. */
  1127. /**
  1128. * Sets the current geometry buffer for the scene.
  1129. */
  1130. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1131. private _pickedDownMesh;
  1132. private _pickedUpMesh;
  1133. private _pickedDownSprite;
  1134. private _externalData;
  1135. private _uid;
  1136. /**
  1137. * @constructor
  1138. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  1139. */
  1140. constructor(engine: Engine);
  1141. readonly debugLayer: DebugLayer;
  1142. workerCollisions: boolean;
  1143. readonly selectionOctree: Octree<AbstractMesh>;
  1144. /**
  1145. * The mesh that is currently under the pointer.
  1146. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1147. */
  1148. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1149. /**
  1150. * Current on-screen X position of the pointer
  1151. * @return {number} X position of the pointer
  1152. */
  1153. readonly pointerX: number;
  1154. /**
  1155. * Current on-screen Y position of the pointer
  1156. * @return {number} Y position of the pointer
  1157. */
  1158. readonly pointerY: number;
  1159. getCachedMaterial(): Nullable<Material>;
  1160. getCachedEffect(): Nullable<Effect>;
  1161. getCachedVisibility(): Nullable<number>;
  1162. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1163. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1164. getOutlineRenderer(): OutlineRenderer;
  1165. getEngine(): Engine;
  1166. getTotalVertices(): number;
  1167. readonly totalVerticesPerfCounter: PerfCounter;
  1168. getActiveIndices(): number;
  1169. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1170. getActiveParticles(): number;
  1171. readonly activeParticlesPerfCounter: PerfCounter;
  1172. getActiveBones(): number;
  1173. readonly activeBonesPerfCounter: PerfCounter;
  1174. getInterFramePerfCounter(): number;
  1175. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1176. getLastFrameDuration(): number;
  1177. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1178. getEvaluateActiveMeshesDuration(): number;
  1179. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1180. getActiveMeshes(): SmartArray<AbstractMesh>;
  1181. getRenderTargetsDuration(): number;
  1182. getRenderDuration(): number;
  1183. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1184. getParticlesDuration(): number;
  1185. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1186. getSpritesDuration(): number;
  1187. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1188. getAnimationRatio(): number;
  1189. getRenderId(): number;
  1190. incrementRenderId(): void;
  1191. private _updatePointerPosition(evt);
  1192. private _createUbo();
  1193. private _createAlternateUbo();
  1194. /**
  1195. * Use this method to simulate a pointer move on a mesh
  1196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1199. */
  1200. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1201. private _processPointerMove(pickResult, evt);
  1202. /**
  1203. * Use this method to simulate a pointer down on a mesh
  1204. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1205. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1206. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1207. */
  1208. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1209. private _processPointerDown(pickResult, evt);
  1210. /**
  1211. * Use this method to simulate a pointer up on a mesh
  1212. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1213. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1214. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1215. */
  1216. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1217. private _processPointerUp(pickResult, evt, clickInfo);
  1218. /**
  1219. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1220. * @param attachUp defines if you want to attach events to pointerup
  1221. * @param attachDown defines if you want to attach events to pointerdown
  1222. * @param attachMove defines if you want to attach events to pointermove
  1223. */
  1224. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1225. detachControl(): void;
  1226. /**
  1227. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1228. * Delay loaded resources are not taking in account
  1229. * @return true if all required resources are ready
  1230. */
  1231. isReady(): boolean;
  1232. resetCachedMaterial(): void;
  1233. registerBeforeRender(func: () => void): void;
  1234. unregisterBeforeRender(func: () => void): void;
  1235. registerAfterRender(func: () => void): void;
  1236. unregisterAfterRender(func: () => void): void;
  1237. private _executeOnceBeforeRender(func);
  1238. /**
  1239. * The provided function will run before render once and will be disposed afterwards.
  1240. * A timeout delay can be provided so that the function will be executed in N ms.
  1241. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1242. * @param func The function to be executed.
  1243. * @param timeout optional delay in ms
  1244. */
  1245. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1246. _addPendingData(data: any): void;
  1247. _removePendingData(data: any): void;
  1248. getWaitingItemsCount(): number;
  1249. readonly isLoading: boolean;
  1250. /**
  1251. * Registers a function to be executed when the scene is ready.
  1252. * @param {Function} func - the function to be executed.
  1253. */
  1254. executeWhenReady(func: () => void): void;
  1255. /**
  1256. * Returns a promise that resolves when the scene is ready.
  1257. * @returns A promise that resolves when the scene is ready.
  1258. */
  1259. whenReadyAsync(): Promise<void>;
  1260. _checkIsReady(): void;
  1261. /**
  1262. * Will start the animation sequence of a given target
  1263. * @param target defines the target
  1264. * @param from defines from which frame should animation start
  1265. * @param to defines until which frame should animation run.
  1266. * @param weight defines the weight to apply to the animation (1.0 by default)
  1267. * @param loop defines if the animation loops
  1268. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1269. * @param onAnimationEnd defines the function to be executed when the animation ends
  1270. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1271. * @returns the animatable object created for this animation
  1272. */
  1273. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1274. /**
  1275. * Will start the animation sequence of a given target
  1276. * @param target defines the target
  1277. * @param from defines from which frame should animation start
  1278. * @param to defines until which frame should animation run.
  1279. * @param loop defines if the animation loops
  1280. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1281. * @param onAnimationEnd defines the function to be executed when the animation ends
  1282. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1283. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1284. * @returns the animatable object created for this animation
  1285. */
  1286. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1287. /**
  1288. * Begin a new animation on a given node
  1289. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1290. * @param {BABYLON.Animation[]} defines the list of animations to start
  1291. * @param {number} from defines the initial value
  1292. * @param {number} to defines the final value
  1293. * @param {boolean} loop defines if you want animation to loop (off by default)
  1294. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1295. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1296. * @returns the list of created animatables
  1297. */
  1298. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1299. /**
  1300. * Begin a new animation on a given node and its hierarchy
  1301. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1302. * @param {boolean} directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1303. * @param {BABYLON.Animation[]} defines the list of animations to start
  1304. * @param {number} from defines the initial value
  1305. * @param {number} to defines the final value
  1306. * @param {boolean} loop defines if you want animation to loop (off by default)
  1307. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1308. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1309. * @returns the list of animatables created for all nodes
  1310. */
  1311. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1312. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1313. /**
  1314. * Gets all animatables associated with a given target
  1315. * @param target defines the target to look animatables for
  1316. * @returns an array of Animatables
  1317. */
  1318. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1319. readonly animatables: Animatable[];
  1320. /**
  1321. * Will stop the animation of the given target
  1322. * @param target - the target
  1323. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1324. */
  1325. stopAnimation(target: any, animationName?: string): void;
  1326. /**
  1327. * Stops and removes all animations that have been applied to the scene
  1328. */
  1329. stopAllAnimations(): void;
  1330. private _animate();
  1331. /** @ignore */
  1332. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1333. private _processLateAnimationBindings();
  1334. _switchToAlternateCameraConfiguration(active: boolean): void;
  1335. getViewMatrix(): Matrix;
  1336. getProjectionMatrix(): Matrix;
  1337. getTransformMatrix(): Matrix;
  1338. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1339. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1340. getSceneUniformBuffer(): UniformBuffer;
  1341. getUniqueId(): number;
  1342. addMesh(newMesh: AbstractMesh): void;
  1343. removeMesh(toRemove: AbstractMesh): number;
  1344. addTransformNode(newTransformNode: TransformNode): void;
  1345. removeTransformNode(toRemove: TransformNode): number;
  1346. removeSkeleton(toRemove: Skeleton): number;
  1347. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1348. removeLight(toRemove: Light): number;
  1349. removeCamera(toRemove: Camera): number;
  1350. removeParticleSystem(toRemove: IParticleSystem): number;
  1351. removeAnimation(toRemove: Animation): number;
  1352. removeMultiMaterial(toRemove: MultiMaterial): number;
  1353. removeMaterial(toRemove: Material): number;
  1354. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1355. removeActionManager(toRemove: ActionManager): number;
  1356. addLight(newLight: Light): void;
  1357. sortLightsByPriority(): void;
  1358. addCamera(newCamera: Camera): void;
  1359. addSkeleton(newSkeleton: Skeleton): void;
  1360. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1361. addAnimation(newAnimation: Animation): void;
  1362. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1363. addMaterial(newMaterial: Material): void;
  1364. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1365. addGeometry(newGeometrie: Geometry): void;
  1366. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1367. addActionManager(newActionManager: ActionManager): void;
  1368. /**
  1369. * Switch active camera
  1370. * @param {Camera} newCamera - new active camera
  1371. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1372. */
  1373. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1374. /**
  1375. * sets the active camera of the scene using its ID
  1376. * @param {string} id - the camera's ID
  1377. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1378. */
  1379. setActiveCameraByID(id: string): Nullable<Camera>;
  1380. /**
  1381. * sets the active camera of the scene using its name
  1382. * @param {string} name - the camera's name
  1383. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1384. */
  1385. setActiveCameraByName(name: string): Nullable<Camera>;
  1386. /**
  1387. * get an animation group using its name
  1388. * @param {string} the material's name
  1389. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1390. */
  1391. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1392. /**
  1393. * get a material using its id
  1394. * @param {string} the material's ID
  1395. * @return {BABYLON.Material|null} the material or null if none found.
  1396. */
  1397. getMaterialByID(id: string): Nullable<Material>;
  1398. /**
  1399. * get a material using its name
  1400. * @param {string} the material's name
  1401. * @return {BABYLON.Material|null} the material or null if none found.
  1402. */
  1403. getMaterialByName(name: string): Nullable<Material>;
  1404. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1405. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1406. getCameraByID(id: string): Nullable<Camera>;
  1407. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1408. /**
  1409. * get a camera using its name
  1410. * @param {string} the camera's name
  1411. * @return {BABYLON.Camera|null} the camera or null if none found.
  1412. */
  1413. getCameraByName(name: string): Nullable<Camera>;
  1414. /**
  1415. * get a bone using its id
  1416. * @param {string} the bone's id
  1417. * @return {BABYLON.Bone|null} the bone or null if not found
  1418. */
  1419. getBoneByID(id: string): Nullable<Bone>;
  1420. /**
  1421. * get a bone using its id
  1422. * @param {string} the bone's name
  1423. * @return {BABYLON.Bone|null} the bone or null if not found
  1424. */
  1425. getBoneByName(name: string): Nullable<Bone>;
  1426. /**
  1427. * get a light node using its name
  1428. * @param {string} the light's name
  1429. * @return {BABYLON.Light|null} the light or null if none found.
  1430. */
  1431. getLightByName(name: string): Nullable<Light>;
  1432. /**
  1433. * get a light node using its ID
  1434. * @param {string} the light's id
  1435. * @return {BABYLON.Light|null} the light or null if none found.
  1436. */
  1437. getLightByID(id: string): Nullable<Light>;
  1438. /**
  1439. * get a light node using its scene-generated unique ID
  1440. * @param {number} the light's unique id
  1441. * @return {BABYLON.Light|null} the light or null if none found.
  1442. */
  1443. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1444. /**
  1445. * get a particle system by id
  1446. * @param id {number} the particle system id
  1447. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1448. */
  1449. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1450. /**
  1451. * get a geometry using its ID
  1452. * @param {string} the geometry's id
  1453. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1454. */
  1455. getGeometryByID(id: string): Nullable<Geometry>;
  1456. /**
  1457. * add a new geometry to this scene.
  1458. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1459. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1460. * @return {boolean} was the geometry added or not
  1461. */
  1462. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1463. /**
  1464. * Removes an existing geometry
  1465. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1466. * @return {boolean} was the geometry removed or not
  1467. */
  1468. removeGeometry(geometry: Geometry): boolean;
  1469. getGeometries(): Geometry[];
  1470. /**
  1471. * Get the first added mesh found of a given ID
  1472. * @param {string} id - the id to search for
  1473. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1474. */
  1475. getMeshByID(id: string): Nullable<AbstractMesh>;
  1476. getMeshesByID(id: string): Array<AbstractMesh>;
  1477. /**
  1478. * Get the first added transform node found of a given ID
  1479. * @param {string} id - the id to search for
  1480. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1481. */
  1482. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1483. getTransformNodesByID(id: string): Array<TransformNode>;
  1484. /**
  1485. * Get a mesh with its auto-generated unique id
  1486. * @param {number} uniqueId - the unique id to search for
  1487. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1488. */
  1489. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1490. /**
  1491. * Get a the last added mesh found of a given ID
  1492. * @param {string} id - the id to search for
  1493. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1494. */
  1495. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1496. /**
  1497. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1498. * @param {string} id - the id to search for
  1499. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1500. */
  1501. getLastEntryByID(id: string): Nullable<Node>;
  1502. getNodeByID(id: string): Nullable<Node>;
  1503. getNodeByName(name: string): Nullable<Node>;
  1504. getMeshByName(name: string): Nullable<AbstractMesh>;
  1505. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1506. getSoundByName(name: string): Nullable<Sound>;
  1507. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1508. getSkeletonById(id: string): Nullable<Skeleton>;
  1509. getSkeletonByName(name: string): Nullable<Skeleton>;
  1510. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1511. isActiveMesh(mesh: AbstractMesh): boolean;
  1512. /**
  1513. * Return a the first highlight layer of the scene with a given name.
  1514. * @param name The name of the highlight layer to look for.
  1515. * @return The highlight layer if found otherwise null.
  1516. */
  1517. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1518. /**
  1519. * Return a the first highlight layer of the scene with a given name.
  1520. * @param name The name of the highlight layer to look for.
  1521. * @return The highlight layer if found otherwise null.
  1522. */
  1523. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  1524. /**
  1525. * Return a unique id as a string which can serve as an identifier for the scene
  1526. */
  1527. readonly uid: string;
  1528. /**
  1529. * Add an externaly attached data from its key.
  1530. * This method call will fail and return false, if such key already exists.
  1531. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1532. * @param key the unique key that identifies the data
  1533. * @param data the data object to associate to the key for this Engine instance
  1534. * @return true if no such key were already present and the data was added successfully, false otherwise
  1535. */
  1536. addExternalData<T>(key: string, data: T): boolean;
  1537. /**
  1538. * Get an externaly attached data from its key
  1539. * @param key the unique key that identifies the data
  1540. * @return the associated data, if present (can be null), or undefined if not present
  1541. */
  1542. getExternalData<T>(key: string): Nullable<T>;
  1543. /**
  1544. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1545. * @param key the unique key that identifies the data
  1546. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1547. * @return the associated data, can be null if the factory returned null.
  1548. */
  1549. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1550. /**
  1551. * Remove an externaly attached data from the Engine instance
  1552. * @param key the unique key that identifies the data
  1553. * @return true if the data was successfully removed, false if it doesn't exist
  1554. */
  1555. removeExternalData(key: string): boolean;
  1556. private _evaluateSubMesh(subMesh, mesh);
  1557. /**
  1558. * Clear the processed materials smart array preventing retention point in material dispose.
  1559. */
  1560. freeProcessedMaterials(): void;
  1561. /**
  1562. * Clear the active meshes smart array preventing retention point in mesh dispose.
  1563. */
  1564. freeActiveMeshes(): void;
  1565. /**
  1566. * Clear the info related to rendering groups preventing retention points during dispose.
  1567. */
  1568. freeRenderingGroups(): void;
  1569. _isInIntermediateRendering(): boolean;
  1570. private _activeMeshCandidateProvider;
  1571. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1572. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1573. private _activeMeshesFrozen;
  1574. /**
  1575. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1576. */
  1577. freezeActiveMeshes(): Scene;
  1578. /**
  1579. * Use this function to restart evaluating active meshes on every frame
  1580. */
  1581. unfreezeActiveMeshes(): this;
  1582. private _evaluateActiveMeshes();
  1583. private _activeMesh(sourceMesh, mesh);
  1584. updateTransformMatrix(force?: boolean): void;
  1585. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1586. private _renderForCamera(camera, rigParent?);
  1587. private _processSubCameras(camera);
  1588. private _checkIntersections();
  1589. render(): void;
  1590. private _updateAudioParameters();
  1591. audioEnabled: boolean;
  1592. private _disableAudio();
  1593. private _enableAudio();
  1594. headphone: boolean;
  1595. private _switchAudioModeForHeadphones();
  1596. private _switchAudioModeForNormalSpeakers();
  1597. /**
  1598. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  1599. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  1600. * @returns the created depth renderer
  1601. */
  1602. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  1603. /**
  1604. * Disables a depth renderer for a given camera
  1605. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  1606. */
  1607. disableDepthRenderer(camera?: Nullable<Camera>): void;
  1608. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1609. disableGeometryBufferRenderer(): void;
  1610. freezeMaterials(): void;
  1611. unfreezeMaterials(): void;
  1612. dispose(): void;
  1613. readonly isDisposed: boolean;
  1614. disposeSounds(): void;
  1615. /**
  1616. * Get the world extend vectors with an optional filter
  1617. *
  1618. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  1619. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  1620. */
  1621. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  1622. min: Vector3;
  1623. max: Vector3;
  1624. };
  1625. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1626. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1627. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1628. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1629. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1630. private _internalPick(rayFunction, predicate?, fastCheck?);
  1631. private _internalMultiPick(rayFunction, predicate?);
  1632. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1633. private _tempPickingRay;
  1634. /** Launch a ray to try to pick a mesh in the scene
  1635. * @param x position on screen
  1636. * @param y position on screen
  1637. * @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
  1638. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1639. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1640. */
  1641. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1642. /** Launch a ray to try to pick a sprite in the scene
  1643. * @param x position on screen
  1644. * @param y position on screen
  1645. * @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
  1646. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1648. */
  1649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1650. private _cachedRayForTransform;
  1651. /** Use the given ray to pick a mesh in the scene
  1652. * @param ray The ray to use to pick meshes
  1653. * @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
  1654. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1655. */
  1656. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1657. /**
  1658. * Launch a ray to try to pick a mesh in the scene
  1659. * @param x X position on screen
  1660. * @param y Y position on screen
  1661. * @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
  1662. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1663. */
  1664. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1665. /**
  1666. * Launch a ray to try to pick a mesh in the scene
  1667. * @param ray Ray to use
  1668. * @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
  1669. */
  1670. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1671. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1672. getPointerOverMesh(): Nullable<AbstractMesh>;
  1673. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1674. getPointerOverSprite(): Nullable<Sprite>;
  1675. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1676. /**
  1677. * Enables physics to the current scene
  1678. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1679. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1680. * @return {boolean} was the physics engine initialized
  1681. */
  1682. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1683. disablePhysicsEngine(): void;
  1684. isPhysicsEnabled(): boolean;
  1685. deleteCompoundImpostor(compound: any): void;
  1686. _rebuildGeometries(): void;
  1687. _rebuildTextures(): void;
  1688. /**
  1689. * Creates a default light for the scene.
  1690. * @param replace Whether to replace the existing lights in the scene.
  1691. */
  1692. createDefaultLight(replace?: boolean): void;
  1693. /**
  1694. * Creates a default camera for the scene.
  1695. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1696. * @param replace Whether to replace the existing active camera in the scene.
  1697. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1698. */
  1699. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1700. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1701. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1702. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1703. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1704. private _getByTags(list, tagsQuery, forEach?);
  1705. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1706. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1707. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1708. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1709. /**
  1710. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1711. * This allowed control for front to back rendering or reversly depending of the special needs.
  1712. *
  1713. * @param renderingGroupId The rendering group id corresponding to its index
  1714. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1715. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1716. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1717. */
  1718. 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;
  1719. /**
  1720. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1721. *
  1722. * @param renderingGroupId The rendering group id corresponding to its index
  1723. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1724. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1725. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1726. */
  1727. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1728. /**
  1729. * Will flag all materials as dirty to trigger new shader compilation
  1730. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1731. */
  1732. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1733. _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;
  1734. /** @ignore */
  1735. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1736. }
  1737. }
  1738. declare module BABYLON {
  1739. type Nullable<T> = T | null;
  1740. type float = number;
  1741. type double = number;
  1742. type int = number;
  1743. type FloatArray = number[] | Float32Array;
  1744. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1745. }
  1746. declare module BABYLON {
  1747. class Analyser {
  1748. SMOOTHING: number;
  1749. FFT_SIZE: number;
  1750. BARGRAPHAMPLITUDE: number;
  1751. DEBUGCANVASPOS: {
  1752. x: number;
  1753. y: number;
  1754. };
  1755. DEBUGCANVASSIZE: {
  1756. width: number;
  1757. height: number;
  1758. };
  1759. private _byteFreqs;
  1760. private _byteTime;
  1761. private _floatFreqs;
  1762. private _webAudioAnalyser;
  1763. private _debugCanvas;
  1764. private _debugCanvasContext;
  1765. private _scene;
  1766. private _registerFunc;
  1767. private _audioEngine;
  1768. constructor(scene: Scene);
  1769. getFrequencyBinCount(): number;
  1770. getByteFrequencyData(): Uint8Array;
  1771. getByteTimeDomainData(): Uint8Array;
  1772. getFloatFrequencyData(): Uint8Array;
  1773. drawDebugCanvas(): void;
  1774. stopDebugCanvas(): void;
  1775. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  1776. dispose(): void;
  1777. }
  1778. }
  1779. declare module BABYLON {
  1780. class AudioEngine {
  1781. private _audioContext;
  1782. private _audioContextInitialized;
  1783. canUseWebAudio: boolean;
  1784. masterGain: GainNode;
  1785. private _connectedAnalyser;
  1786. WarnedWebAudioUnsupported: boolean;
  1787. unlocked: boolean;
  1788. onAudioUnlocked: () => any;
  1789. isMP3supported: boolean;
  1790. isOGGsupported: boolean;
  1791. readonly audioContext: Nullable<AudioContext>;
  1792. constructor();
  1793. private _unlockiOSaudio();
  1794. private _initializeAudioContext();
  1795. dispose(): void;
  1796. getGlobalVolume(): number;
  1797. setGlobalVolume(newVolume: number): void;
  1798. connectToAnalyser(analyser: Analyser): void;
  1799. }
  1800. }
  1801. declare module BABYLON {
  1802. class Sound {
  1803. name: string;
  1804. autoplay: boolean;
  1805. loop: boolean;
  1806. useCustomAttenuation: boolean;
  1807. soundTrackId: number;
  1808. spatialSound: boolean;
  1809. refDistance: number;
  1810. rolloffFactor: number;
  1811. maxDistance: number;
  1812. distanceModel: string;
  1813. private _panningModel;
  1814. onended: () => any;
  1815. private _playbackRate;
  1816. private _streaming;
  1817. private _startTime;
  1818. private _startOffset;
  1819. private _position;
  1820. private _localDirection;
  1821. private _volume;
  1822. private _isReadyToPlay;
  1823. isPlaying: boolean;
  1824. isPaused: boolean;
  1825. private _isDirectional;
  1826. private _readyToPlayCallback;
  1827. private _audioBuffer;
  1828. private _soundSource;
  1829. private _streamingSource;
  1830. private _soundPanner;
  1831. private _soundGain;
  1832. private _inputAudioNode;
  1833. private _ouputAudioNode;
  1834. private _coneInnerAngle;
  1835. private _coneOuterAngle;
  1836. private _coneOuterGain;
  1837. private _scene;
  1838. private _connectedMesh;
  1839. private _customAttenuationFunction;
  1840. private _registerFunc;
  1841. private _isOutputConnected;
  1842. private _htmlAudioElement;
  1843. private _urlType;
  1844. /**
  1845. * Create a sound and attach it to a scene
  1846. * @param name Name of your sound
  1847. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  1848. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  1849. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  1850. */
  1851. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  1852. dispose(): void;
  1853. isReady(): boolean;
  1854. private _soundLoaded(audioData);
  1855. setAudioBuffer(audioBuffer: AudioBuffer): void;
  1856. updateOptions(options: any): void;
  1857. private _createSpatialParameters();
  1858. private _updateSpatialParameters();
  1859. switchPanningModelToHRTF(): void;
  1860. switchPanningModelToEqualPower(): void;
  1861. private _switchPanningModel();
  1862. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  1863. /**
  1864. * Transform this sound into a directional source
  1865. * @param coneInnerAngle Size of the inner cone in degree
  1866. * @param coneOuterAngle Size of the outer cone in degree
  1867. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  1868. */
  1869. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  1870. setPosition(newPosition: Vector3): void;
  1871. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  1872. private _updateDirection();
  1873. updateDistanceFromListener(): void;
  1874. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  1875. /**
  1876. * Play the sound
  1877. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  1878. * @param offset (optional) Start the sound setting it at a specific time
  1879. */
  1880. play(time?: number, offset?: number): void;
  1881. private _onended();
  1882. /**
  1883. * Stop the sound
  1884. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  1885. */
  1886. stop(time?: number): void;
  1887. pause(): void;
  1888. setVolume(newVolume: number, time?: number): void;
  1889. setPlaybackRate(newPlaybackRate: number): void;
  1890. getVolume(): number;
  1891. attachToMesh(meshToConnectTo: AbstractMesh): void;
  1892. detachFromMesh(): void;
  1893. private _onRegisterAfterWorldMatrixUpdate(node);
  1894. clone(): Nullable<Sound>;
  1895. getAudioBuffer(): AudioBuffer | null;
  1896. serialize(): any;
  1897. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. class SoundTrack {
  1902. private _outputAudioNode;
  1903. private _scene;
  1904. id: number;
  1905. soundCollection: Array<Sound>;
  1906. private _isMainTrack;
  1907. private _connectedAnalyser;
  1908. private _options;
  1909. private _isInitialized;
  1910. constructor(scene: Scene, options?: any);
  1911. private _initializeSoundTrackAudioGraph();
  1912. dispose(): void;
  1913. AddSound(sound: Sound): void;
  1914. RemoveSound(sound: Sound): void;
  1915. setVolume(newVolume: number): void;
  1916. switchPanningModelToHRTF(): void;
  1917. switchPanningModelToEqualPower(): void;
  1918. connectToAnalyser(analyser: Analyser): void;
  1919. }
  1920. }
  1921. declare module BABYLON {
  1922. /**
  1923. * The action to be carried out following a trigger
  1924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  1925. */
  1926. class Action {
  1927. triggerOptions: any;
  1928. /**
  1929. * Trigger for the action
  1930. */
  1931. trigger: number;
  1932. /**
  1933. * Internal only - manager for action
  1934. * @ignore
  1935. */
  1936. _actionManager: ActionManager;
  1937. private _nextActiveAction;
  1938. private _child;
  1939. private _condition?;
  1940. private _triggerParameter;
  1941. /**
  1942. * An event triggered prior to action being executed.
  1943. * @type Observable
  1944. */
  1945. onBeforeExecuteObservable: Observable<Action>;
  1946. /**
  1947. * Creates a new Action
  1948. * @param triggerOptions the trigger, with or without parameters, for the action
  1949. * @param condition an optional determinant of action
  1950. */
  1951. constructor(triggerOptions: any, condition?: Condition);
  1952. /**
  1953. * Internal only
  1954. * @ignore
  1955. */
  1956. _prepare(): void;
  1957. /**
  1958. * Gets the trigger parameters
  1959. * @returns the trigger parameters
  1960. */
  1961. getTriggerParameter(): any;
  1962. /**
  1963. * Internal only - executes current action event
  1964. * @ignore
  1965. */
  1966. _executeCurrent(evt?: ActionEvent): void;
  1967. /**
  1968. * Execute placeholder for child classes
  1969. * @param evt optional action event
  1970. */
  1971. execute(evt?: ActionEvent): void;
  1972. /**
  1973. * Skips to next active action
  1974. */
  1975. skipToNextActiveAction(): void;
  1976. /**
  1977. * Adds action to chain of actions, may be a DoNothingAction
  1978. * @param index The index of the attribute.
  1979. * @returns The action passed in
  1980. * @see https://www.babylonjs-playground.com/#1T30HR#0
  1981. */
  1982. then(action: Action): Action;
  1983. /**
  1984. * Internal only
  1985. * @ignore
  1986. */
  1987. _getProperty(propertyPath: string): string;
  1988. /**
  1989. * Internal only
  1990. * @ignore
  1991. */
  1992. _getEffectiveTarget(target: any, propertyPath: string): any;
  1993. /**
  1994. * Serialize placeholder for child classes
  1995. * @param parent of child
  1996. * @returns the serialized object
  1997. */
  1998. serialize(parent: any): any;
  1999. /**
  2000. * Internal only called by serialize
  2001. * @ignore
  2002. */
  2003. protected _serialize(serializedAction: any, parent?: any): any;
  2004. /**
  2005. * Internal only
  2006. * @ignore
  2007. */
  2008. static _SerializeValueAsString: (value: any) => string;
  2009. /**
  2010. * Internal only
  2011. * @ignore
  2012. */
  2013. static _GetTargetProperty: (target: Scene | Node) => {
  2014. name: string;
  2015. targetType: string;
  2016. value: string;
  2017. };
  2018. }
  2019. }
  2020. declare module BABYLON {
  2021. /**
  2022. * ActionEvent is the event being sent when an action is triggered.
  2023. */
  2024. class ActionEvent {
  2025. source: any;
  2026. pointerX: number;
  2027. pointerY: number;
  2028. meshUnderPointer: Nullable<AbstractMesh>;
  2029. sourceEvent: any;
  2030. additionalData: any;
  2031. /**
  2032. * @param source The mesh or sprite that triggered the action.
  2033. * @param pointerX The X mouse cursor position at the time of the event
  2034. * @param pointerY The Y mouse cursor position at the time of the event
  2035. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2036. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2037. */
  2038. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  2039. /**
  2040. * Helper function to auto-create an ActionEvent from a source mesh.
  2041. * @param source The source mesh that triggered the event
  2042. * @param evt {Event} The original (browser) event
  2043. */
  2044. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2045. /**
  2046. * Helper function to auto-create an ActionEvent from a source mesh.
  2047. * @param source The source sprite that triggered the event
  2048. * @param scene Scene associated with the sprite
  2049. * @param evt {Event} The original (browser) event
  2050. */
  2051. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2052. /**
  2053. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2054. * @param scene the scene where the event occurred
  2055. * @param evt {Event} The original (browser) event
  2056. */
  2057. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2058. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2059. }
  2060. /**
  2061. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2062. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2063. */
  2064. class ActionManager {
  2065. private static _NothingTrigger;
  2066. private static _OnPickTrigger;
  2067. private static _OnLeftPickTrigger;
  2068. private static _OnRightPickTrigger;
  2069. private static _OnCenterPickTrigger;
  2070. private static _OnPickDownTrigger;
  2071. private static _OnDoublePickTrigger;
  2072. private static _OnPickUpTrigger;
  2073. private static _OnLongPressTrigger;
  2074. private static _OnPointerOverTrigger;
  2075. private static _OnPointerOutTrigger;
  2076. private static _OnEveryFrameTrigger;
  2077. private static _OnIntersectionEnterTrigger;
  2078. private static _OnIntersectionExitTrigger;
  2079. private static _OnKeyDownTrigger;
  2080. private static _OnKeyUpTrigger;
  2081. private static _OnPickOutTrigger;
  2082. static readonly NothingTrigger: number;
  2083. static readonly OnPickTrigger: number;
  2084. static readonly OnLeftPickTrigger: number;
  2085. static readonly OnRightPickTrigger: number;
  2086. static readonly OnCenterPickTrigger: number;
  2087. static readonly OnPickDownTrigger: number;
  2088. static readonly OnDoublePickTrigger: number;
  2089. static readonly OnPickUpTrigger: number;
  2090. static readonly OnPickOutTrigger: number;
  2091. static readonly OnLongPressTrigger: number;
  2092. static readonly OnPointerOverTrigger: number;
  2093. static readonly OnPointerOutTrigger: number;
  2094. static readonly OnEveryFrameTrigger: number;
  2095. static readonly OnIntersectionEnterTrigger: number;
  2096. static readonly OnIntersectionExitTrigger: number;
  2097. static readonly OnKeyDownTrigger: number;
  2098. static readonly OnKeyUpTrigger: number;
  2099. static Triggers: {
  2100. [key: string]: number;
  2101. };
  2102. actions: Action[];
  2103. hoverCursor: string;
  2104. private _scene;
  2105. constructor(scene: Scene);
  2106. dispose(): void;
  2107. getScene(): Scene;
  2108. /**
  2109. * Does this action manager handles actions of any of the given triggers
  2110. * @param {number[]} triggers - the triggers to be tested
  2111. * @return {boolean} whether one (or more) of the triggers is handeled
  2112. */
  2113. hasSpecificTriggers(triggers: number[]): boolean;
  2114. /**
  2115. * Does this action manager handles actions of a given trigger
  2116. * @param {number} trigger - the trigger to be tested
  2117. * @return {boolean} whether the trigger is handeled
  2118. */
  2119. hasSpecificTrigger(trigger: number): boolean;
  2120. /**
  2121. * Does this action manager has pointer triggers
  2122. * @return {boolean} whether or not it has pointer triggers
  2123. */
  2124. readonly hasPointerTriggers: boolean;
  2125. /**
  2126. * Does this action manager has pick triggers
  2127. * @return {boolean} whether or not it has pick triggers
  2128. */
  2129. readonly hasPickTriggers: boolean;
  2130. /**
  2131. * Does exist one action manager with at least one trigger
  2132. * @return {boolean} whether or not it exists one action manager with one trigger
  2133. **/
  2134. static readonly HasTriggers: boolean;
  2135. /**
  2136. * Does exist one action manager with at least one pick trigger
  2137. * @return {boolean} whether or not it exists one action manager with one pick trigger
  2138. **/
  2139. static readonly HasPickTriggers: boolean;
  2140. /**
  2141. * Does exist one action manager that handles actions of a given trigger
  2142. * @param {number} trigger - the trigger to be tested
  2143. * @return {boolean} whether the trigger is handeled by at least one action manager
  2144. **/
  2145. static HasSpecificTrigger(trigger: number): boolean;
  2146. /**
  2147. * Registers an action to this action manager
  2148. * @param {BABYLON.Action} action - the action to be registered
  2149. * @return {BABYLON.Action} the action amended (prepared) after registration
  2150. */
  2151. registerAction(action: Action): Nullable<Action>;
  2152. /**
  2153. * Unregisters an action to this action manager
  2154. * @param action The action to be unregistered
  2155. * @return whether the action has been unregistered
  2156. */
  2157. unregisterAction(action: Action): Boolean;
  2158. /**
  2159. * Process a specific trigger
  2160. * @param {number} trigger - the trigger to process
  2161. * @param evt {BABYLON.ActionEvent} the event details to be processed
  2162. */
  2163. processTrigger(trigger: number, evt?: ActionEvent): void;
  2164. _getEffectiveTarget(target: any, propertyPath: string): any;
  2165. _getProperty(propertyPath: string): string;
  2166. serialize(name: string): any;
  2167. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2168. static GetTriggerName(trigger: number): string;
  2169. }
  2170. }
  2171. declare module BABYLON {
  2172. /**
  2173. * A Condition applied to an Action
  2174. */
  2175. class Condition {
  2176. /**
  2177. * Internal only - manager for action
  2178. * @ignore
  2179. */
  2180. _actionManager: ActionManager;
  2181. /**
  2182. * Internal only
  2183. * @ignore
  2184. */
  2185. _evaluationId: number;
  2186. /**
  2187. * Internal only
  2188. * @ignore
  2189. */
  2190. _currentResult: boolean;
  2191. /**
  2192. * Creates a new Condition
  2193. * @param actionManager the manager of the action the condition is applied to
  2194. */
  2195. constructor(actionManager: ActionManager);
  2196. /**
  2197. * Check if the current condition is valid
  2198. * @returns a boolean
  2199. */
  2200. isValid(): boolean;
  2201. /**
  2202. * Internal only
  2203. * @ignore
  2204. */
  2205. _getProperty(propertyPath: string): string;
  2206. /**
  2207. * Internal only
  2208. * @ignore
  2209. */
  2210. _getEffectiveTarget(target: any, propertyPath: string): any;
  2211. /**
  2212. * Serialize placeholder for child classes
  2213. * @returns the serialized object
  2214. */
  2215. serialize(): any;
  2216. /**
  2217. * Internal only
  2218. * @ignore
  2219. */
  2220. protected _serialize(serializedCondition: any): any;
  2221. }
  2222. /**
  2223. * Defines specific conditional operators as extensions of Condition
  2224. */
  2225. class ValueCondition extends Condition {
  2226. propertyPath: string;
  2227. value: any;
  2228. operator: number;
  2229. /**
  2230. * Internal only
  2231. * @ignore
  2232. */
  2233. private static _IsEqual;
  2234. /**
  2235. * Internal only
  2236. * @ignore
  2237. */
  2238. private static _IsDifferent;
  2239. /**
  2240. * Internal only
  2241. * @ignore
  2242. */
  2243. private static _IsGreater;
  2244. /**
  2245. * Internal only
  2246. * @ignore
  2247. */
  2248. private static _IsLesser;
  2249. /**
  2250. * returns the number for IsEqual
  2251. */
  2252. static readonly IsEqual: number;
  2253. /**
  2254. * Returns the number for IsDifferent
  2255. */
  2256. static readonly IsDifferent: number;
  2257. /**
  2258. * Returns the number for IsGreater
  2259. */
  2260. static readonly IsGreater: number;
  2261. /**
  2262. * Returns the number for IsLesser
  2263. */
  2264. static readonly IsLesser: number;
  2265. /**
  2266. * Internal only The action manager for the condition
  2267. * @ignore
  2268. */
  2269. _actionManager: ActionManager;
  2270. /**
  2271. * Internal only
  2272. * @ignore
  2273. */
  2274. private _target;
  2275. /**
  2276. * Internal only
  2277. * @ignore
  2278. */
  2279. private _effectiveTarget;
  2280. /**
  2281. * Internal only
  2282. * @ignore
  2283. */
  2284. private _property;
  2285. /**
  2286. * Creates a new ValueCondition
  2287. * @param actionManager manager for the action the condition applies to
  2288. * @param target for the action
  2289. * @param propertyPath path to specify the property of the target the conditional operator uses
  2290. * @param value the vale compared by the conditional operator against the current value of the property
  2291. * @param operator the conditional operator, default {BABYLON.ValueCondition.IsEqual}
  2292. */
  2293. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  2294. /**
  2295. * Compares the given value with the property value for the specified conditional operator
  2296. * @returns the result of the comparison
  2297. */
  2298. isValid(): boolean;
  2299. /**
  2300. * Serialize the ValueCondition into a JSON compatible object
  2301. * @returns serialization object
  2302. */
  2303. serialize(): any;
  2304. /**
  2305. * Gets the name of the conditional operator for the ValueCondition
  2306. * @param operator the conditional operator
  2307. * @returns the name
  2308. */
  2309. static GetOperatorName(operator: number): string;
  2310. }
  2311. /**
  2312. * Defines a predicate condition as an extension of Condition
  2313. */
  2314. class PredicateCondition extends Condition {
  2315. predicate: () => boolean;
  2316. /**
  2317. * Internal only - manager for action
  2318. * @ignore
  2319. */
  2320. _actionManager: ActionManager;
  2321. /**
  2322. * Creates a new {BABYLON.PredicateCondition}
  2323. * @param actionManager manager for the action the condition applies to
  2324. * @param predicate
  2325. */
  2326. constructor(actionManager: ActionManager, predicate: () => boolean);
  2327. /**
  2328. * @returns the validity of the predicate condition
  2329. */
  2330. isValid(): boolean;
  2331. }
  2332. /**
  2333. * Defines a state condition as an extension of {BABYLON.Condition}
  2334. */
  2335. class StateCondition extends Condition {
  2336. value: string;
  2337. /**
  2338. * Internal only - manager for action
  2339. * @ignore
  2340. */
  2341. _actionManager: ActionManager;
  2342. /**
  2343. * Internal only
  2344. * @ignore
  2345. */
  2346. private _target;
  2347. /**
  2348. * Creates a new {BABYLON.StateCondition}
  2349. * @param actionManager manager for the action the condition applies to
  2350. * @param target of the condition
  2351. * @param value to compare with target state
  2352. */
  2353. constructor(actionManager: ActionManager, target: any, value: string);
  2354. /**
  2355. * @returns the validity of the state
  2356. */
  2357. isValid(): boolean;
  2358. /**
  2359. * Serialize the {BABYLON.StateCondition} into a JSON compatible object
  2360. * @returns serialization object
  2361. */
  2362. serialize(): any;
  2363. }
  2364. }
  2365. declare module BABYLON {
  2366. class SwitchBooleanAction extends Action {
  2367. propertyPath: string;
  2368. private _target;
  2369. private _effectiveTarget;
  2370. private _property;
  2371. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  2372. _prepare(): void;
  2373. execute(): void;
  2374. serialize(parent: any): any;
  2375. }
  2376. class SetStateAction extends Action {
  2377. value: string;
  2378. private _target;
  2379. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  2380. execute(): void;
  2381. serialize(parent: any): any;
  2382. }
  2383. class SetValueAction extends Action {
  2384. propertyPath: string;
  2385. value: any;
  2386. private _target;
  2387. private _effectiveTarget;
  2388. private _property;
  2389. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  2390. _prepare(): void;
  2391. execute(): void;
  2392. serialize(parent: any): any;
  2393. }
  2394. class IncrementValueAction extends Action {
  2395. propertyPath: string;
  2396. value: any;
  2397. private _target;
  2398. private _effectiveTarget;
  2399. private _property;
  2400. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  2401. _prepare(): void;
  2402. execute(): void;
  2403. serialize(parent: any): any;
  2404. }
  2405. class PlayAnimationAction extends Action {
  2406. from: number;
  2407. to: number;
  2408. loop: boolean | undefined;
  2409. private _target;
  2410. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  2411. _prepare(): void;
  2412. execute(): void;
  2413. serialize(parent: any): any;
  2414. }
  2415. class StopAnimationAction extends Action {
  2416. private _target;
  2417. constructor(triggerOptions: any, target: any, condition?: Condition);
  2418. _prepare(): void;
  2419. execute(): void;
  2420. serialize(parent: any): any;
  2421. }
  2422. class DoNothingAction extends Action {
  2423. constructor(triggerOptions?: any, condition?: Condition);
  2424. execute(): void;
  2425. serialize(parent: any): any;
  2426. }
  2427. class CombineAction extends Action {
  2428. children: Action[];
  2429. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  2430. _prepare(): void;
  2431. execute(evt: ActionEvent): void;
  2432. serialize(parent: any): any;
  2433. }
  2434. class ExecuteCodeAction extends Action {
  2435. func: (evt: ActionEvent) => void;
  2436. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  2437. execute(evt: ActionEvent): void;
  2438. }
  2439. class SetParentAction extends Action {
  2440. private _parent;
  2441. private _target;
  2442. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  2443. _prepare(): void;
  2444. execute(): void;
  2445. serialize(parent: any): any;
  2446. }
  2447. class PlaySoundAction extends Action {
  2448. private _sound;
  2449. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2450. _prepare(): void;
  2451. execute(): void;
  2452. serialize(parent: any): any;
  2453. }
  2454. class StopSoundAction extends Action {
  2455. private _sound;
  2456. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2457. _prepare(): void;
  2458. execute(): void;
  2459. serialize(parent: any): any;
  2460. }
  2461. }
  2462. declare module BABYLON {
  2463. class InterpolateValueAction extends Action {
  2464. propertyPath: string;
  2465. value: any;
  2466. duration: number;
  2467. stopOtherAnimations: boolean | undefined;
  2468. onInterpolationDone: (() => void) | undefined;
  2469. private _target;
  2470. private _effectiveTarget;
  2471. private _property;
  2472. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  2473. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  2474. _prepare(): void;
  2475. execute(): void;
  2476. serialize(parent: any): any;
  2477. }
  2478. }
  2479. declare module BABYLON {
  2480. class Animatable {
  2481. target: any;
  2482. fromFrame: number;
  2483. toFrame: number;
  2484. loopAnimation: boolean;
  2485. onAnimationEnd: (() => void) | null | undefined;
  2486. private _localDelayOffset;
  2487. private _pausedDelay;
  2488. private _runtimeAnimations;
  2489. private _paused;
  2490. private _scene;
  2491. private _speedRatio;
  2492. private _weight;
  2493. private _syncRoot;
  2494. animationStarted: boolean;
  2495. /**
  2496. * Gets the root Animatable used to synchronize and normalize animations
  2497. */
  2498. readonly syncRoot: Animatable;
  2499. /**
  2500. * Gets the current frame of the first RuntimeAnimation
  2501. * Used to synchronize Animatables
  2502. */
  2503. readonly masterFrame: number;
  2504. /**
  2505. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2506. */
  2507. weight: number;
  2508. /**
  2509. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2510. */
  2511. speedRatio: number;
  2512. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2513. /**
  2514. * Synchronize and normalize current Animatable with a source Animatable.
  2515. * This is useful when using animation weights and when animations are not of the same length
  2516. * @param root defines the root Animatable to synchronize with
  2517. * @returns the current Animatable
  2518. */
  2519. syncWith(root: Animatable): Animatable;
  2520. getAnimations(): RuntimeAnimation[];
  2521. appendAnimations(target: any, animations: Animation[]): void;
  2522. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2523. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2524. reset(): void;
  2525. enableBlending(blendingSpeed: number): void;
  2526. disableBlending(): void;
  2527. goToFrame(frame: number): void;
  2528. pause(): void;
  2529. restart(): void;
  2530. stop(animationName?: string): void;
  2531. _animate(delay: number): boolean;
  2532. }
  2533. }
  2534. declare module BABYLON {
  2535. class AnimationRange {
  2536. name: string;
  2537. from: number;
  2538. to: number;
  2539. constructor(name: string, from: number, to: number);
  2540. clone(): AnimationRange;
  2541. }
  2542. /**
  2543. * Composed of a frame, and an action function
  2544. */
  2545. class AnimationEvent {
  2546. frame: number;
  2547. action: () => void;
  2548. onlyOnce: boolean | undefined;
  2549. isDone: boolean;
  2550. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2551. }
  2552. class PathCursor {
  2553. private path;
  2554. private _onchange;
  2555. value: number;
  2556. animations: Animation[];
  2557. constructor(path: Path2);
  2558. getPoint(): Vector3;
  2559. moveAhead(step?: number): PathCursor;
  2560. moveBack(step?: number): PathCursor;
  2561. move(step: number): PathCursor;
  2562. private ensureLimits();
  2563. private raiseOnChange();
  2564. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2565. }
  2566. interface IAnimationKey {
  2567. frame: number;
  2568. value: any;
  2569. inTangent?: any;
  2570. outTangent?: any;
  2571. interpolation?: AnimationKeyInterpolation;
  2572. }
  2573. enum AnimationKeyInterpolation {
  2574. /**
  2575. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2576. */
  2577. STEP = 1,
  2578. }
  2579. class Animation {
  2580. name: string;
  2581. targetProperty: string;
  2582. framePerSecond: number;
  2583. dataType: number;
  2584. loopMode: number | undefined;
  2585. enableBlending: boolean | undefined;
  2586. static AllowMatricesInterpolation: boolean;
  2587. private _keys;
  2588. private _easingFunction;
  2589. _runtimeAnimations: RuntimeAnimation[];
  2590. private _events;
  2591. targetPropertyPath: string[];
  2592. blendingSpeed: number;
  2593. private _ranges;
  2594. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2595. /**
  2596. * Sets up an animation.
  2597. * @param property the property to animate
  2598. * @param animationType the animation type to apply
  2599. * @param easingFunction the easing function used in the animation
  2600. * @returns The created animation
  2601. */
  2602. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2603. /**
  2604. * Create and start an animation on a node
  2605. * @param {string} name defines the name of the global animation that will be run on all nodes
  2606. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2607. * @param {string} targetProperty defines property to animate
  2608. * @param {number} framePerSecond defines the number of frame per second yo use
  2609. * @param {number} totalFrame defines the number of frames in total
  2610. * @param {any} from defines the initial value
  2611. * @param {any} to defines the final value
  2612. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2613. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2614. * @param onAnimationEnd defines the callback to call when animation end
  2615. * @returns the animatable created for this animation
  2616. */
  2617. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2618. /**
  2619. * Create and start an animation on a node and its descendants
  2620. * @param {string} name defines the name of the global animation that will be run on all nodes
  2621. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2622. * @param {boolean} directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  2623. * @param {string} targetProperty defines property to animate
  2624. * @param {number} framePerSecond defines the number of frame per second yo use
  2625. * @param {number} totalFrame defines the number of frames in total
  2626. * @param {any} from defines the initial value
  2627. * @param {any} to defines the final value
  2628. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2629. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2630. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2631. * @returns the list of animatables created for all nodes
  2632. * @example https://www.babylonjs-playground.com/#MH0VLI
  2633. */
  2634. 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[]>;
  2635. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2636. /**
  2637. * Transition property of the Camera to the target Value.
  2638. * @param property The property to transition
  2639. * @param targetValue The target Value of the property
  2640. * @param host The object where the property to animate belongs
  2641. * @param scene Scene used to run the animation
  2642. * @param frameRate Framerate (in frame/s) to use
  2643. * @param transition The transition type we want to use
  2644. * @param duration The duration of the animation, in milliseconds
  2645. * @param onAnimationEnd Call back trigger at the end of the animation.
  2646. */
  2647. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2648. /**
  2649. * Return the array of runtime animations currently using this animation
  2650. */
  2651. readonly runtimeAnimations: RuntimeAnimation[];
  2652. readonly hasRunningRuntimeAnimations: boolean;
  2653. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2654. /**
  2655. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2656. */
  2657. toString(fullDetails?: boolean): string;
  2658. /**
  2659. * Add an event to this animation.
  2660. */
  2661. addEvent(event: AnimationEvent): void;
  2662. /**
  2663. * Remove all events found at the given frame
  2664. * @param frame
  2665. */
  2666. removeEvents(frame: number): void;
  2667. getEvents(): AnimationEvent[];
  2668. createRange(name: string, from: number, to: number): void;
  2669. deleteRange(name: string, deleteFrames?: boolean): void;
  2670. getRange(name: string): Nullable<AnimationRange>;
  2671. getKeys(): Array<IAnimationKey>;
  2672. getHighestFrame(): number;
  2673. getEasingFunction(): IEasingFunction;
  2674. setEasingFunction(easingFunction: EasingFunction): void;
  2675. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2676. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2677. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2678. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2679. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2680. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2681. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2682. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2683. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2684. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2685. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2686. clone(): Animation;
  2687. setKeys(values: Array<IAnimationKey>): void;
  2688. serialize(): any;
  2689. private static _ANIMATIONTYPE_FLOAT;
  2690. private static _ANIMATIONTYPE_VECTOR3;
  2691. private static _ANIMATIONTYPE_QUATERNION;
  2692. private static _ANIMATIONTYPE_MATRIX;
  2693. private static _ANIMATIONTYPE_COLOR3;
  2694. private static _ANIMATIONTYPE_VECTOR2;
  2695. private static _ANIMATIONTYPE_SIZE;
  2696. private static _ANIMATIONLOOPMODE_RELATIVE;
  2697. private static _ANIMATIONLOOPMODE_CYCLE;
  2698. private static _ANIMATIONLOOPMODE_CONSTANT;
  2699. static readonly ANIMATIONTYPE_FLOAT: number;
  2700. static readonly ANIMATIONTYPE_VECTOR3: number;
  2701. static readonly ANIMATIONTYPE_VECTOR2: number;
  2702. static readonly ANIMATIONTYPE_SIZE: number;
  2703. static readonly ANIMATIONTYPE_QUATERNION: number;
  2704. static readonly ANIMATIONTYPE_MATRIX: number;
  2705. static readonly ANIMATIONTYPE_COLOR3: number;
  2706. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2707. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2708. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2709. static Parse(parsedAnimation: any): Animation;
  2710. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2711. }
  2712. }
  2713. declare module BABYLON {
  2714. /**
  2715. * This class defines the direct association between an animation and a target
  2716. */
  2717. class TargetedAnimation {
  2718. animation: Animation;
  2719. target: any;
  2720. }
  2721. /**
  2722. * Use this class to create coordinated animations on multiple targets
  2723. */
  2724. class AnimationGroup implements IDisposable {
  2725. name: string;
  2726. private _scene;
  2727. private _targetedAnimations;
  2728. private _animatables;
  2729. private _from;
  2730. private _to;
  2731. private _isStarted;
  2732. private _speedRatio;
  2733. onAnimationEndObservable: Observable<TargetedAnimation>;
  2734. /**
  2735. * Define if the animations are started
  2736. */
  2737. readonly isStarted: boolean;
  2738. /**
  2739. * Gets or sets the speed ratio to use for all animations
  2740. */
  2741. /**
  2742. * Gets or sets the speed ratio to use for all animations
  2743. */
  2744. speedRatio: number;
  2745. /**
  2746. * Gets the targeted animations for this animation group
  2747. */
  2748. readonly targetedAnimations: Array<TargetedAnimation>;
  2749. /**
  2750. * returning the list of animatables controlled by this animation group.
  2751. */
  2752. readonly animatables: Array<Animatable>;
  2753. constructor(name: string, scene?: Nullable<Scene>);
  2754. /**
  2755. * Add an animation (with its target) in the group
  2756. * @param animation defines the animation we want to add
  2757. * @param target defines the target of the animation
  2758. * @returns the {BABYLON.TargetedAnimation} object
  2759. */
  2760. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2761. /**
  2762. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2763. * It can add constant keys at begin or end
  2764. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2765. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2766. */
  2767. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2768. /**
  2769. * Start all animations on given targets
  2770. * @param loop defines if animations must loop
  2771. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2772. * @param from defines the from key (optional)
  2773. * @param to defines the to key (optional)
  2774. * @returns the current animation group
  2775. */
  2776. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  2777. /**
  2778. * Pause all animations
  2779. */
  2780. pause(): AnimationGroup;
  2781. /**
  2782. * Play all animations to initial state
  2783. * This function will start() the animations if they were not started or will restart() them if they were paused
  2784. * @param loop defines if animations must loop
  2785. */
  2786. play(loop?: boolean): AnimationGroup;
  2787. /**
  2788. * Reset all animations to initial state
  2789. */
  2790. reset(): AnimationGroup;
  2791. /**
  2792. * Restart animations from key 0
  2793. */
  2794. restart(): AnimationGroup;
  2795. /**
  2796. * Stop all animations
  2797. */
  2798. stop(): AnimationGroup;
  2799. /**
  2800. * Goes to a specific frame in this animation group
  2801. *
  2802. * @param frame the frame number to go to
  2803. * @return the animationGroup
  2804. */
  2805. goToFrame(frame: number): AnimationGroup;
  2806. /**
  2807. * Dispose all associated resources
  2808. */
  2809. dispose(): void;
  2810. }
  2811. }
  2812. declare module BABYLON {
  2813. /**
  2814. * Class used to override all child animations of a given target
  2815. */
  2816. class AnimationPropertiesOverride {
  2817. /**
  2818. * Gets or sets a value indicating if animation blending must be used
  2819. */
  2820. enableBlending: boolean;
  2821. /**
  2822. * Gets or sets the blending speed to use when enableBlending is true
  2823. */
  2824. blendingSpeed: number;
  2825. /**
  2826. * Gets or sets the default loop mode to use
  2827. */
  2828. loopMode: number;
  2829. }
  2830. }
  2831. declare module BABYLON {
  2832. interface IEasingFunction {
  2833. ease(gradient: number): number;
  2834. }
  2835. class EasingFunction implements IEasingFunction {
  2836. private static _EASINGMODE_EASEIN;
  2837. private static _EASINGMODE_EASEOUT;
  2838. private static _EASINGMODE_EASEINOUT;
  2839. static readonly EASINGMODE_EASEIN: number;
  2840. static readonly EASINGMODE_EASEOUT: number;
  2841. static readonly EASINGMODE_EASEINOUT: number;
  2842. private _easingMode;
  2843. setEasingMode(easingMode: number): void;
  2844. getEasingMode(): number;
  2845. easeInCore(gradient: number): number;
  2846. ease(gradient: number): number;
  2847. }
  2848. class CircleEase extends EasingFunction implements IEasingFunction {
  2849. easeInCore(gradient: number): number;
  2850. }
  2851. class BackEase extends EasingFunction implements IEasingFunction {
  2852. amplitude: number;
  2853. constructor(amplitude?: number);
  2854. easeInCore(gradient: number): number;
  2855. }
  2856. class BounceEase extends EasingFunction implements IEasingFunction {
  2857. bounces: number;
  2858. bounciness: number;
  2859. constructor(bounces?: number, bounciness?: number);
  2860. easeInCore(gradient: number): number;
  2861. }
  2862. class CubicEase extends EasingFunction implements IEasingFunction {
  2863. easeInCore(gradient: number): number;
  2864. }
  2865. class ElasticEase extends EasingFunction implements IEasingFunction {
  2866. oscillations: number;
  2867. springiness: number;
  2868. constructor(oscillations?: number, springiness?: number);
  2869. easeInCore(gradient: number): number;
  2870. }
  2871. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2872. exponent: number;
  2873. constructor(exponent?: number);
  2874. easeInCore(gradient: number): number;
  2875. }
  2876. class PowerEase extends EasingFunction implements IEasingFunction {
  2877. power: number;
  2878. constructor(power?: number);
  2879. easeInCore(gradient: number): number;
  2880. }
  2881. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2882. easeInCore(gradient: number): number;
  2883. }
  2884. class QuarticEase extends EasingFunction implements IEasingFunction {
  2885. easeInCore(gradient: number): number;
  2886. }
  2887. class QuinticEase extends EasingFunction implements IEasingFunction {
  2888. easeInCore(gradient: number): number;
  2889. }
  2890. class SineEase extends EasingFunction implements IEasingFunction {
  2891. easeInCore(gradient: number): number;
  2892. }
  2893. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2894. x1: number;
  2895. y1: number;
  2896. x2: number;
  2897. y2: number;
  2898. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2899. easeInCore(gradient: number): number;
  2900. }
  2901. }
  2902. declare module BABYLON {
  2903. class RuntimeAnimation {
  2904. private _currentFrame;
  2905. private _animation;
  2906. private _target;
  2907. private _host;
  2908. private _originalValue;
  2909. private _originalBlendValue;
  2910. private _offsetsCache;
  2911. private _highLimitsCache;
  2912. private _stopped;
  2913. private _blendingFactor;
  2914. private _scene;
  2915. private _currentValue;
  2916. private _activeTarget;
  2917. private _targetPath;
  2918. private _weight;
  2919. /**
  2920. * Gets the current frame
  2921. */
  2922. readonly currentFrame: number;
  2923. /**
  2924. * Gets the weight of the runtime animation
  2925. */
  2926. readonly weight: number;
  2927. /**
  2928. * Gets the original value of the runtime animation
  2929. */
  2930. readonly originalValue: any;
  2931. /**
  2932. * Gets the current value of the runtime animation
  2933. */
  2934. readonly currentValue: any;
  2935. /**
  2936. * Gets the path where to store the animated value in the target
  2937. */
  2938. readonly targetPath: string;
  2939. /**
  2940. * Gets the actual target of the runtime animation
  2941. */
  2942. readonly target: any;
  2943. /**
  2944. * Create a new RuntimeAnimation object
  2945. * @param target defines the target of the animation
  2946. * @param animation defines the source {BABYLON.Animation} object
  2947. * @param scene defines the hosting scene
  2948. * @param host defines the initiating Animatable
  2949. */
  2950. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  2951. readonly animation: Animation;
  2952. reset(): void;
  2953. isStopped(): boolean;
  2954. dispose(): void;
  2955. private _getKeyValue(value);
  2956. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2957. /**
  2958. * Affect the interpolated value to the target
  2959. * @param currentValue defines the value computed by the animation
  2960. * @param weight defines the weight to apply to this value
  2961. */
  2962. setValue(currentValue: any, weight?: number): void;
  2963. private _getCorrectLoopMode();
  2964. /**
  2965. * Move the current animation to a given frame
  2966. * @param frame defines the frame to move to
  2967. */
  2968. goToFrame(frame: number): void;
  2969. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2970. private _ratioOffset;
  2971. private _previousDelay;
  2972. private _previousRatio;
  2973. /**
  2974. * Execute the current animation
  2975. * @param delay defines the delay to add to the current frame
  2976. * @param from defines the lower bound of the animation range
  2977. * @param to defines the upper bound of the animation range
  2978. * @param loop defines if the current animation must loop
  2979. * @param speedRatio defines the current speed ratio
  2980. * @param weight defines the weight of the animation (default is -1 so no weight)
  2981. * @returns a boolean indicating if the animation has ended
  2982. */
  2983. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  2984. }
  2985. }
  2986. declare module BABYLON {
  2987. class ArcRotateCamera extends TargetCamera {
  2988. alpha: number;
  2989. beta: number;
  2990. radius: number;
  2991. protected _target: Vector3;
  2992. protected _targetHost: Nullable<AbstractMesh>;
  2993. target: Vector3;
  2994. inertialAlphaOffset: number;
  2995. inertialBetaOffset: number;
  2996. inertialRadiusOffset: number;
  2997. lowerAlphaLimit: Nullable<number>;
  2998. upperAlphaLimit: Nullable<number>;
  2999. lowerBetaLimit: number;
  3000. upperBetaLimit: number;
  3001. lowerRadiusLimit: Nullable<number>;
  3002. upperRadiusLimit: Nullable<number>;
  3003. inertialPanningX: number;
  3004. inertialPanningY: number;
  3005. pinchToPanMaxDistance: number;
  3006. panningDistanceLimit: Nullable<number>;
  3007. panningOriginTarget: Vector3;
  3008. panningInertia: number;
  3009. angularSensibilityX: number;
  3010. angularSensibilityY: number;
  3011. pinchPrecision: number;
  3012. pinchDeltaPercentage: number;
  3013. panningSensibility: number;
  3014. keysUp: number[];
  3015. keysDown: number[];
  3016. keysLeft: number[];
  3017. keysRight: number[];
  3018. wheelPrecision: number;
  3019. wheelDeltaPercentage: number;
  3020. zoomOnFactor: number;
  3021. targetScreenOffset: Vector2;
  3022. allowUpsideDown: boolean;
  3023. _viewMatrix: Matrix;
  3024. _useCtrlForPanning: boolean;
  3025. _panningMouseButton: number;
  3026. inputs: ArcRotateCameraInputsManager;
  3027. _reset: () => void;
  3028. panningAxis: Vector3;
  3029. protected _localDirection: Vector3;
  3030. protected _transformedDirection: Vector3;
  3031. private _bouncingBehavior;
  3032. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3033. useBouncingBehavior: boolean;
  3034. private _framingBehavior;
  3035. readonly framingBehavior: Nullable<FramingBehavior>;
  3036. useFramingBehavior: boolean;
  3037. private _autoRotationBehavior;
  3038. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3039. useAutoRotationBehavior: boolean;
  3040. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3041. onCollide: (collidedMesh: AbstractMesh) => void;
  3042. checkCollisions: boolean;
  3043. collisionRadius: Vector3;
  3044. protected _collider: Collider;
  3045. protected _previousPosition: Vector3;
  3046. protected _collisionVelocity: Vector3;
  3047. protected _newPosition: Vector3;
  3048. protected _previousAlpha: number;
  3049. protected _previousBeta: number;
  3050. protected _previousRadius: number;
  3051. protected _collisionTriggered: boolean;
  3052. protected _targetBoundingCenter: Nullable<Vector3>;
  3053. private _computationVector;
  3054. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3055. _initCache(): void;
  3056. _updateCache(ignoreParentClass?: boolean): void;
  3057. protected _getTargetPosition(): Vector3;
  3058. /**
  3059. * Store current camera state (fov, position, etc..)
  3060. */
  3061. private _storedAlpha;
  3062. private _storedBeta;
  3063. private _storedRadius;
  3064. private _storedTarget;
  3065. storeState(): Camera;
  3066. /**
  3067. * Restored camera state. You must call storeState() first
  3068. */
  3069. _restoreStateValues(): boolean;
  3070. _isSynchronizedViewMatrix(): boolean;
  3071. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3072. detachControl(element: HTMLElement): void;
  3073. _checkInputs(): void;
  3074. protected _checkLimits(): void;
  3075. rebuildAnglesAndRadius(): void;
  3076. setPosition(position: Vector3): void;
  3077. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3078. _getViewMatrix(): Matrix;
  3079. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3080. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3081. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3082. min: Vector3;
  3083. max: Vector3;
  3084. distance: number;
  3085. }, doNotUpdateMaxZ?: boolean): void;
  3086. /**
  3087. * @override
  3088. * Override Camera.createRigCamera
  3089. */
  3090. createRigCamera(name: string, cameraIndex: number): Camera;
  3091. /**
  3092. * @override
  3093. * Override Camera._updateRigCameras
  3094. */
  3095. _updateRigCameras(): void;
  3096. dispose(): void;
  3097. getClassName(): string;
  3098. }
  3099. }
  3100. declare module BABYLON {
  3101. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3102. constructor(camera: ArcRotateCamera);
  3103. addMouseWheel(): ArcRotateCameraInputsManager;
  3104. addPointers(): ArcRotateCameraInputsManager;
  3105. addKeyboard(): ArcRotateCameraInputsManager;
  3106. addGamepad(): ArcRotateCameraInputsManager;
  3107. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3108. }
  3109. }
  3110. declare module BABYLON {
  3111. <<<<<<< HEAD
  3112. class Camera extends Node {
  3113. inputs: CameraInputsManager<Camera>;
  3114. private static _PERSPECTIVE_CAMERA;
  3115. private static _ORTHOGRAPHIC_CAMERA;
  3116. private static _FOVMODE_VERTICAL_FIXED;
  3117. private static _FOVMODE_HORIZONTAL_FIXED;
  3118. private static _RIG_MODE_NONE;
  3119. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3120. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3121. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3122. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3123. private static _RIG_MODE_VR;
  3124. private static _RIG_MODE_WEBVR;
  3125. static readonly PERSPECTIVE_CAMERA: number;
  3126. static readonly ORTHOGRAPHIC_CAMERA: number;
  3127. =======
  3128. interface Behavior<T extends Node> {
  3129. name: string;
  3130. init(): void;
  3131. attach(node: T): void;
  3132. detach(): void;
  3133. }
  3134. }
  3135. declare module BABYLON {
  3136. class Bone extends Node {
  3137. name: string;
  3138. private static _tmpVecs;
  3139. private static _tmpQuat;
  3140. private static _tmpMats;
  3141. children: Bone[];
  3142. animations: Animation[];
  3143. length: number;
  3144. _index: Nullable<number>;
  3145. private _skeleton;
  3146. private _localMatrix;
  3147. private _restPose;
  3148. private _baseMatrix;
  3149. private _worldTransform;
  3150. private _absoluteTransform;
  3151. private _invertedAbsoluteTransform;
  3152. private _parent;
  3153. private _scaleMatrix;
  3154. private _scaleVector;
  3155. private _negateScaleChildren;
  3156. private _scalingDeterminant;
  3157. _matrix: Matrix;
  3158. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  3159. getSkeleton(): Skeleton;
  3160. getParent(): Nullable<Bone>;
  3161. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  3162. getLocalMatrix(): Matrix;
  3163. getBaseMatrix(): Matrix;
  3164. getRestPose(): Matrix;
  3165. returnToRest(): void;
  3166. getWorldMatrix(): Matrix;
  3167. getInvertedAbsoluteTransform(): Matrix;
  3168. getAbsoluteTransform(): Matrix;
  3169. position: Vector3;
  3170. rotation: Vector3;
  3171. rotationQuaternion: Quaternion;
  3172. scaling: Vector3;
  3173. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  3174. /**
  3175. * This is the default FOV mode for perspective cameras.
  3176. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3177. *
  3178. */
  3179. static readonly FOVMODE_VERTICAL_FIXED: number;
  3180. /**
  3181. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3182. *
  3183. */
  3184. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3185. static readonly RIG_MODE_NONE: number;
  3186. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3187. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3188. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3189. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3190. static readonly RIG_MODE_VR: number;
  3191. static readonly RIG_MODE_WEBVR: number;
  3192. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3193. static UseAlternateWebVRRendering: boolean;
  3194. position: Vector3;
  3195. /**
  3196. * The vector the camera should consider as up.
  3197. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3198. */
  3199. upVector: Vector3;
  3200. orthoLeft: Nullable<number>;
  3201. orthoRight: Nullable<number>;
  3202. orthoBottom: Nullable<number>;
  3203. orthoTop: Nullable<number>;
  3204. /**
  3205. * FOV is set in Radians. (default is 0.8)
  3206. */
  3207. fov: number;
  3208. minZ: number;
  3209. maxZ: number;
  3210. inertia: number;
  3211. mode: number;
  3212. isIntermediate: boolean;
  3213. viewport: Viewport;
  3214. /**
  3215. * Restricts the camera to viewing objects with the same layerMask.
  3216. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3217. */
  3218. layerMask: number;
  3219. /**
  3220. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3221. */
  3222. fovMode: number;
  3223. cameraRigMode: number;
  3224. interaxialDistance: number;
  3225. isStereoscopicSideBySide: boolean;
  3226. _cameraRigParams: any;
  3227. _rigCameras: Camera[];
  3228. _rigPostProcess: Nullable<PostProcess>;
  3229. protected _webvrViewMatrix: Matrix;
  3230. _skipRendering: boolean;
  3231. _alternateCamera: Camera;
  3232. customRenderTargets: RenderTargetTexture[];
  3233. onViewMatrixChangedObservable: Observable<Camera>;
  3234. onProjectionMatrixChangedObservable: Observable<Camera>;
  3235. onAfterCheckInputsObservable: Observable<Camera>;
  3236. onRestoreStateObservable: Observable<Camera>;
  3237. private _computedViewMatrix;
  3238. _projectionMatrix: Matrix;
  3239. private _doNotComputeProjectionMatrix;
  3240. private _worldMatrix;
  3241. _postProcesses: Nullable<PostProcess>[];
  3242. private _transformMatrix;
  3243. _activeMeshes: SmartArray<AbstractMesh>;
  3244. private _globalPosition;
  3245. private _frustumPlanes;
  3246. private _refreshFrustumPlanes;
  3247. constructor(name: string, position: Vector3, scene: Scene);
  3248. private _storedFov;
  3249. private _stateStored;
  3250. /**
  3251. * Store current camera state (fov, position, etc..)
  3252. */
  3253. storeState(): Camera;
  3254. /**
  3255. * Restores the camera state values if it has been stored. You must call storeState() first
  3256. */
  3257. protected _restoreStateValues(): boolean;
  3258. /**
  3259. * Restored camera state. You must call storeState() first
  3260. */
  3261. restoreState(): boolean;
  3262. getClassName(): string;
  3263. /**
  3264. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3265. */
  3266. toString(fullDetails?: boolean): string;
  3267. readonly globalPosition: Vector3;
  3268. getActiveMeshes(): SmartArray<AbstractMesh>;
  3269. isActiveMesh(mesh: Mesh): boolean;
  3270. /**
  3271. * Is this camera ready to be used/rendered
  3272. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  3273. * @return true if the camera is ready
  3274. */
  3275. isReady(completeCheck?: boolean): boolean;
  3276. _initCache(): void;
  3277. _updateCache(ignoreParentClass?: boolean): void;
  3278. _isSynchronized(): boolean;
  3279. _isSynchronizedViewMatrix(): boolean;
  3280. _isSynchronizedProjectionMatrix(): boolean;
  3281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3282. detachControl(element: HTMLElement): void;
  3283. update(): void;
  3284. _checkInputs(): void;
  3285. readonly rigCameras: Camera[];
  3286. readonly rigPostProcess: Nullable<PostProcess>;
  3287. /**
  3288. * Internal, gets the first post proces.
  3289. * @returns the first post process to be run on this camera.
  3290. */
  3291. _getFirstPostProcess(): Nullable<PostProcess>;
  3292. private _cascadePostProcessesToRigCams();
  3293. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3294. detachPostProcess(postProcess: PostProcess): void;
  3295. getWorldMatrix(): Matrix;
  3296. _getViewMatrix(): Matrix;
  3297. getViewMatrix(force?: boolean): Matrix;
  3298. freezeProjectionMatrix(projection?: Matrix): void;
  3299. unfreezeProjectionMatrix(): void;
  3300. getProjectionMatrix(force?: boolean): Matrix;
  3301. getTranformationMatrix(): Matrix;
  3302. private updateFrustumPlanes();
  3303. isInFrustum(target: ICullable): boolean;
  3304. isCompletelyInFrustum(target: ICullable): boolean;
  3305. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3306. /**
  3307. * Releases resources associated with this node.
  3308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  3309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  3310. */
  3311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  3312. readonly leftCamera: Nullable<FreeCamera>;
  3313. readonly rightCamera: Nullable<FreeCamera>;
  3314. getLeftTarget(): Nullable<Vector3>;
  3315. getRightTarget(): Nullable<Vector3>;
  3316. setCameraRigMode(mode: number, rigParams: any): void;
  3317. private _getVRProjectionMatrix();
  3318. protected _updateCameraRotationMatrix(): void;
  3319. protected _updateWebVRCameraRotationMatrix(): void;
  3320. /**
  3321. * This function MUST be overwritten by the different WebVR cameras available.
  3322. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3323. */
  3324. protected _getWebVRProjectionMatrix(): Matrix;
  3325. /**
  3326. * This function MUST be overwritten by the different WebVR cameras available.
  3327. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3328. */
  3329. protected _getWebVRViewMatrix(): Matrix;
  3330. setCameraRigParameter(name: string, value: any): void;
  3331. /**
  3332. * needs to be overridden by children so sub has required properties to be copied
  3333. */
  3334. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3335. /**
  3336. * May need to be overridden by children
  3337. */
  3338. _updateRigCameras(): void;
  3339. _setupInputs(): void;
  3340. serialize(): any;
  3341. clone(name: string): Camera;
  3342. getDirection(localAxis: Vector3): Vector3;
  3343. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3344. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3345. computeWorldMatrix(): Matrix;
  3346. static Parse(parsedCamera: any, scene: Scene): Camera;
  3347. }
  3348. }
  3349. declare module BABYLON {
  3350. var CameraInputTypes: {};
  3351. interface ICameraInput<TCamera extends Camera> {
  3352. camera: Nullable<TCamera>;
  3353. getClassName(): string;
  3354. getSimpleName(): string;
  3355. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3356. detachControl: (element: Nullable<HTMLElement>) => void;
  3357. checkInputs?: () => void;
  3358. }
  3359. interface CameraInputsMap<TCamera extends Camera> {
  3360. [name: string]: ICameraInput<TCamera>;
  3361. [idx: number]: ICameraInput<TCamera>;
  3362. }
  3363. class CameraInputsManager<TCamera extends Camera> {
  3364. attached: CameraInputsMap<TCamera>;
  3365. attachedElement: Nullable<HTMLElement>;
  3366. noPreventDefault: boolean;
  3367. camera: TCamera;
  3368. checkInputs: () => void;
  3369. constructor(camera: TCamera);
  3370. /**
  3371. * Add an input method to a camera.
  3372. * builtin inputs example: camera.inputs.addGamepad();
  3373. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3374. * @param input camera input method
  3375. */
  3376. add(input: ICameraInput<TCamera>): void;
  3377. /**
  3378. * Remove a specific input method from a camera
  3379. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3380. * @param inputToRemove camera input method
  3381. */
  3382. remove(inputToRemove: ICameraInput<TCamera>): void;
  3383. removeByType(inputType: string): void;
  3384. private _addCheckInputs(fn);
  3385. attachInput(input: ICameraInput<TCamera>): void;
  3386. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3387. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3388. rebuildInputCheck(): void;
  3389. /**
  3390. * Remove all attached input methods from a camera
  3391. */
  3392. clear(): void;
  3393. serialize(serializedCamera: any): void;
  3394. parse(parsedCamera: any): void;
  3395. }
  3396. }
  3397. declare module BABYLON {
  3398. /**
  3399. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3400. * being tilted forward or back and left or right.
  3401. */
  3402. class DeviceOrientationCamera extends FreeCamera {
  3403. private _initialQuaternion;
  3404. private _quaternionCache;
  3405. /**
  3406. * Creates a new device orientation camera
  3407. * @param name The name of the camera
  3408. * @param position The start position camera
  3409. * @param scene The scene the camera belongs to
  3410. */
  3411. constructor(name: string, position: Vector3, scene: Scene);
  3412. /**
  3413. * Gets the current instance class name ("DeviceOrientationCamera").
  3414. * This helps avoiding instanceof at run time.
  3415. * @returns the class name
  3416. */
  3417. getClassName(): string;
  3418. /**
  3419. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3420. */
  3421. _checkInputs(): void;
  3422. /**
  3423. * Reset the camera to its default orientation on the specified axis only.
  3424. * @param axis The axis to reset
  3425. */
  3426. resetToCurrentRotation(axis?: Axis): void;
  3427. }
  3428. }
  3429. declare module BABYLON {
  3430. class FollowCamera extends TargetCamera {
  3431. radius: number;
  3432. rotationOffset: number;
  3433. heightOffset: number;
  3434. cameraAcceleration: number;
  3435. maxCameraSpeed: number;
  3436. lockedTarget: Nullable<AbstractMesh>;
  3437. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3438. private getRadians(degrees);
  3439. private follow(cameraTarget);
  3440. _checkInputs(): void;
  3441. getClassName(): string;
  3442. }
  3443. class ArcFollowCamera extends TargetCamera {
  3444. alpha: number;
  3445. beta: number;
  3446. radius: number;
  3447. target: Nullable<AbstractMesh>;
  3448. private _cartesianCoordinates;
  3449. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3450. private follow();
  3451. _checkInputs(): void;
  3452. getClassName(): string;
  3453. }
  3454. }
  3455. declare module BABYLON {
  3456. class FreeCamera extends TargetCamera {
  3457. ellipsoid: Vector3;
  3458. ellipsoidOffset: Vector3;
  3459. checkCollisions: boolean;
  3460. applyGravity: boolean;
  3461. inputs: FreeCameraInputsManager;
  3462. /**
  3463. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3464. * Higher values reduce sensitivity.
  3465. */
  3466. /**
  3467. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3468. * Higher values reduce sensitivity.
  3469. */
  3470. angularSensibility: number;
  3471. keysUp: number[];
  3472. keysDown: number[];
  3473. keysLeft: number[];
  3474. keysRight: number[];
  3475. onCollide: (collidedMesh: AbstractMesh) => void;
  3476. private _collider;
  3477. private _needMoveForGravity;
  3478. private _oldPosition;
  3479. private _diffPosition;
  3480. private _newPosition;
  3481. _localDirection: Vector3;
  3482. _transformedDirection: Vector3;
  3483. constructor(name: string, position: Vector3, scene: Scene);
  3484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3485. detachControl(element: HTMLElement): void;
  3486. private _collisionMask;
  3487. collisionMask: number;
  3488. _collideWithWorld(displacement: Vector3): void;
  3489. private _onCollisionPositionChange;
  3490. _checkInputs(): void;
  3491. _decideIfNeedsToMove(): boolean;
  3492. _updatePosition(): void;
  3493. dispose(): void;
  3494. getClassName(): string;
  3495. }
  3496. }
  3497. declare module BABYLON {
  3498. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3499. constructor(camera: FreeCamera);
  3500. addKeyboard(): FreeCameraInputsManager;
  3501. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3502. addGamepad(): FreeCameraInputsManager;
  3503. addDeviceOrientation(): FreeCameraInputsManager;
  3504. addTouch(): FreeCameraInputsManager;
  3505. addVirtualJoystick(): FreeCameraInputsManager;
  3506. }
  3507. }
  3508. declare module BABYLON {
  3509. class GamepadCamera extends UniversalCamera {
  3510. gamepadAngularSensibility: number;
  3511. gamepadMoveSensibility: number;
  3512. constructor(name: string, position: Vector3, scene: Scene);
  3513. getClassName(): string;
  3514. }
  3515. }
  3516. declare module BABYLON {
  3517. class AnaglyphFreeCamera extends FreeCamera {
  3518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3519. getClassName(): string;
  3520. }
  3521. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3522. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3523. getClassName(): string;
  3524. }
  3525. class AnaglyphGamepadCamera extends GamepadCamera {
  3526. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3527. getClassName(): string;
  3528. }
  3529. class AnaglyphUniversalCamera extends UniversalCamera {
  3530. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3531. getClassName(): string;
  3532. }
  3533. class StereoscopicFreeCamera extends FreeCamera {
  3534. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3535. getClassName(): string;
  3536. }
  3537. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3538. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3539. getClassName(): string;
  3540. }
  3541. class StereoscopicGamepadCamera extends GamepadCamera {
  3542. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3543. getClassName(): string;
  3544. }
  3545. class StereoscopicUniversalCamera extends UniversalCamera {
  3546. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3547. getClassName(): string;
  3548. }
  3549. }
  3550. declare module BABYLON {
  3551. class TargetCamera extends Camera {
  3552. cameraDirection: Vector3;
  3553. cameraRotation: Vector2;
  3554. rotation: Vector3;
  3555. rotationQuaternion: Quaternion;
  3556. speed: number;
  3557. noRotationConstraint: boolean;
  3558. lockedTarget: any;
  3559. _currentTarget: Vector3;
  3560. _viewMatrix: Matrix;
  3561. _camMatrix: Matrix;
  3562. _cameraTransformMatrix: Matrix;
  3563. _cameraRotationMatrix: Matrix;
  3564. private _rigCamTransformMatrix;
  3565. _referencePoint: Vector3;
  3566. private _currentUpVector;
  3567. _transformedReferencePoint: Vector3;
  3568. _lookAtTemp: Matrix;
  3569. _tempMatrix: Matrix;
  3570. _reset: () => void;
  3571. constructor(name: string, position: Vector3, scene: Scene);
  3572. getFrontPosition(distance: number): Vector3;
  3573. _getLockedTargetPosition(): Nullable<Vector3>;
  3574. /**
  3575. * Store current camera state (fov, position, etc..)
  3576. */
  3577. private _storedPosition;
  3578. private _storedRotation;
  3579. private _storedRotationQuaternion;
  3580. storeState(): Camera;
  3581. /**
  3582. * Restored camera state. You must call storeState() first
  3583. */
  3584. _restoreStateValues(): boolean;
  3585. _initCache(): void;
  3586. _updateCache(ignoreParentClass?: boolean): void;
  3587. _isSynchronizedViewMatrix(): boolean;
  3588. _computeLocalCameraSpeed(): number;
  3589. setTarget(target: Vector3): void;
  3590. /**
  3591. * Return the current target position of the camera. This value is expressed in local space.
  3592. */
  3593. getTarget(): Vector3;
  3594. _decideIfNeedsToMove(): boolean;
  3595. _updatePosition(): void;
  3596. _checkInputs(): void;
  3597. protected _updateCameraRotationMatrix(): void;
  3598. _getViewMatrix(): Matrix;
  3599. /**
  3600. * @override
  3601. * Override Camera.createRigCamera
  3602. */
  3603. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3604. /**
  3605. * @override
  3606. * Override Camera._updateRigCameras
  3607. */
  3608. _updateRigCameras(): void;
  3609. private _getRigCamPosition(halfSpace, result);
  3610. getClassName(): string;
  3611. }
  3612. }
  3613. declare module BABYLON {
  3614. <<<<<<< HEAD
  3615. class TouchCamera extends FreeCamera {
  3616. touchAngularSensibility: number;
  3617. touchMoveSensibility: number;
  3618. constructor(name: string, position: Vector3, scene: Scene);
  3619. getClassName(): string;
  3620. _setupInputs(): void;
  3621. }
  3622. }
  3623. declare module BABYLON {
  3624. class UniversalCamera extends TouchCamera {
  3625. gamepadAngularSensibility: number;
  3626. gamepadMoveSensibility: number;
  3627. constructor(name: string, position: Vector3, scene: Scene);
  3628. getClassName(): string;
  3629. }
  3630. }
  3631. declare module BABYLON {
  3632. class VirtualJoysticksCamera extends FreeCamera {
  3633. constructor(name: string, position: Vector3, scene: Scene);
  3634. =======
  3635. class ArcRotateCamera extends TargetCamera {
  3636. alpha: number;
  3637. beta: number;
  3638. radius: number;
  3639. protected _target: Vector3;
  3640. protected _targetHost: Nullable<AbstractMesh>;
  3641. target: Vector3;
  3642. inertialAlphaOffset: number;
  3643. inertialBetaOffset: number;
  3644. inertialRadiusOffset: number;
  3645. lowerAlphaLimit: Nullable<number>;
  3646. upperAlphaLimit: Nullable<number>;
  3647. lowerBetaLimit: number;
  3648. upperBetaLimit: number;
  3649. lowerRadiusLimit: Nullable<number>;
  3650. upperRadiusLimit: Nullable<number>;
  3651. inertialPanningX: number;
  3652. inertialPanningY: number;
  3653. pinchToPanMaxDistance: number;
  3654. panningDistanceLimit: Nullable<number>;
  3655. panningOriginTarget: Vector3;
  3656. panningInertia: number;
  3657. angularSensibilityX: number;
  3658. angularSensibilityY: number;
  3659. pinchPrecision: number;
  3660. pinchDeltaPercentage: number;
  3661. panningSensibility: number;
  3662. keysUp: number[];
  3663. keysDown: number[];
  3664. keysLeft: number[];
  3665. keysRight: number[];
  3666. wheelPrecision: number;
  3667. wheelDeltaPercentage: number;
  3668. zoomOnFactor: number;
  3669. targetScreenOffset: Vector2;
  3670. allowUpsideDown: boolean;
  3671. _viewMatrix: Matrix;
  3672. _useCtrlForPanning: boolean;
  3673. _panningMouseButton: number;
  3674. inputs: ArcRotateCameraInputsManager;
  3675. _reset: () => void;
  3676. panningAxis: Vector3;
  3677. protected _localDirection: Vector3;
  3678. protected _transformedDirection: Vector3;
  3679. private _bouncingBehavior;
  3680. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3681. useBouncingBehavior: boolean;
  3682. private _framingBehavior;
  3683. readonly framingBehavior: Nullable<FramingBehavior>;
  3684. useFramingBehavior: boolean;
  3685. private _autoRotationBehavior;
  3686. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3687. useAutoRotationBehavior: boolean;
  3688. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3689. onCollide: (collidedMesh: AbstractMesh) => void;
  3690. checkCollisions: boolean;
  3691. collisionRadius: Vector3;
  3692. protected _collider: Collider;
  3693. protected _previousPosition: Vector3;
  3694. protected _collisionVelocity: Vector3;
  3695. protected _newPosition: Vector3;
  3696. protected _previousAlpha: number;
  3697. protected _previousBeta: number;
  3698. protected _previousRadius: number;
  3699. protected _collisionTriggered: boolean;
  3700. protected _targetBoundingCenter: Nullable<Vector3>;
  3701. private _computationVector;
  3702. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3703. _initCache(): void;
  3704. _updateCache(ignoreParentClass?: boolean): void;
  3705. protected _getTargetPosition(): Vector3;
  3706. /**
  3707. * Store current camera state (fov, position, etc..)
  3708. */
  3709. private _storedAlpha;
  3710. private _storedBeta;
  3711. private _storedRadius;
  3712. private _storedTarget;
  3713. storeState(): Camera;
  3714. /**
  3715. * Restored camera state. You must call storeState() first
  3716. */
  3717. _restoreStateValues(): boolean;
  3718. _isSynchronizedViewMatrix(): boolean;
  3719. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3720. detachControl(element: HTMLElement): void;
  3721. _checkInputs(): void;
  3722. protected _checkLimits(): void;
  3723. rebuildAnglesAndRadius(): void;
  3724. setPosition(position: Vector3): void;
  3725. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3726. _getViewMatrix(): Matrix;
  3727. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3728. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3729. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3730. min: Vector3;
  3731. max: Vector3;
  3732. distance: number;
  3733. }, doNotUpdateMaxZ?: boolean): void;
  3734. /**
  3735. * @override
  3736. * Override Camera.createRigCamera
  3737. */
  3738. createRigCamera(name: string, cameraIndex: number): Camera;
  3739. /**
  3740. * @override
  3741. * Override Camera._updateRigCameras
  3742. */
  3743. _updateRigCameras(): void;
  3744. dispose(): void;
  3745. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  3746. getClassName(): string;
  3747. }
  3748. }
  3749. <<<<<<< HEAD
  3750. interface VRDisplay extends EventTarget {
  3751. /**
  3752. * Dictionary of capabilities describing the VRDisplay.
  3753. */
  3754. readonly capabilities: VRDisplayCapabilities;
  3755. /**
  3756. * z-depth defining the far plane of the eye view frustum
  3757. * enables mapping of values in the render target depth
  3758. * attachment to scene coordinates. Initially set to 10000.0.
  3759. */
  3760. depthFar: number;
  3761. /**
  3762. * z-depth defining the near plane of the eye view frustum
  3763. * enables mapping of values in the render target depth
  3764. * attachment to scene coordinates. Initially set to 0.01.
  3765. */
  3766. depthNear: number;
  3767. /**
  3768. * An identifier for this distinct VRDisplay. Used as an
  3769. * association point in the Gamepad API.
  3770. */
  3771. readonly displayId: number;
  3772. /**
  3773. * A display name, a user-readable name identifying it.
  3774. */
  3775. readonly displayName: string;
  3776. readonly isConnected: boolean;
  3777. readonly isPresenting: boolean;
  3778. /**
  3779. * If this VRDisplay supports room-scale experiences, the optional
  3780. * stage attribute contains details on the room-scale parameters.
  3781. */
  3782. readonly stageParameters: VRStageParameters | null;
  3783. /**
  3784. * Passing the value returned by `requestAnimationFrame` to
  3785. * `cancelAnimationFrame` will unregister the callback.
  3786. */
  3787. cancelAnimationFrame(handle: number): void;
  3788. /**
  3789. * Stops presenting to the VRDisplay.
  3790. */
  3791. exitPresent(): Promise<void>;
  3792. getEyeParameters(whichEye: string): VREyeParameters;
  3793. /**
  3794. * Populates the passed VRFrameData with the information required to render
  3795. * the current frame.
  3796. */
  3797. getFrameData(frameData: VRFrameData): boolean;
  3798. /**
  3799. * Get the layers currently being presented.
  3800. */
  3801. getLayers(): VRLayer[];
  3802. /**
  3803. * Return a VRPose containing the future predicted pose of the VRDisplay
  3804. * when the current frame will be presented. The value returned will not
  3805. * change until JavaScript has returned control to the browser.
  3806. *
  3807. * The VRPose will contain the position, orientation, velocity,
  3808. * and acceleration of each of these properties.
  3809. */
  3810. getPose(): VRPose;
  3811. /**
  3812. * Return the current instantaneous pose of the VRDisplay, with no
  3813. * prediction applied.
  3814. */
  3815. getImmediatePose(): VRPose;
  3816. /**
  3817. * The callback passed to `requestAnimationFrame` will be called
  3818. * any time a new frame should be rendered. When the VRDisplay is
  3819. * presenting the callback will be called at the native refresh
  3820. * rate of the HMD. When not presenting this function acts
  3821. * identically to how window.requestAnimationFrame acts. Content should
  3822. * make no assumptions of frame rate or vsync behavior as the HMD runs
  3823. * asynchronously from other displays and at differing refresh rates.
  3824. */
  3825. requestAnimationFrame(callback: FrameRequestCallback): number;
  3826. /**
  3827. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  3828. * Repeat calls while already presenting will update the VRLayers being displayed.
  3829. */
  3830. requestPresent(layers: VRLayer[]): Promise<void>;
  3831. /**
  3832. * Reset the pose for this display, treating its current position and
  3833. * orientation as the "origin/zero" values. VRPose.position,
  3834. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  3835. * updated when calling resetPose(). This should be called in only
  3836. * sitting-space experiences.
  3837. */
  3838. resetPose(): void;
  3839. /**
  3840. * The VRLayer provided to the VRDisplay will be captured and presented
  3841. * in the HMD. Calling this function has the same effect on the source
  3842. * canvas as any other operation that uses its source image, and canvases
  3843. * created without preserveDrawingBuffer set to true will be cleared.
  3844. */
  3845. submitFrame(pose?: VRPose): void;
  3846. }
  3847. declare var VRDisplay: {
  3848. prototype: VRDisplay;
  3849. new (): VRDisplay;
  3850. };
  3851. interface VRLayer {
  3852. leftBounds?: number[] | null;
  3853. rightBounds?: number[] | null;
  3854. source?: HTMLCanvasElement | null;
  3855. }
  3856. interface VRDisplayCapabilities {
  3857. readonly canPresent: boolean;
  3858. readonly hasExternalDisplay: boolean;
  3859. readonly hasOrientation: boolean;
  3860. readonly hasPosition: boolean;
  3861. readonly maxLayers: number;
  3862. }
  3863. interface VREyeParameters {
  3864. /** @deprecated */
  3865. readonly fieldOfView: VRFieldOfView;
  3866. readonly offset: Float32Array;
  3867. readonly renderHeight: number;
  3868. readonly renderWidth: number;
  3869. }
  3870. interface VRFieldOfView {
  3871. readonly downDegrees: number;
  3872. readonly leftDegrees: number;
  3873. readonly rightDegrees: number;
  3874. readonly upDegrees: number;
  3875. }
  3876. interface VRFrameData {
  3877. readonly leftProjectionMatrix: Float32Array;
  3878. readonly leftViewMatrix: Float32Array;
  3879. readonly pose: VRPose;
  3880. readonly rightProjectionMatrix: Float32Array;
  3881. readonly rightViewMatrix: Float32Array;
  3882. readonly timestamp: number;
  3883. }
  3884. interface VRPose {
  3885. readonly angularAcceleration: Float32Array | null;
  3886. readonly angularVelocity: Float32Array | null;
  3887. readonly linearAcceleration: Float32Array | null;
  3888. readonly linearVelocity: Float32Array | null;
  3889. readonly orientation: Float32Array | null;
  3890. readonly position: Float32Array | null;
  3891. readonly timestamp: number;
  3892. }
  3893. interface VRStageParameters {
  3894. sittingToStandingTransform?: Float32Array;
  3895. sizeX?: number;
  3896. sizeY?: number;
  3897. }
  3898. interface Navigator {
  3899. getVRDisplays(): Promise<VRDisplay[]>;
  3900. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  3901. }
  3902. interface Window {
  3903. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  3904. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  3905. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  3906. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  3907. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  3908. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  3909. }
  3910. interface Gamepad {
  3911. readonly displayId: number;
  3912. }
  3913. declare module BABYLON {
  3914. class Collider {
  3915. /** Define if a collision was found */
  3916. collisionFound: boolean;
  3917. =======
  3918. declare module BABYLON {
  3919. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3920. constructor(camera: ArcRotateCamera);
  3921. addMouseWheel(): ArcRotateCameraInputsManager;
  3922. addPointers(): ArcRotateCameraInputsManager;
  3923. addKeyboard(): ArcRotateCameraInputsManager;
  3924. addGamepad(): ArcRotateCameraInputsManager;
  3925. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3926. }
  3927. }
  3928. declare module BABYLON {
  3929. class Camera extends Node {
  3930. inputs: CameraInputsManager<Camera>;
  3931. private static _PERSPECTIVE_CAMERA;
  3932. private static _ORTHOGRAPHIC_CAMERA;
  3933. private static _FOVMODE_VERTICAL_FIXED;
  3934. private static _FOVMODE_HORIZONTAL_FIXED;
  3935. private static _RIG_MODE_NONE;
  3936. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3937. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3938. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3939. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3940. private static _RIG_MODE_VR;
  3941. private static _RIG_MODE_WEBVR;
  3942. static readonly PERSPECTIVE_CAMERA: number;
  3943. static readonly ORTHOGRAPHIC_CAMERA: number;
  3944. /**
  3945. * This is the default FOV mode for perspective cameras.
  3946. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3947. *
  3948. */
  3949. static readonly FOVMODE_VERTICAL_FIXED: number;
  3950. /**
  3951. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3952. *
  3953. */
  3954. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3955. static readonly RIG_MODE_NONE: number;
  3956. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3957. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3958. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3959. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3960. static readonly RIG_MODE_VR: number;
  3961. static readonly RIG_MODE_WEBVR: number;
  3962. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3963. static UseAlternateWebVRRendering: boolean;
  3964. position: Vector3;
  3965. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  3966. /**
  3967. * The vector the camera should consider as up.
  3968. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3969. */
  3970. upVector: Vector3;
  3971. orthoLeft: Nullable<number>;
  3972. orthoRight: Nullable<number>;
  3973. orthoBottom: Nullable<number>;
  3974. orthoTop: Nullable<number>;
  3975. /**
  3976. * FOV is set in Radians. (default is 0.8)
  3977. */
  3978. fov: number;
  3979. minZ: number;
  3980. maxZ: number;
  3981. inertia: number;
  3982. mode: number;
  3983. isIntermediate: boolean;
  3984. viewport: Viewport;
  3985. /**
  3986. * Restricts the camera to viewing objects with the same layerMask.
  3987. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3988. */
  3989. layerMask: number;
  3990. /**
  3991. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3992. */
  3993. fovMode: number;
  3994. cameraRigMode: number;
  3995. interaxialDistance: number;
  3996. isStereoscopicSideBySide: boolean;
  3997. _cameraRigParams: any;
  3998. _rigCameras: Camera[];
  3999. _rigPostProcess: Nullable<PostProcess>;
  4000. protected _webvrViewMatrix: Matrix;
  4001. _skipRendering: boolean;
  4002. _alternateCamera: Camera;
  4003. customRenderTargets: RenderTargetTexture[];
  4004. onViewMatrixChangedObservable: Observable<Camera>;
  4005. onProjectionMatrixChangedObservable: Observable<Camera>;
  4006. onAfterCheckInputsObservable: Observable<Camera>;
  4007. onRestoreStateObservable: Observable<Camera>;
  4008. private _computedViewMatrix;
  4009. _projectionMatrix: Matrix;
  4010. private _doNotComputeProjectionMatrix;
  4011. private _worldMatrix;
  4012. _postProcesses: Nullable<PostProcess>[];
  4013. private _transformMatrix;
  4014. _activeMeshes: SmartArray<AbstractMesh>;
  4015. private _globalPosition;
  4016. private _frustumPlanes;
  4017. private _refreshFrustumPlanes;
  4018. constructor(name: string, position: Vector3, scene: Scene);
  4019. private _storedFov;
  4020. private _stateStored;
  4021. /**
  4022. * Store current camera state (fov, position, etc..)
  4023. */
  4024. storeState(): Camera;
  4025. /**
  4026. * Restores the camera state values if it has been stored. You must call storeState() first
  4027. */
  4028. protected _restoreStateValues(): boolean;
  4029. /**
  4030. * Restored camera state. You must call storeState() first
  4031. */
  4032. restoreState(): boolean;
  4033. getClassName(): string;
  4034. /**
  4035. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4036. */
  4037. toString(fullDetails?: boolean): string;
  4038. readonly globalPosition: Vector3;
  4039. getActiveMeshes(): SmartArray<AbstractMesh>;
  4040. isActiveMesh(mesh: Mesh): boolean;
  4041. /**
  4042. * Is this camera ready to be used/rendered
  4043. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  4044. * @return true if the camera is ready
  4045. */
  4046. isReady(completeCheck?: boolean): boolean;
  4047. _initCache(): void;
  4048. _updateCache(ignoreParentClass?: boolean): void;
  4049. _isSynchronized(): boolean;
  4050. _isSynchronizedViewMatrix(): boolean;
  4051. _isSynchronizedProjectionMatrix(): boolean;
  4052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  4053. detachControl(element: HTMLElement): void;
  4054. update(): void;
  4055. _checkInputs(): void;
  4056. readonly rigCameras: Camera[];
  4057. readonly rigPostProcess: Nullable<PostProcess>;
  4058. /**
  4059. * Internal, gets the first post proces.
  4060. * @returns the first post process to be run on this camera.
  4061. */
  4062. _getFirstPostProcess(): Nullable<PostProcess>;
  4063. private _cascadePostProcessesToRigCams();
  4064. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  4065. detachPostProcess(postProcess: PostProcess): void;
  4066. getWorldMatrix(): Matrix;
  4067. _getViewMatrix(): Matrix;
  4068. getViewMatrix(force?: boolean): Matrix;
  4069. freezeProjectionMatrix(projection?: Matrix): void;
  4070. unfreezeProjectionMatrix(): void;
  4071. getProjectionMatrix(force?: boolean): Matrix;
  4072. getTranformationMatrix(): Matrix;
  4073. private updateFrustumPlanes();
  4074. isInFrustum(target: ICullable): boolean;
  4075. isCompletelyInFrustum(target: ICullable): boolean;
  4076. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  4077. /**
  4078. * Releases resources associated with this node.
  4079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  4080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  4081. */
  4082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  4083. readonly leftCamera: Nullable<FreeCamera>;
  4084. readonly rightCamera: Nullable<FreeCamera>;
  4085. getLeftTarget(): Nullable<Vector3>;
  4086. getRightTarget(): Nullable<Vector3>;
  4087. setCameraRigMode(mode: number, rigParams: any): void;
  4088. private _getVRProjectionMatrix();
  4089. protected _updateCameraRotationMatrix(): void;
  4090. protected _updateWebVRCameraRotationMatrix(): void;
  4091. /**
  4092. * This function MUST be overwritten by the different WebVR cameras available.
  4093. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4094. */
  4095. protected _getWebVRProjectionMatrix(): Matrix;
  4096. /**
  4097. * This function MUST be overwritten by the different WebVR cameras available.
  4098. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4099. */
  4100. protected _getWebVRViewMatrix(): Matrix;
  4101. setCameraRigParameter(name: string, value: any): void;
  4102. /**
  4103. * needs to be overridden by children so sub has required properties to be copied
  4104. */
  4105. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  4106. /**
  4107. * May need to be overridden by children
  4108. */
  4109. _updateRigCameras(): void;
  4110. _setupInputs(): void;
  4111. serialize(): any;
  4112. clone(name: string): Camera;
  4113. getDirection(localAxis: Vector3): Vector3;
  4114. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  4115. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  4116. computeWorldMatrix(): Matrix;
  4117. static Parse(parsedCamera: any, scene: Scene): Camera;
  4118. }
  4119. }
  4120. declare module BABYLON {
  4121. var CameraInputTypes: {};
  4122. interface ICameraInput<TCamera extends Camera> {
  4123. camera: Nullable<TCamera>;
  4124. getClassName(): string;
  4125. getSimpleName(): string;
  4126. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  4127. detachControl: (element: Nullable<HTMLElement>) => void;
  4128. checkInputs?: () => void;
  4129. }
  4130. interface CameraInputsMap<TCamera extends Camera> {
  4131. [name: string]: ICameraInput<TCamera>;
  4132. [idx: number]: ICameraInput<TCamera>;
  4133. }
  4134. class CameraInputsManager<TCamera extends Camera> {
  4135. attached: CameraInputsMap<TCamera>;
  4136. attachedElement: Nullable<HTMLElement>;
  4137. noPreventDefault: boolean;
  4138. camera: TCamera;
  4139. checkInputs: () => void;
  4140. constructor(camera: TCamera);
  4141. /**
  4142. * Add an input method to a camera.
  4143. * builtin inputs example: camera.inputs.addGamepad();
  4144. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  4145. * @param input camera input method
  4146. */
  4147. add(input: ICameraInput<TCamera>): void;
  4148. /**
  4149. * Remove a specific input method from a camera
  4150. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  4151. * @param inputToRemove camera input method
  4152. */
  4153. remove(inputToRemove: ICameraInput<TCamera>): void;
  4154. removeByType(inputType: string): void;
  4155. private _addCheckInputs(fn);
  4156. attachInput(input: ICameraInput<TCamera>): void;
  4157. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  4158. detachElement(element: HTMLElement, disconnect?: boolean): void;
  4159. rebuildInputCheck(): void;
  4160. /**
  4161. * Remove all attached input methods from a camera
  4162. */
  4163. clear(): void;
  4164. serialize(serializedCamera: any): void;
  4165. parse(parsedCamera: any): void;
  4166. }
  4167. }
  4168. declare module BABYLON {
  4169. /**
  4170. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  4171. * being tilted forward or back and left or right.
  4172. */
  4173. class DeviceOrientationCamera extends FreeCamera {
  4174. private _initialQuaternion;
  4175. private _quaternionCache;
  4176. /**
  4177. * Creates a new device orientation camera. @see DeviceOrientationCamera
  4178. * @param name The name of the camera
  4179. * @param position The start position camera
  4180. * @param scene The scene the camera belongs to
  4181. */
  4182. constructor(name: string, position: Vector3, scene: Scene);
  4183. /**
  4184. * Gets the current instance class name ("DeviceOrientationCamera").
  4185. * This helps avoiding instanceof at run time.
  4186. * @returns the class name
  4187. */
  4188. getClassName(): string;
  4189. /**
  4190. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  4191. */
  4192. _checkInputs(): void;
  4193. /**
  4194. * Reset the camera to its default orientation on the specified axis only.
  4195. * @param axis The axis to reset
  4196. */
  4197. resetToCurrentRotation(axis?: Axis): void;
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. <<<<<<< HEAD
  4202. class Bone extends Node {
  4203. name: string;
  4204. private static _tmpVecs;
  4205. private static _tmpQuat;
  4206. private static _tmpMats;
  4207. children: Bone[];
  4208. animations: Animation[];
  4209. length: number;
  4210. _index: Nullable<number>;
  4211. private _skeleton;
  4212. private _localMatrix;
  4213. private _restPose;
  4214. private _baseMatrix;
  4215. private _worldTransform;
  4216. private _absoluteTransform;
  4217. private _invertedAbsoluteTransform;
  4218. private _parent;
  4219. private _scaleMatrix;
  4220. private _scaleVector;
  4221. private _negateScaleChildren;
  4222. private _scalingDeterminant;
  4223. _matrix: Matrix;
  4224. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4225. getSkeleton(): Skeleton;
  4226. getParent(): Nullable<Bone>;
  4227. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4228. getLocalMatrix(): Matrix;
  4229. getBaseMatrix(): Matrix;
  4230. getRestPose(): Matrix;
  4231. returnToRest(): void;
  4232. getWorldMatrix(): Matrix;
  4233. getInvertedAbsoluteTransform(): Matrix;
  4234. getAbsoluteTransform(): Matrix;
  4235. position: Vector3;
  4236. rotation: Vector3;
  4237. rotationQuaternion: Quaternion;
  4238. scaling: Vector3;
  4239. =======
  4240. class FollowCamera extends TargetCamera {
  4241. radius: number;
  4242. rotationOffset: number;
  4243. heightOffset: number;
  4244. cameraAcceleration: number;
  4245. maxCameraSpeed: number;
  4246. lockedTarget: Nullable<AbstractMesh>;
  4247. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  4248. private getRadians(degrees);
  4249. private follow(cameraTarget);
  4250. _checkInputs(): void;
  4251. getClassName(): string;
  4252. }
  4253. class ArcFollowCamera extends TargetCamera {
  4254. alpha: number;
  4255. beta: number;
  4256. radius: number;
  4257. target: Nullable<AbstractMesh>;
  4258. private _cartesianCoordinates;
  4259. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  4260. private follow();
  4261. _checkInputs(): void;
  4262. getClassName(): string;
  4263. }
  4264. }
  4265. declare module BABYLON {
  4266. class FreeCamera extends TargetCamera {
  4267. ellipsoid: Vector3;
  4268. ellipsoidOffset: Vector3;
  4269. checkCollisions: boolean;
  4270. applyGravity: boolean;
  4271. inputs: FreeCameraInputsManager;
  4272. /**
  4273. * Gets the input sensibility for a mouse input. (default is 2000.0)
  4274. * Higher values reduce sensitivity.
  4275. */
  4276. /**
  4277. * Sets the input sensibility for a mouse input. (default is 2000.0)
  4278. * Higher values reduce sensitivity.
  4279. */
  4280. angularSensibility: number;
  4281. keysUp: number[];
  4282. keysDown: number[];
  4283. keysLeft: number[];
  4284. keysRight: number[];
  4285. onCollide: (collidedMesh: AbstractMesh) => void;
  4286. private _collider;
  4287. private _needMoveForGravity;
  4288. private _oldPosition;
  4289. private _diffPosition;
  4290. private _newPosition;
  4291. _localDirection: Vector3;
  4292. _transformedDirection: Vector3;
  4293. constructor(name: string, position: Vector3, scene: Scene);
  4294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  4295. detachControl(element: HTMLElement): void;
  4296. private _collisionMask;
  4297. collisionMask: number;
  4298. _collideWithWorld(displacement: Vector3): void;
  4299. private _onCollisionPositionChange;
  4300. _checkInputs(): void;
  4301. _decideIfNeedsToMove(): boolean;
  4302. _updatePosition(): void;
  4303. dispose(): void;
  4304. getClassName(): string;
  4305. }
  4306. }
  4307. declare module BABYLON {
  4308. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  4309. constructor(camera: FreeCamera);
  4310. addKeyboard(): FreeCameraInputsManager;
  4311. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  4312. addGamepad(): FreeCameraInputsManager;
  4313. addDeviceOrientation(): FreeCameraInputsManager;
  4314. addTouch(): FreeCameraInputsManager;
  4315. addVirtualJoystick(): FreeCameraInputsManager;
  4316. }
  4317. }
  4318. declare module BABYLON {
  4319. class GamepadCamera extends UniversalCamera {
  4320. gamepadAngularSensibility: number;
  4321. gamepadMoveSensibility: number;
  4322. constructor(name: string, position: Vector3, scene: Scene);
  4323. getClassName(): string;
  4324. }
  4325. }
  4326. declare module BABYLON {
  4327. class AnaglyphFreeCamera extends FreeCamera {
  4328. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  4329. getClassName(): string;
  4330. }
  4331. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  4332. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  4333. getClassName(): string;
  4334. }
  4335. class AnaglyphGamepadCamera extends GamepadCamera {
  4336. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  4337. getClassName(): string;
  4338. }
  4339. class AnaglyphUniversalCamera extends UniversalCamera {
  4340. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  4341. getClassName(): string;
  4342. }
  4343. class StereoscopicFreeCamera extends FreeCamera {
  4344. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4345. getClassName(): string;
  4346. }
  4347. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  4348. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4349. getClassName(): string;
  4350. }
  4351. class StereoscopicGamepadCamera extends GamepadCamera {
  4352. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4353. getClassName(): string;
  4354. }
  4355. class StereoscopicUniversalCamera extends UniversalCamera {
  4356. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4357. getClassName(): string;
  4358. }
  4359. }
  4360. declare module BABYLON {
  4361. class TargetCamera extends Camera {
  4362. cameraDirection: Vector3;
  4363. cameraRotation: Vector2;
  4364. rotation: Vector3;
  4365. rotationQuaternion: Quaternion;
  4366. speed: number;
  4367. noRotationConstraint: boolean;
  4368. lockedTarget: any;
  4369. _currentTarget: Vector3;
  4370. _viewMatrix: Matrix;
  4371. _camMatrix: Matrix;
  4372. _cameraTransformMatrix: Matrix;
  4373. _cameraRotationMatrix: Matrix;
  4374. private _rigCamTransformMatrix;
  4375. _referencePoint: Vector3;
  4376. private _currentUpVector;
  4377. _transformedReferencePoint: Vector3;
  4378. _lookAtTemp: Matrix;
  4379. _tempMatrix: Matrix;
  4380. _reset: () => void;
  4381. constructor(name: string, position: Vector3, scene: Scene);
  4382. getFrontPosition(distance: number): Vector3;
  4383. _getLockedTargetPosition(): Nullable<Vector3>;
  4384. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4385. /**
  4386. * Gets the animation properties override
  4387. */
  4388. <<<<<<< HEAD
  4389. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  4390. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  4391. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  4392. markAsDirty(): void;
  4393. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4394. =======
  4395. private _storedPosition;
  4396. private _storedRotation;
  4397. private _storedRotationQuaternion;
  4398. storeState(): Camera;
  4399. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4400. /**
  4401. * Translate the bone in local or world space.
  4402. * @param vec The amount to translate the bone.
  4403. * @param space The space that the translation is in.
  4404. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4405. */
  4406. <<<<<<< HEAD
  4407. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4408. =======
  4409. _restoreStateValues(): boolean;
  4410. _initCache(): void;
  4411. _updateCache(ignoreParentClass?: boolean): void;
  4412. _isSynchronizedViewMatrix(): boolean;
  4413. _computeLocalCameraSpeed(): number;
  4414. setTarget(target: Vector3): void;
  4415. /**
  4416. * Return the current target position of the camera. This value is expressed in local space.
  4417. */
  4418. getTarget(): Vector3;
  4419. _decideIfNeedsToMove(): boolean;
  4420. _updatePosition(): void;
  4421. _checkInputs(): void;
  4422. protected _updateCameraRotationMatrix(): void;
  4423. _getViewMatrix(): Matrix;
  4424. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4425. /**
  4426. * Set the postion of the bone in local or world space.
  4427. * @param position The position to set the bone.
  4428. * @param space The space that the position is in.
  4429. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4430. */
  4431. <<<<<<< HEAD
  4432. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4433. =======
  4434. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  4435. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4436. /**
  4437. * Set the absolute postion of the bone (world space).
  4438. * @param position The position to set the bone.
  4439. * @param mesh The mesh that this bone is attached to.
  4440. */
  4441. <<<<<<< HEAD
  4442. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4443. /**
  4444. * Set the scale of the bone on the x, y and z axes.
  4445. * @param x The scale of the bone on the x axis.
  4446. * @param x The scale of the bone on the y axis.
  4447. * @param z The scale of the bone on the z axis.
  4448. * @param scaleChildren Set this to true if children of the bone should be scaled.
  4449. */
  4450. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4451. /**
  4452. * Scale the bone on the x, y and z axes.
  4453. * @param x The amount to scale the bone on the x axis.
  4454. * @param x The amount to scale the bone on the y axis.
  4455. * @param z The amount to scale the bone on the z axis.
  4456. * @param scaleChildren Set this to true if children of the bone should be scaled.
  4457. */
  4458. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4459. /**
  4460. * Set the yaw, pitch, and roll of the bone in local or world space.
  4461. * @param yaw The rotation of the bone on the y axis.
  4462. * @param pitch The rotation of the bone on the x axis.
  4463. * @param roll The rotation of the bone on the z axis.
  4464. * @param space The space that the axes of rotation are in.
  4465. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4466. */
  4467. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4468. /**
  4469. * Rotate the bone on an axis in local or world space.
  4470. * @param axis The axis to rotate the bone on.
  4471. * @param amount The amount to rotate the bone.
  4472. * @param space The space that the axis is in.
  4473. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4474. */
  4475. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4476. /**
  4477. * Set the rotation of the bone to a particular axis angle in local or world space.
  4478. * @param axis The axis to rotate the bone on.
  4479. * @param angle The angle that the bone should be rotated to.
  4480. * @param space The space that the axis is in.
  4481. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4482. */
  4483. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4484. /**
  4485. * Set the euler rotation of the bone in local of world space.
  4486. * @param rotation The euler rotation that the bone should be set to.
  4487. * @param space The space that the rotation is in.
  4488. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4489. */
  4490. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4491. /**
  4492. * Set the quaternion rotation of the bone in local of world space.
  4493. * @param quat The quaternion rotation that the bone should be set to.
  4494. * @param space The space that the rotation is in.
  4495. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4496. */
  4497. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4498. /**
  4499. * Set the rotation matrix of the bone in local of world space.
  4500. * @param rotMat The rotation matrix that the bone should be set to.
  4501. * @param space The space that the rotation is in.
  4502. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4503. */
  4504. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4505. private _rotateWithMatrix(rmat, space?, mesh?);
  4506. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  4507. /**
  4508. * Get the scale of the bone
  4509. * @returns the scale of the bone
  4510. */
  4511. getScale(): Vector3;
  4512. /**
  4513. * Copy the scale of the bone to a vector3.
  4514. * @param result The vector3 to copy the scale to
  4515. */
  4516. getScaleToRef(result: Vector3): void;
  4517. /**
  4518. * Get the position of the bone in local or world space.
  4519. * @param space The space that the returned position is in.
  4520. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4521. * @returns The position of the bone
  4522. */
  4523. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4524. /**
  4525. * Copy the position of the bone to a vector3 in local or world space.
  4526. * @param space The space that the returned position is in.
  4527. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4528. * @param result The vector3 to copy the position to.
  4529. */
  4530. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4531. /**
  4532. * Get the absolute position of the bone (world space).
  4533. * @param mesh The mesh that this bone is attached to.
  4534. * @returns The absolute position of the bone
  4535. */
  4536. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4537. /**
  4538. * Copy the absolute position of the bone (world space) to the result param.
  4539. * @param mesh The mesh that this bone is attached to.
  4540. * @param result The vector3 to copy the absolute position to.
  4541. */
  4542. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4543. /**
  4544. * Compute the absolute transforms of this bone and its children.
  4545. */
  4546. computeAbsoluteTransforms(): void;
  4547. private _syncScaleVector();
  4548. /**
  4549. * Get the world direction from an axis that is in the local space of the bone.
  4550. * @param localAxis The local direction that is used to compute the world direction.
  4551. * @param mesh The mesh that this bone is attached to.
  4552. * @returns The world direction
  4553. */
  4554. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4555. /**
  4556. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  4557. * @param localAxis The local direction that is used to compute the world direction.
  4558. * @param mesh The mesh that this bone is attached to.
  4559. * @param result The vector3 that the world direction will be copied to.
  4560. */
  4561. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4562. /**
  4563. * Get the euler rotation of the bone in local or world space.
  4564. * @param space The space that the rotation should be in.
  4565. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4566. * @returns The euler rotation
  4567. */
  4568. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4569. /**
  4570. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  4571. * @param space The space that the rotation should be in.
  4572. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4573. * @param result The vector3 that the rotation should be copied to.
  4574. */
  4575. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4576. /**
  4577. * Get the quaternion rotation of the bone in either local or world space.
  4578. * @param space The space that the rotation should be in.
  4579. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4580. * @returns The quaternion rotation
  4581. */
  4582. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4583. /**
  4584. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  4585. * @param space The space that the rotation should be in.
  4586. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4587. * @param result The quaternion that the rotation should be copied to.
  4588. */
  4589. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4590. /**
  4591. * Get the rotation matrix of the bone in local or world space.
  4592. * @param space The space that the rotation should be in.
  4593. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4594. * @returns The rotation matrix
  4595. */
  4596. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4597. /**
  4598. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  4599. * @param space The space that the rotation should be in.
  4600. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4601. * @param result The quaternion that the rotation should be copied to.
  4602. */
  4603. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4604. /**
  4605. * Get the world position of a point that is in the local space of the bone.
  4606. * @param position The local position
  4607. * @param mesh The mesh that this bone is attached to.
  4608. * @returns The world position
  4609. */
  4610. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4611. /**
  4612. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  4613. * @param position The local position
  4614. * @param mesh The mesh that this bone is attached to.
  4615. * @param result The vector3 that the world position should be copied to.
  4616. */
  4617. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4618. /**
  4619. * Get the local position of a point that is in world space.
  4620. * @param position The world position
  4621. * @param mesh The mesh that this bone is attached to.
  4622. * @returns The local position
  4623. */
  4624. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4625. /**
  4626. * Get the local position of a point that is in world space and copy it to the result param.
  4627. * @param position The world position
  4628. * @param mesh The mesh that this bone is attached to.
  4629. * @param result The vector3 that the local position should be copied to.
  4630. */
  4631. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4632. =======
  4633. _updateRigCameras(): void;
  4634. private _getRigCamPosition(halfSpace, result);
  4635. getClassName(): string;
  4636. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4637. }
  4638. }
  4639. declare module BABYLON {
  4640. <<<<<<< HEAD
  4641. class BoneIKController {
  4642. private static _tmpVecs;
  4643. private static _tmpQuat;
  4644. private static _tmpMats;
  4645. targetMesh: AbstractMesh;
  4646. poleTargetMesh: AbstractMesh;
  4647. poleTargetBone: Nullable<Bone>;
  4648. targetPosition: Vector3;
  4649. poleTargetPosition: Vector3;
  4650. poleTargetLocalOffset: Vector3;
  4651. poleAngle: number;
  4652. mesh: AbstractMesh;
  4653. slerpAmount: number;
  4654. private _bone1Quat;
  4655. private _bone1Mat;
  4656. private _bone2Ang;
  4657. private _bone1;
  4658. private _bone2;
  4659. private _bone1Length;
  4660. private _bone2Length;
  4661. private _maxAngle;
  4662. private _maxReach;
  4663. private _rightHandedSystem;
  4664. private _bendAxis;
  4665. private _slerping;
  4666. private _adjustRoll;
  4667. maxAngle: number;
  4668. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  4669. targetMesh?: AbstractMesh;
  4670. poleTargetMesh?: AbstractMesh;
  4671. poleTargetBone?: Bone;
  4672. poleTargetLocalOffset?: Vector3;
  4673. poleAngle?: number;
  4674. bendAxis?: Vector3;
  4675. maxAngle?: number;
  4676. slerpAmount?: number;
  4677. });
  4678. private _setMaxAngle(ang);
  4679. update(): void;
  4680. =======
  4681. class TouchCamera extends FreeCamera {
  4682. touchAngularSensibility: number;
  4683. touchMoveSensibility: number;
  4684. constructor(name: string, position: Vector3, scene: Scene);
  4685. getClassName(): string;
  4686. _setupInputs(): void;
  4687. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4688. }
  4689. }
  4690. declare module BABYLON {
  4691. <<<<<<< HEAD
  4692. class BoneLookController {
  4693. private static _tmpVecs;
  4694. private static _tmpQuat;
  4695. private static _tmpMats;
  4696. /**
  4697. * The target Vector3 that the bone will look at.
  4698. */
  4699. target: Vector3;
  4700. /**
  4701. * The mesh that the bone is attached to.
  4702. */
  4703. mesh: AbstractMesh;
  4704. /**
  4705. * The bone that will be looking to the target.
  4706. */
  4707. bone: Bone;
  4708. /**
  4709. * The up axis of the coordinate system that is used when the bone is rotated.
  4710. */
  4711. upAxis: Vector3;
  4712. /**
  4713. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4714. */
  4715. upAxisSpace: Space;
  4716. /**
  4717. * Used to make an adjustment to the yaw of the bone.
  4718. */
  4719. adjustYaw: number;
  4720. /**
  4721. * Used to make an adjustment to the pitch of the bone.
  4722. */
  4723. adjustPitch: number;
  4724. /**
  4725. * Used to make an adjustment to the roll of the bone.
  4726. */
  4727. adjustRoll: number;
  4728. /**
  4729. * 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).
  4730. */
  4731. slerpAmount: number;
  4732. private _minYaw;
  4733. private _maxYaw;
  4734. private _minPitch;
  4735. private _maxPitch;
  4736. private _minYawSin;
  4737. private _minYawCos;
  4738. private _maxYawSin;
  4739. private _maxYawCos;
  4740. private _midYawConstraint;
  4741. private _minPitchTan;
  4742. private _maxPitchTan;
  4743. private _boneQuat;
  4744. private _slerping;
  4745. private _transformYawPitch;
  4746. private _transformYawPitchInv;
  4747. private _firstFrameSkipped;
  4748. private _yawRange;
  4749. private _fowardAxis;
  4750. /**
  4751. * Get/set the minimum yaw angle that the bone can look to.
  4752. */
  4753. minYaw: number;
  4754. /**
  4755. * Get/set the maximum yaw angle that the bone can look to.
  4756. */
  4757. maxYaw: number;
  4758. /**
  4759. * Get/set the minimum pitch angle that the bone can look to.
  4760. */
  4761. minPitch: number;
  4762. /**
  4763. * Get/set the maximum pitch angle that the bone can look to.
  4764. */
  4765. maxPitch: number;
  4766. /**
  4767. * Create a BoneLookController
  4768. * @param mesh the mesh that the bone belongs to
  4769. * @param bone the bone that will be looking to the target
  4770. * @param target the target Vector3 to look at
  4771. * @param settings optional settings:
  4772. * - maxYaw: the maximum angle the bone will yaw to
  4773. * - minYaw: the minimum angle the bone will yaw to
  4774. * - maxPitch: the maximum angle the bone will pitch to
  4775. * - minPitch: the minimum angle the bone will yaw to
  4776. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  4777. * - upAxis: the up axis of the coordinate system
  4778. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4779. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  4780. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  4781. * - adjustYaw: used to make an adjustment to the yaw of the bone
  4782. * - adjustPitch: used to make an adjustment to the pitch of the bone
  4783. * - adjustRoll: used to make an adjustment to the roll of the bone
  4784. **/
  4785. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  4786. maxYaw?: number;
  4787. minYaw?: number;
  4788. maxPitch?: number;
  4789. minPitch?: number;
  4790. slerpAmount?: number;
  4791. upAxis?: Vector3;
  4792. upAxisSpace?: Space;
  4793. yawAxis?: Vector3;
  4794. pitchAxis?: Vector3;
  4795. adjustYaw?: number;
  4796. adjustPitch?: number;
  4797. adjustRoll?: number;
  4798. });
  4799. /**
  4800. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  4801. */
  4802. update(): void;
  4803. private _getAngleDiff(ang1, ang2);
  4804. private _getAngleBetween(ang1, ang2);
  4805. private _isAngleBetween(ang, ang1, ang2);
  4806. =======
  4807. class UniversalCamera extends TouchCamera {
  4808. gamepadAngularSensibility: number;
  4809. gamepadMoveSensibility: number;
  4810. constructor(name: string, position: Vector3, scene: Scene);
  4811. getClassName(): string;
  4812. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  4813. }
  4814. }
  4815. declare module BABYLON {
  4816. <<<<<<< HEAD
  4817. class Skeleton implements IAnimatable {
  4818. name: string;
  4819. id: string;
  4820. bones: Bone[];
  4821. dimensionsAtRest: Vector3;
  4822. needInitialSkinMatrix: boolean;
  4823. animations: Array<Animation>;
  4824. private _scene;
  4825. private _isDirty;
  4826. private _transformMatrices;
  4827. private _meshesWithPoseMatrix;
  4828. private _animatables;
  4829. private _identity;
  4830. private _synchronizedWithMesh;
  4831. private _ranges;
  4832. private _lastAbsoluteTransformsUpdateId;
  4833. /**
  4834. * Specifies if the skeleton should be serialized.
  4835. */
  4836. doNotSerialize: boolean;
  4837. /**
  4838. * Gets or sets the animation properties override
  4839. */
  4840. animationPropertiesOverride: AnimationPropertiesOverride;
  4841. /**
  4842. * An event triggered before computing the skeleton's matrices
  4843. * @type {BABYLON.Observable}
  4844. */
  4845. onBeforeComputeObservable: Observable<Skeleton>;
  4846. constructor(name: string, id: string, scene: Scene);
  4847. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  4848. getScene(): Scene;
  4849. /**
  4850. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4851. */
  4852. toString(fullDetails?: boolean): string;
  4853. /**
  4854. * Get bone's index searching by name
  4855. * @param {string} name is bone's name to search for
  4856. * @return {number} Indice of the bone. Returns -1 if not found
  4857. */
  4858. getBoneIndexByName(name: string): number;
  4859. createAnimationRange(name: string, from: number, to: number): void;
  4860. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  4861. getAnimationRange(name: string): Nullable<AnimationRange>;
  4862. /**
  4863. * Returns as an Array, all AnimationRanges defined on this skeleton
  4864. */
  4865. getAnimationRanges(): Nullable<AnimationRange>[];
  4866. /**
  4867. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  4868. */
  4869. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  4870. returnToRest(): void;
  4871. private _getHighestAnimationFrame();
  4872. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  4873. _markAsDirty(): void;
  4874. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4875. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4876. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  4877. prepare(): void;
  4878. getAnimatables(): IAnimatable[];
  4879. clone(name: string, id: string): Skeleton;
  4880. enableBlending(blendingSpeed?: number): void;
  4881. dispose(): void;
  4882. serialize(): any;
  4883. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  4884. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  4885. getPoseMatrix(): Nullable<Matrix>;
  4886. sortBones(): void;
  4887. private _sortBones(index, bones, visited);
  4888. }
  4889. }
  4890. declare module BABYLON {
  4891. class BoundingBox implements ICullable {
  4892. minimum: Vector3;
  4893. maximum: Vector3;
  4894. vectors: Vector3[];
  4895. center: Vector3;
  4896. centerWorld: Vector3;
  4897. extendSize: Vector3;
  4898. extendSizeWorld: Vector3;
  4899. directions: Vector3[];
  4900. vectorsWorld: Vector3[];
  4901. minimumWorld: Vector3;
  4902. maximumWorld: Vector3;
  4903. private _worldMatrix;
  4904. constructor(minimum: Vector3, maximum: Vector3);
  4905. getWorldMatrix(): Matrix;
  4906. setWorldMatrix(matrix: Matrix): BoundingBox;
  4907. _update(world: Matrix): void;
  4908. isInFrustum(frustumPlanes: Plane[]): boolean;
  4909. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4910. intersectsPoint(point: Vector3): boolean;
  4911. intersectsSphere(sphere: BoundingSphere): boolean;
  4912. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  4913. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  4914. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  4915. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4916. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4917. }
  4918. }
  4919. declare module BABYLON {
  4920. interface ICullable {
  4921. isInFrustum(frustumPlanes: Plane[]): boolean;
  4922. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4923. }
  4924. class BoundingInfo implements ICullable {
  4925. minimum: Vector3;
  4926. maximum: Vector3;
  4927. boundingBox: BoundingBox;
  4928. boundingSphere: BoundingSphere;
  4929. private _isLocked;
  4930. constructor(minimum: Vector3, maximum: Vector3);
  4931. isLocked: boolean;
  4932. update(world: Matrix): void;
  4933. /**
  4934. * Recreate the bounding info to be centered around a specific point given a specific extend.
  4935. * @param center New center of the bounding info
  4936. * @param extend New extend of the bounding info
  4937. */
  4938. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  4939. isInFrustum(frustumPlanes: Plane[]): boolean;
  4940. /**
  4941. * Gets the world distance between the min and max points of the bounding box
  4942. */
  4943. readonly diagonalLength: number;
  4944. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4945. _checkCollision(collider: Collider): boolean;
  4946. intersectsPoint(point: Vector3): boolean;
  4947. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  4948. }
  4949. }
  4950. declare module BABYLON {
  4951. class BoundingSphere {
  4952. minimum: Vector3;
  4953. maximum: Vector3;
  4954. center: Vector3;
  4955. radius: number;
  4956. centerWorld: Vector3;
  4957. radiusWorld: number;
  4958. private _tempRadiusVector;
  4959. constructor(minimum: Vector3, maximum: Vector3);
  4960. _update(world: Matrix): void;
  4961. isInFrustum(frustumPlanes: Plane[]): boolean;
  4962. intersectsPoint(point: Vector3): boolean;
  4963. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  4964. }
  4965. }
  4966. declare module BABYLON {
  4967. class Ray {
  4968. origin: Vector3;
  4969. direction: Vector3;
  4970. length: number;
  4971. private _edge1;
  4972. private _edge2;
  4973. private _pvec;
  4974. private _tvec;
  4975. private _qvec;
  4976. private _tmpRay;
  4977. constructor(origin: Vector3, direction: Vector3, length?: number);
  4978. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  4979. intersectsBox(box: BoundingBox): boolean;
  4980. intersectsSphere(sphere: BoundingSphere): boolean;
  4981. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  4982. intersectsPlane(plane: Plane): Nullable<number>;
  4983. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  4984. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  4985. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  4986. private static smallnum;
  4987. private static rayl;
  4988. /**
  4989. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  4990. * @param sega the first point of the segment to test the intersection against
  4991. * @param segb the second point of the segment to test the intersection against
  4992. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  4993. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  4994. */
  4995. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  4996. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4997. static Zero(): Ray;
  4998. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4999. /**
  5000. * 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
  5001. * transformed to the given world matrix.
  5002. * @param origin The origin point
  5003. * @param end The end point
  5004. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5005. */
  5006. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5007. static Transform(ray: Ray, matrix: Matrix): Ray;
  5008. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. interface Behavior<T extends Node> {
  5013. name: string;
  5014. init(): void;
  5015. attach(node: T): void;
  5016. detach(): void;
  5017. }
  5018. }
  5019. declare module BABYLON {
  5020. class KeyboardEventTypes {
  5021. static _KEYDOWN: number;
  5022. static _KEYUP: number;
  5023. static readonly KEYDOWN: number;
  5024. static readonly KEYUP: number;
  5025. }
  5026. class KeyboardInfo {
  5027. type: number;
  5028. event: KeyboardEvent;
  5029. constructor(type: number, event: KeyboardEvent);
  5030. }
  5031. =======
  5032. class VirtualJoysticksCamera extends FreeCamera {
  5033. constructor(name: string, position: Vector3, scene: Scene);
  5034. getClassName(): string;
  5035. }
  5036. }
  5037. interface VRDisplay extends EventTarget {
  5038. /**
  5039. * Dictionary of capabilities describing the VRDisplay.
  5040. */
  5041. readonly capabilities: VRDisplayCapabilities;
  5042. /**
  5043. * z-depth defining the far plane of the eye view frustum
  5044. * enables mapping of values in the render target depth
  5045. * attachment to scene coordinates. Initially set to 10000.0.
  5046. */
  5047. depthFar: number;
  5048. /**
  5049. * z-depth defining the near plane of the eye view frustum
  5050. * enables mapping of values in the render target depth
  5051. * attachment to scene coordinates. Initially set to 0.01.
  5052. */
  5053. depthNear: number;
  5054. /**
  5055. * An identifier for this distinct VRDisplay. Used as an
  5056. * association point in the Gamepad API.
  5057. */
  5058. readonly displayId: number;
  5059. /**
  5060. * A display name, a user-readable name identifying it.
  5061. */
  5062. readonly displayName: string;
  5063. readonly isConnected: boolean;
  5064. readonly isPresenting: boolean;
  5065. /**
  5066. * If this VRDisplay supports room-scale experiences, the optional
  5067. * stage attribute contains details on the room-scale parameters.
  5068. */
  5069. readonly stageParameters: VRStageParameters | null;
  5070. /**
  5071. * Passing the value returned by `requestAnimationFrame` to
  5072. * `cancelAnimationFrame` will unregister the callback.
  5073. */
  5074. cancelAnimationFrame(handle: number): void;
  5075. /**
  5076. * Stops presenting to the VRDisplay.
  5077. */
  5078. exitPresent(): Promise<void>;
  5079. getEyeParameters(whichEye: string): VREyeParameters;
  5080. /**
  5081. * Populates the passed VRFrameData with the information required to render
  5082. * the current frame.
  5083. */
  5084. getFrameData(frameData: VRFrameData): boolean;
  5085. /**
  5086. * Get the layers currently being presented.
  5087. */
  5088. getLayers(): VRLayer[];
  5089. /**
  5090. * Return a VRPose containing the future predicted pose of the VRDisplay
  5091. * when the current frame will be presented. The value returned will not
  5092. * change until JavaScript has returned control to the browser.
  5093. *
  5094. * The VRPose will contain the position, orientation, velocity,
  5095. * and acceleration of each of these properties.
  5096. */
  5097. getPose(): VRPose;
  5098. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  5099. /**
  5100. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5101. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5102. */
  5103. class KeyboardInfoPre extends KeyboardInfo {
  5104. constructor(type: number, event: KeyboardEvent);
  5105. skipOnPointerObservable: boolean;
  5106. }
  5107. }
  5108. declare module BABYLON {
  5109. class PointerEventTypes {
  5110. static _POINTERDOWN: number;
  5111. static _POINTERUP: number;
  5112. static _POINTERMOVE: number;
  5113. static _POINTERWHEEL: number;
  5114. static _POINTERPICK: number;
  5115. static _POINTERTAP: number;
  5116. static _POINTERDOUBLETAP: number;
  5117. static readonly POINTERDOWN: number;
  5118. static readonly POINTERUP: number;
  5119. static readonly POINTERMOVE: number;
  5120. static readonly POINTERWHEEL: number;
  5121. static readonly POINTERPICK: number;
  5122. static readonly POINTERTAP: number;
  5123. static readonly POINTERDOUBLETAP: number;
  5124. }
  5125. class PointerInfoBase {
  5126. type: number;
  5127. event: PointerEvent | MouseWheelEvent;
  5128. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5129. }
  5130. /**
  5131. * This class is used to store pointer related info for the onPrePointerObservable event.
  5132. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5133. */
  5134. class PointerInfoPre extends PointerInfoBase {
  5135. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5136. localPosition: Vector2;
  5137. skipOnPointerObservable: boolean;
  5138. }
  5139. /**
  5140. * This type contains all the data related to a pointer event in Babylon.js.
  5141. * 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.
  5142. */
  5143. class PointerInfo extends PointerInfoBase {
  5144. pickInfo: Nullable<PickingInfo>;
  5145. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5146. }
  5147. }
  5148. declare module BABYLON {
  5149. /**
  5150. * This class can be used to get instrumentation data from a Babylon engine
  5151. */
  5152. class EngineInstrumentation implements IDisposable {
  5153. engine: Engine;
  5154. private _captureGPUFrameTime;
  5155. private _gpuFrameTimeToken;
  5156. private _gpuFrameTime;
  5157. private _captureShaderCompilationTime;
  5158. private _shaderCompilationTime;
  5159. private _onBeginFrameObserver;
  5160. private _onEndFrameObserver;
  5161. private _onBeforeShaderCompilationObserver;
  5162. private _onAfterShaderCompilationObserver;
  5163. /**
  5164. * Gets the perf counter used for GPU frame time
  5165. */
  5166. readonly gpuFrameTimeCounter: PerfCounter;
  5167. /**
  5168. * Gets the GPU frame time capture status
  5169. */
  5170. /**
  5171. * Enable or disable the GPU frame time capture
  5172. */
  5173. captureGPUFrameTime: boolean;
  5174. /**
  5175. * Gets the perf counter used for shader compilation time
  5176. */
  5177. readonly shaderCompilationTimeCounter: PerfCounter;
  5178. /**
  5179. * Gets the shader compilation time capture status
  5180. */
  5181. /**
  5182. * Enable or disable the shader compilation time capture
  5183. */
  5184. captureShaderCompilationTime: boolean;
  5185. constructor(engine: Engine);
  5186. dispose(): void;
  5187. }
  5188. }
  5189. declare module BABYLON {
  5190. /**
  5191. * This class can be used to get instrumentation data from a Babylon engine
  5192. */
  5193. class SceneInstrumentation implements IDisposable {
  5194. scene: Scene;
  5195. private _captureActiveMeshesEvaluationTime;
  5196. private _activeMeshesEvaluationTime;
  5197. private _captureRenderTargetsRenderTime;
  5198. private _renderTargetsRenderTime;
  5199. private _captureFrameTime;
  5200. private _frameTime;
  5201. private _captureRenderTime;
  5202. private _renderTime;
  5203. private _captureInterFrameTime;
  5204. private _interFrameTime;
  5205. private _captureParticlesRenderTime;
  5206. private _particlesRenderTime;
  5207. private _captureSpritesRenderTime;
  5208. private _spritesRenderTime;
  5209. private _capturePhysicsTime;
  5210. private _physicsTime;
  5211. private _captureAnimationsTime;
  5212. private _animationsTime;
  5213. private _onBeforeActiveMeshesEvaluationObserver;
  5214. private _onAfterActiveMeshesEvaluationObserver;
  5215. private _onBeforeRenderTargetsRenderObserver;
  5216. private _onAfterRenderTargetsRenderObserver;
  5217. private _onAfterRenderObserver;
  5218. private _onBeforeDrawPhaseObserver;
  5219. private _onAfterDrawPhaseObserver;
  5220. private _onBeforeAnimationsObserver;
  5221. private _onBeforeParticlesRenderingObserver;
  5222. private _onAfterParticlesRenderingObserver;
  5223. private _onBeforeSpritesRenderingObserver;
  5224. private _onAfterSpritesRenderingObserver;
  5225. private _onBeforePhysicsObserver;
  5226. private _onAfterPhysicsObserver;
  5227. private _onAfterAnimationsObserver;
  5228. /**
  5229. * Gets the perf counter used for active meshes evaluation time
  5230. */
  5231. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  5232. /**
  5233. * Gets the active meshes evaluation time capture status
  5234. */
  5235. /**
  5236. * Enable or disable the active meshes evaluation time capture
  5237. */
  5238. captureActiveMeshesEvaluationTime: boolean;
  5239. /**
  5240. * Gets the perf counter used for render targets render time
  5241. */
  5242. readonly renderTargetsRenderTimeCounter: PerfCounter;
  5243. /**
  5244. * Gets the render targets render time capture status
  5245. */
  5246. /**
  5247. * Enable or disable the render targets render time capture
  5248. */
  5249. captureRenderTargetsRenderTime: boolean;
  5250. /**
  5251. * Gets the perf counter used for particles render time
  5252. */
  5253. readonly particlesRenderTimeCounter: PerfCounter;
  5254. /**
  5255. * Gets the particles render time capture status
  5256. */
  5257. /**
  5258. * Enable or disable the particles render time capture
  5259. */
  5260. captureParticlesRenderTime: boolean;
  5261. /**
  5262. * Gets the perf counter used for sprites render time
  5263. */
  5264. readonly spritesRenderTimeCounter: PerfCounter;
  5265. /**
  5266. * Gets the sprites render time capture status
  5267. */
  5268. /**
  5269. * Enable or disable the sprites render time capture
  5270. */
  5271. captureSpritesRenderTime: boolean;
  5272. /**
  5273. * Gets the perf counter used for physics time
  5274. */
  5275. readonly physicsTimeCounter: PerfCounter;
  5276. /**
  5277. * Gets the physics time capture status
  5278. */
  5279. /**
  5280. * Enable or disable the physics time capture
  5281. */
  5282. capturePhysicsTime: boolean;
  5283. /**
  5284. * Gets the perf counter used for animations time
  5285. */
  5286. readonly animationsTimeCounter: PerfCounter;
  5287. /**
  5288. * Gets the animations time capture status
  5289. */
  5290. /**
  5291. * Enable or disable the animations time capture
  5292. */
  5293. captureAnimationsTime: boolean;
  5294. /**
  5295. * Gets the perf counter used for frame time capture
  5296. */
  5297. readonly frameTimeCounter: PerfCounter;
  5298. /**
  5299. * Gets the frame time capture status
  5300. */
  5301. /**
  5302. * Enable or disable the frame time capture
  5303. */
  5304. captureFrameTime: boolean;
  5305. /**
  5306. * Gets the perf counter used for inter-frames time capture
  5307. */
  5308. readonly interFrameTimeCounter: PerfCounter;
  5309. /**
  5310. * Gets the inter-frames time capture status
  5311. */
  5312. /**
  5313. * Enable or disable the inter-frames time capture
  5314. */
  5315. captureInterFrameTime: boolean;
  5316. /**
  5317. * Gets the perf counter used for render time capture
  5318. */
  5319. readonly renderTimeCounter: PerfCounter;
  5320. /**
  5321. * Gets the render time capture status
  5322. */
  5323. /**
  5324. * Enable or disable the render time capture
  5325. */
  5326. captureRenderTime: boolean;
  5327. /**
  5328. * Gets the perf counter used for draw calls
  5329. */
  5330. readonly drawCallsCounter: PerfCounter;
  5331. /**
  5332. * Gets the perf counter used for texture collisions
  5333. */
  5334. readonly textureCollisionsCounter: PerfCounter;
  5335. constructor(scene: Scene);
  5336. dispose(): void;
  5337. }
  5338. }
  5339. declare module BABYLON {
  5340. class _TimeToken {
  5341. _startTimeQuery: Nullable<WebGLQuery>;
  5342. _endTimeQuery: Nullable<WebGLQuery>;
  5343. _timeElapsedQuery: Nullable<WebGLQuery>;
  5344. _timeElapsedQueryEnded: boolean;
  5345. }
  5346. }
  5347. declare module BABYLON {
  5348. class Collider {
  5349. /** Define if a collision was found */
  5350. collisionFound: boolean;
  5351. /**
  5352. * Define last intersection point in local space
  5353. */
  5354. intersectionPoint: Vector3;
  5355. /**
  5356. * Define last collided mesh
  5357. */
  5358. collidedMesh: Nullable<AbstractMesh>;
  5359. private _collisionPoint;
  5360. private _planeIntersectionPoint;
  5361. private _tempVector;
  5362. private _tempVector2;
  5363. private _tempVector3;
  5364. private _tempVector4;
  5365. private _edge;
  5366. private _baseToVertex;
  5367. private _destinationPoint;
  5368. private _slidePlaneNormal;
  5369. private _displacementVector;
  5370. _radius: Vector3;
  5371. _retry: number;
  5372. private _velocity;
  5373. private _basePoint;
  5374. private _epsilon;
  5375. _velocityWorldLength: number;
  5376. _basePointWorld: Vector3;
  5377. private _velocityWorld;
  5378. private _normalizedVelocity;
  5379. _initialVelocity: Vector3;
  5380. _initialPosition: Vector3;
  5381. private _nearestDistance;
  5382. private _collisionMask;
  5383. collisionMask: number;
  5384. /**
  5385. * Gets the plane normal used to compute the sliding response (in local space)
  5386. */
  5387. readonly slidePlaneNormal: Vector3;
  5388. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5390. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5391. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5392. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5393. _getResponse(pos: Vector3, vel: Vector3): void;
  5394. }
  5395. }
  5396. declare module BABYLON {
  5397. var CollisionWorker: string;
  5398. interface ICollisionCoordinator {
  5399. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5400. init(scene: Scene): void;
  5401. destroy(): void;
  5402. onMeshAdded(mesh: AbstractMesh): void;
  5403. onMeshUpdated(mesh: AbstractMesh): void;
  5404. onMeshRemoved(mesh: AbstractMesh): void;
  5405. onGeometryAdded(geometry: Geometry): void;
  5406. onGeometryUpdated(geometry: Geometry): void;
  5407. onGeometryDeleted(geometry: Geometry): void;
  5408. }
  5409. interface SerializedMesh {
  5410. id: string;
  5411. name: string;
  5412. uniqueId: number;
  5413. geometryId: Nullable<string>;
  5414. sphereCenter: Array<number>;
  5415. sphereRadius: number;
  5416. boxMinimum: Array<number>;
  5417. boxMaximum: Array<number>;
  5418. worldMatrixFromCache: any;
  5419. subMeshes: Array<SerializedSubMesh>;
  5420. checkCollisions: boolean;
  5421. }
  5422. interface SerializedSubMesh {
  5423. position: number;
  5424. verticesStart: number;
  5425. verticesCount: number;
  5426. indexStart: number;
  5427. indexCount: number;
  5428. hasMaterial: boolean;
  5429. sphereCenter: Array<number>;
  5430. sphereRadius: number;
  5431. boxMinimum: Array<number>;
  5432. boxMaximum: Array<number>;
  5433. }
  5434. /**
  5435. * Interface describing the value associated with a geometry
  5436. */
  5437. interface SerializedGeometry {
  5438. /**
  5439. * Defines the unique ID of the geometry
  5440. */
  5441. id: string;
  5442. /**
  5443. * Defines the array containing the positions
  5444. */
  5445. positions: Float32Array;
  5446. /**
  5447. * Defines the array containing the indices
  5448. */
  5449. indices: Uint32Array;
  5450. /**
  5451. * Defines the array containing the normals
  5452. */
  5453. normals: Float32Array;
  5454. }
  5455. interface BabylonMessage {
  5456. taskType: WorkerTaskType;
  5457. payload: InitPayload | CollidePayload | UpdatePayload;
  5458. }
  5459. interface SerializedColliderToWorker {
  5460. position: Array<number>;
  5461. velocity: Array<number>;
  5462. radius: Array<number>;
  5463. }
  5464. enum WorkerTaskType {
  5465. INIT = 0,
  5466. UPDATE = 1,
  5467. COLLIDE = 2,
  5468. }
  5469. interface WorkerReply {
  5470. error: WorkerReplyType;
  5471. taskType: WorkerTaskType;
  5472. payload?: any;
  5473. }
  5474. interface CollisionReplyPayload {
  5475. newPosition: Array<number>;
  5476. collisionId: number;
  5477. collidedMeshUniqueId: number;
  5478. }
  5479. interface InitPayload {
  5480. }
  5481. interface CollidePayload {
  5482. collisionId: number;
  5483. collider: SerializedColliderToWorker;
  5484. maximumRetry: number;
  5485. excludedMeshUniqueId: Nullable<number>;
  5486. }
  5487. interface UpdatePayload {
  5488. updatedMeshes: {
  5489. [n: number]: SerializedMesh;
  5490. };
  5491. updatedGeometries: {
  5492. [s: string]: SerializedGeometry;
  5493. };
  5494. removedMeshes: Array<number>;
  5495. removedGeometries: Array<string>;
  5496. }
  5497. enum WorkerReplyType {
  5498. SUCCESS = 0,
  5499. UNKNOWN_ERROR = 1,
  5500. }
  5501. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5502. private _scene;
  5503. private _scaledPosition;
  5504. private _scaledVelocity;
  5505. private _collisionsCallbackArray;
  5506. private _init;
  5507. private _runningUpdated;
  5508. private _worker;
  5509. private _addUpdateMeshesList;
  5510. private _addUpdateGeometriesList;
  5511. private _toRemoveMeshesArray;
  5512. private _toRemoveGeometryArray;
  5513. constructor();
  5514. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5515. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5516. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5517. init(scene: Scene): void;
  5518. destroy(): void;
  5519. onMeshAdded(mesh: AbstractMesh): void;
  5520. onMeshUpdated: (transformNode: TransformNode) => void;
  5521. onMeshRemoved(mesh: AbstractMesh): void;
  5522. onGeometryAdded(geometry: Geometry): void;
  5523. onGeometryUpdated: (geometry: Geometry) => void;
  5524. onGeometryDeleted(geometry: Geometry): void;
  5525. private _afterRender;
  5526. private _onMessageFromWorker;
  5527. }
  5528. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5529. private _scene;
  5530. private _scaledPosition;
  5531. private _scaledVelocity;
  5532. private _finalPosition;
  5533. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5534. init(scene: Scene): void;
  5535. destroy(): void;
  5536. onMeshAdded(mesh: AbstractMesh): void;
  5537. onMeshUpdated(mesh: AbstractMesh): void;
  5538. onMeshRemoved(mesh: AbstractMesh): void;
  5539. onGeometryAdded(geometry: Geometry): void;
  5540. onGeometryUpdated(geometry: Geometry): void;
  5541. onGeometryDeleted(geometry: Geometry): void;
  5542. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5543. }
  5544. }
  5545. declare function importScripts(...urls: string[]): void;
  5546. declare const safePostMessage: any;
  5547. declare module BABYLON {
  5548. var WorkerIncluded: boolean;
  5549. class CollisionCache {
  5550. private _meshes;
  5551. private _geometries;
  5552. getMeshes(): {
  5553. [n: number]: SerializedMesh;
  5554. };
  5555. getGeometries(): {
  5556. [s: number]: SerializedGeometry;
  5557. };
  5558. getMesh(id: any): SerializedMesh;
  5559. addMesh(mesh: SerializedMesh): void;
  5560. removeMesh(uniqueId: number): void;
  5561. getGeometry(id: string): SerializedGeometry;
  5562. addGeometry(geometry: SerializedGeometry): void;
  5563. removeGeometry(id: string): void;
  5564. }
  5565. class CollideWorker {
  5566. collider: Collider;
  5567. private _collisionCache;
  5568. private finalPosition;
  5569. private collisionsScalingMatrix;
  5570. private collisionTranformationMatrix;
  5571. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5572. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5573. private checkCollision(mesh);
  5574. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5575. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5576. private checkSubmeshCollision(subMesh);
  5577. }
  5578. interface ICollisionDetector {
  5579. onInit(payload: InitPayload): void;
  5580. onUpdate(payload: UpdatePayload): void;
  5581. onCollision(payload: CollidePayload): void;
  5582. }
  5583. class CollisionDetectorTransferable implements ICollisionDetector {
  5584. private _collisionCache;
  5585. onInit(payload: InitPayload): void;
  5586. onUpdate(payload: UpdatePayload): void;
  5587. onCollision(payload: CollidePayload): void;
  5588. }
  5589. }
  5590. declare module BABYLON {
  5591. class IntersectionInfo {
  5592. bu: Nullable<number>;
  5593. bv: Nullable<number>;
  5594. distance: number;
  5595. faceId: number;
  5596. subMeshId: number;
  5597. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5598. }
  5599. class PickingInfo {
  5600. hit: boolean;
  5601. distance: number;
  5602. pickedPoint: Nullable<Vector3>;
  5603. pickedMesh: Nullable<AbstractMesh>;
  5604. bu: number;
  5605. bv: number;
  5606. faceId: number;
  5607. subMeshId: number;
  5608. pickedSprite: Nullable<Sprite>;
  5609. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5610. getTextureCoordinates(): Nullable<Vector2>;
  5611. }
  5612. }
  5613. declare module BABYLON {
  5614. class BoundingBox implements ICullable {
  5615. minimum: Vector3;
  5616. maximum: Vector3;
  5617. vectors: Vector3[];
  5618. center: Vector3;
  5619. centerWorld: Vector3;
  5620. extendSize: Vector3;
  5621. extendSizeWorld: Vector3;
  5622. directions: Vector3[];
  5623. vectorsWorld: Vector3[];
  5624. minimumWorld: Vector3;
  5625. maximumWorld: Vector3;
  5626. private _worldMatrix;
  5627. constructor(minimum: Vector3, maximum: Vector3);
  5628. getWorldMatrix(): Matrix;
  5629. setWorldMatrix(matrix: Matrix): BoundingBox;
  5630. _update(world: Matrix): void;
  5631. isInFrustum(frustumPlanes: Plane[]): boolean;
  5632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5633. intersectsPoint(point: Vector3): boolean;
  5634. intersectsSphere(sphere: BoundingSphere): boolean;
  5635. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5636. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5637. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5638. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5639. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5640. }
  5641. }
  5642. declare module BABYLON {
  5643. interface ICullable {
  5644. isInFrustum(frustumPlanes: Plane[]): boolean;
  5645. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5646. }
  5647. class BoundingInfo implements ICullable {
  5648. minimum: Vector3;
  5649. maximum: Vector3;
  5650. boundingBox: BoundingBox;
  5651. boundingSphere: BoundingSphere;
  5652. private _isLocked;
  5653. constructor(minimum: Vector3, maximum: Vector3);
  5654. isLocked: boolean;
  5655. update(world: Matrix): void;
  5656. /**
  5657. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5658. * @param center New center of the bounding info
  5659. * @param extend New extend of the bounding info
  5660. */
  5661. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5662. isInFrustum(frustumPlanes: Plane[]): boolean;
  5663. /**
  5664. * Gets the world distance between the min and max points of the bounding box
  5665. */
  5666. readonly diagonalLength: number;
  5667. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5668. _checkCollision(collider: Collider): boolean;
  5669. intersectsPoint(point: Vector3): boolean;
  5670. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5671. }
  5672. }
  5673. declare module BABYLON {
  5674. class BoundingSphere {
  5675. minimum: Vector3;
  5676. maximum: Vector3;
  5677. center: Vector3;
  5678. radius: number;
  5679. centerWorld: Vector3;
  5680. radiusWorld: number;
  5681. private _tempRadiusVector;
  5682. constructor(minimum: Vector3, maximum: Vector3);
  5683. _update(world: Matrix): void;
  5684. isInFrustum(frustumPlanes: Plane[]): boolean;
  5685. intersectsPoint(point: Vector3): boolean;
  5686. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5687. }
  5688. }
  5689. declare module BABYLON {
  5690. class Ray {
  5691. origin: Vector3;
  5692. direction: Vector3;
  5693. length: number;
  5694. private _edge1;
  5695. private _edge2;
  5696. private _pvec;
  5697. private _tvec;
  5698. private _qvec;
  5699. private _tmpRay;
  5700. constructor(origin: Vector3, direction: Vector3, length?: number);
  5701. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5702. intersectsBox(box: BoundingBox): boolean;
  5703. intersectsSphere(sphere: BoundingSphere): boolean;
  5704. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5705. intersectsPlane(plane: Plane): Nullable<number>;
  5706. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5707. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5708. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5709. private static smallnum;
  5710. private static rayl;
  5711. /**
  5712. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5713. * @param sega the first point of the segment to test the intersection against
  5714. * @param segb the second point of the segment to test the intersection against
  5715. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5716. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5717. */
  5718. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5719. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5720. static Zero(): Ray;
  5721. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5722. /**
  5723. * 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
  5724. * transformed to the given world matrix.
  5725. * @param origin The origin point
  5726. * @param end The end point
  5727. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5728. */
  5729. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5730. static Transform(ray: Ray, matrix: Matrix): Ray;
  5731. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5732. }
  5733. }
  5734. declare module BABYLON {
  5735. class DebugLayer {
  5736. private _scene;
  5737. static InspectorURL: string;
  5738. private _inspector;
  5739. private BJSINSPECTOR;
  5740. constructor(scene: Scene);
  5741. /** Creates the inspector window. */
  5742. private _createInspector(config?);
  5743. isVisible(): boolean;
  5744. hide(): void;
  5745. show(config?: {
  5746. popup?: boolean;
  5747. initialTab?: number;
  5748. parentElement?: HTMLElement;
  5749. newColors?: {
  5750. backgroundColor?: string;
  5751. backgroundColorLighter?: string;
  5752. backgroundColorLighter2?: string;
  5753. backgroundColorLighter3?: string;
  5754. color?: string;
  5755. colorTop?: string;
  5756. colorBot?: string;
  5757. };
  5758. }): void;
  5759. }
  5760. }
  5761. declare module BABYLON {
  5762. class Debug {
  5763. static AxesViewer: {
  5764. new (scene: Scene, scaleLines?: number): {
  5765. _xline: Vector3[];
  5766. _yline: Vector3[];
  5767. _zline: Vector3[];
  5768. _xmesh: Nullable<LinesMesh>;
  5769. _ymesh: Nullable<LinesMesh>;
  5770. _zmesh: Nullable<LinesMesh>;
  5771. scene: Nullable<Scene>;
  5772. scaleLines: number;
  5773. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5774. dispose(): void;
  5775. };
  5776. };
  5777. static BoneAxesViewer: {
  5778. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  5779. mesh: Nullable<Mesh>;
  5780. bone: Nullable<Bone>;
  5781. pos: Vector3;
  5782. xaxis: Vector3;
  5783. yaxis: Vector3;
  5784. zaxis: Vector3;
  5785. update(): void;
  5786. dispose(): void;
  5787. _xline: Vector3[];
  5788. _yline: Vector3[];
  5789. _zline: Vector3[];
  5790. _xmesh: Nullable<LinesMesh>;
  5791. _ymesh: Nullable<LinesMesh>;
  5792. _zmesh: Nullable<LinesMesh>;
  5793. scene: Nullable<Scene>;
  5794. scaleLines: number;
  5795. };
  5796. };
  5797. static PhysicsViewer: {
  5798. new (scene: Scene): {
  5799. _impostors: Nullable<PhysicsImpostor>[];
  5800. _meshes: Nullable<AbstractMesh>[];
  5801. _scene: Nullable<Scene>;
  5802. _numMeshes: number;
  5803. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5804. _renderFunction: () => void;
  5805. _debugBoxMesh: Mesh;
  5806. _debugSphereMesh: Mesh;
  5807. _debugMaterial: StandardMaterial;
  5808. _updateDebugMeshes(): void;
  5809. showImpostor(impostor: PhysicsImpostor): void;
  5810. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5811. _getDebugMaterial(scene: Scene): Material;
  5812. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  5813. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  5814. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  5815. dispose(): void;
  5816. };
  5817. };
  5818. static SkeletonViewer: {
  5819. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  5820. color: Color3;
  5821. _scene: Scene;
  5822. _debugLines: Vector3[][];
  5823. _debugMesh: Nullable<LinesMesh>;
  5824. _isEnabled: boolean;
  5825. _renderFunction: () => void;
  5826. skeleton: Skeleton;
  5827. mesh: AbstractMesh;
  5828. autoUpdateBonesMatrices: boolean;
  5829. renderingGroupId: number;
  5830. isEnabled: boolean;
  5831. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  5832. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  5833. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  5834. update(): void;
  5835. dispose(): void;
  5836. };
  5837. };
  5838. }
  5839. }
  5840. declare module BABYLON {
  5841. class RayHelper {
  5842. ray: Nullable<Ray>;
  5843. private _renderPoints;
  5844. private _renderLine;
  5845. private _renderFunction;
  5846. private _scene;
  5847. private _updateToMeshFunction;
  5848. private _attachedToMesh;
  5849. private _meshSpaceDirection;
  5850. private _meshSpaceOrigin;
  5851. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5852. constructor(ray: Ray);
  5853. show(scene: Scene, color: Color3): void;
  5854. hide(): void;
  5855. private _render();
  5856. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5857. detachFromMesh(): void;
  5858. private _updateToMesh();
  5859. dispose(): void;
  5860. }
  5861. }
  5862. declare module BABYLON {
  5863. class InstancingAttributeInfo {
  5864. /**
  5865. * Index/offset of the attribute in the vertex shader
  5866. */
  5867. index: number;
  5868. /**
  5869. * size of the attribute, 1, 2, 3 or 4
  5870. */
  5871. attributeSize: number;
  5872. /**
  5873. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5874. * default is FLOAT
  5875. */
  5876. attribyteType: number;
  5877. /**
  5878. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5879. */
  5880. normalized: boolean;
  5881. /**
  5882. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5883. */
  5884. offset: number;
  5885. /**
  5886. * Name of the GLSL attribute, for debugging purpose only
  5887. */
  5888. attributeName: string;
  5889. }
  5890. /**
  5891. * Define options used to create a render target texture
  5892. */
  5893. class RenderTargetCreationOptions {
  5894. /**
  5895. * Specifies is mipmaps must be generated
  5896. */
  5897. generateMipMaps?: boolean;
  5898. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5899. generateDepthBuffer?: boolean;
  5900. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5901. generateStencilBuffer?: boolean;
  5902. /** Defines texture type (int by default) */
  5903. type?: number;
  5904. /** Defines sampling mode (trilinear by default) */
  5905. samplingMode?: number;
  5906. /** Defines format (RGBA by default) */
  5907. format?: number;
  5908. }
  5909. /**
  5910. * Define options used to create a depth texture
  5911. */
  5912. class DepthTextureCreationOptions {
  5913. /** Specifies whether or not a stencil should be allocated in the texture */
  5914. generateStencil?: boolean;
  5915. /** Specifies whether or not bilinear filtering is enable on the texture */
  5916. bilinearFiltering?: boolean;
  5917. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  5918. comparisonFunction?: number;
  5919. /** Specifies if the created texture is a cube texture */
  5920. isCube?: boolean;
  5921. }
  5922. /**
  5923. * Regroup several parameters relative to the browser in use
  5924. */
  5925. class EngineCapabilities {
  5926. /** The maximum textures image */
  5927. maxTexturesImageUnits: number;
  5928. maxVertexTextureImageUnits: number;
  5929. maxCombinedTexturesImageUnits: number;
  5930. /** The maximum texture size */
  5931. maxTextureSize: number;
  5932. maxCubemapTextureSize: number;
  5933. maxRenderTextureSize: number;
  5934. maxVertexAttribs: number;
  5935. maxVaryingVectors: number;
  5936. maxVertexUniformVectors: number;
  5937. maxFragmentUniformVectors: number;
  5938. standardDerivatives: boolean;
  5939. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  5940. pvrtc: any;
  5941. etc1: any;
  5942. etc2: any;
  5943. astc: any;
  5944. textureFloat: boolean;
  5945. vertexArrayObject: boolean;
  5946. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  5947. maxAnisotropy: number;
  5948. instancedArrays: boolean;
  5949. uintIndices: boolean;
  5950. highPrecisionShaderSupported: boolean;
  5951. fragmentDepthSupported: boolean;
  5952. textureFloatLinearFiltering: boolean;
  5953. textureFloatRender: boolean;
  5954. textureHalfFloat: boolean;
  5955. textureHalfFloatLinearFiltering: boolean;
  5956. textureHalfFloatRender: boolean;
  5957. textureLOD: boolean;
  5958. drawBuffersExtension: boolean;
  5959. depthTextureExtension: boolean;
  5960. colorBufferFloat: boolean;
  5961. timerQuery: EXT_disjoint_timer_query;
  5962. canUseTimestampForTimerQuery: boolean;
  5963. }
  5964. interface EngineOptions extends WebGLContextAttributes {
  5965. limitDeviceRatio?: number;
  5966. autoEnableWebVR?: boolean;
  5967. disableWebGL2Support?: boolean;
  5968. audioEngine?: boolean;
  5969. deterministicLockstep?: boolean;
  5970. lockstepMaxSteps?: number;
  5971. doNotHandleContextLost?: boolean;
  5972. }
  5973. interface IDisplayChangedEventArgs {
  5974. vrDisplay: Nullable<any>;
  5975. vrSupported: boolean;
  5976. }
  5977. /**
  5978. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  5979. */
  5980. class Engine {
  5981. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  5982. static ExceptionList: ({
  5983. key: string;
  5984. capture: string;
  5985. captureConstraint: number;
  5986. targets: string[];
  5987. } | {
  5988. key: string;
  5989. capture: null;
  5990. captureConstraint: null;
  5991. targets: string[];
  5992. })[];
  5993. static Instances: Engine[];
  5994. static readonly LastCreatedEngine: Nullable<Engine>;
  5995. static readonly LastCreatedScene: Nullable<Scene>;
  5996. /**
  5997. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  5998. */
  5999. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6000. private static _ALPHA_DISABLE;
  6001. private static _ALPHA_ADD;
  6002. private static _ALPHA_COMBINE;
  6003. private static _ALPHA_SUBTRACT;
  6004. private static _ALPHA_MULTIPLY;
  6005. private static _ALPHA_MAXIMIZED;
  6006. private static _ALPHA_ONEONE;
  6007. private static _ALPHA_PREMULTIPLIED;
  6008. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6009. private static _ALPHA_INTERPOLATE;
  6010. private static _ALPHA_SCREENMODE;
  6011. private static _DELAYLOADSTATE_NONE;
  6012. private static _DELAYLOADSTATE_LOADED;
  6013. private static _DELAYLOADSTATE_LOADING;
  6014. private static _DELAYLOADSTATE_NOTLOADED;
  6015. private static _TEXTUREFORMAT_ALPHA;
  6016. private static _TEXTUREFORMAT_LUMINANCE;
  6017. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6018. private static _TEXTUREFORMAT_RGB;
  6019. private static _TEXTUREFORMAT_RGBA;
  6020. private static _TEXTUREFORMAT_R32F;
  6021. private static _TEXTUREFORMAT_RG32F;
  6022. private static _TEXTUREFORMAT_RGB32F;
  6023. private static _TEXTUREFORMAT_RGBA32F;
  6024. private static _TEXTURETYPE_UNSIGNED_INT;
  6025. private static _TEXTURETYPE_FLOAT;
  6026. private static _TEXTURETYPE_HALF_FLOAT;
  6027. private static _NEVER;
  6028. private static _ALWAYS;
  6029. private static _LESS;
  6030. private static _EQUAL;
  6031. private static _LEQUAL;
  6032. private static _GREATER;
  6033. private static _GEQUAL;
  6034. private static _NOTEQUAL;
  6035. static readonly NEVER: number;
  6036. static readonly ALWAYS: number;
  6037. static readonly LESS: number;
  6038. static readonly EQUAL: number;
  6039. static readonly LEQUAL: number;
  6040. static readonly GREATER: number;
  6041. static readonly GEQUAL: number;
  6042. static readonly NOTEQUAL: number;
  6043. private static _KEEP;
  6044. private static _REPLACE;
  6045. private static _INCR;
  6046. private static _DECR;
  6047. private static _INVERT;
  6048. private static _INCR_WRAP;
  6049. private static _DECR_WRAP;
  6050. static readonly KEEP: number;
  6051. static readonly REPLACE: number;
  6052. static readonly INCR: number;
  6053. static readonly DECR: number;
  6054. static readonly INVERT: number;
  6055. static readonly INCR_WRAP: number;
  6056. static readonly DECR_WRAP: number;
  6057. static readonly ALPHA_DISABLE: number;
  6058. static readonly ALPHA_ONEONE: number;
  6059. static readonly ALPHA_ADD: number;
  6060. static readonly ALPHA_COMBINE: number;
  6061. static readonly ALPHA_SUBTRACT: number;
  6062. static readonly ALPHA_MULTIPLY: number;
  6063. static readonly ALPHA_MAXIMIZED: number;
  6064. static readonly ALPHA_PREMULTIPLIED: number;
  6065. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6066. static readonly ALPHA_INTERPOLATE: number;
  6067. static readonly ALPHA_SCREENMODE: number;
  6068. static readonly DELAYLOADSTATE_NONE: number;
  6069. static readonly DELAYLOADSTATE_LOADED: number;
  6070. static readonly DELAYLOADSTATE_LOADING: number;
  6071. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6072. static readonly TEXTUREFORMAT_ALPHA: number;
  6073. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6074. /**
  6075. * R32F
  6076. */
  6077. static readonly TEXTUREFORMAT_R32F: number;
  6078. /**
  6079. * RG32F
  6080. */
  6081. static readonly TEXTUREFORMAT_RG32F: number;
  6082. /**
  6083. * RGB32F
  6084. */
  6085. static readonly TEXTUREFORMAT_RGB32F: number;
  6086. /**
  6087. * RGBA32F
  6088. */
  6089. static readonly TEXTUREFORMAT_RGBA32F: number;
  6090. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6091. static readonly TEXTUREFORMAT_RGB: number;
  6092. static readonly TEXTUREFORMAT_RGBA: number;
  6093. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6094. static readonly TEXTURETYPE_FLOAT: number;
  6095. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6096. private static _SCALEMODE_FLOOR;
  6097. private static _SCALEMODE_NEAREST;
  6098. private static _SCALEMODE_CEILING;
  6099. static readonly SCALEMODE_FLOOR: number;
  6100. static readonly SCALEMODE_NEAREST: number;
  6101. static readonly SCALEMODE_CEILING: number;
  6102. static readonly Version: string;
  6103. static CollisionsEpsilon: number;
  6104. static CodeRepository: string;
  6105. static ShadersRepository: string;
  6106. forcePOTTextures: boolean;
  6107. isFullscreen: boolean;
  6108. isPointerLock: boolean;
  6109. cullBackFaces: boolean;
  6110. renderEvenInBackground: boolean;
  6111. preventCacheWipeBetweenFrames: boolean;
  6112. /**
  6113. * To enable/disable IDB support and avoid XHR on .manifest
  6114. **/
  6115. enableOfflineSupport: boolean;
  6116. scenes: Scene[];
  6117. postProcesses: PostProcess[];
  6118. /**
  6119. * Observable event triggered each time the rendering canvas is resized
  6120. */
  6121. onResizeObservable: Observable<Engine>;
  6122. /**
  6123. * Observable event triggered each time the canvas loses focus
  6124. */
  6125. onCanvasBlurObservable: Observable<Engine>;
  6126. /**
  6127. * Observable event triggered each time the canvas gains focus
  6128. */
  6129. onCanvasFocusObservable: Observable<Engine>;
  6130. /**
  6131. * Observable event triggered each time the canvas receives pointerout event
  6132. */
  6133. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6134. /**
  6135. * Observable event triggered before each texture is initialized
  6136. */
  6137. onBeforeTextureInitObservable: Observable<Texture>;
  6138. private _vrDisplay;
  6139. private _vrSupported;
  6140. private _oldSize;
  6141. private _oldHardwareScaleFactor;
  6142. private _vrExclusivePointerMode;
  6143. private _webVRInitPromise;
  6144. readonly isInVRExclusivePointerMode: boolean;
  6145. disableUniformBuffers: boolean;
  6146. _uniformBuffers: UniformBuffer[];
  6147. readonly supportsUniformBuffers: boolean;
  6148. /**
  6149. * Observable raised when the engine begins a new frame
  6150. */
  6151. onBeginFrameObservable: Observable<Engine>;
  6152. /**
  6153. * Observable raised when the engine ends the current frame
  6154. */
  6155. onEndFrameObservable: Observable<Engine>;
  6156. /**
  6157. * Observable raised when the engine is about to compile a shader
  6158. */
  6159. onBeforeShaderCompilationObservable: Observable<Engine>;
  6160. /**
  6161. * Observable raised when the engine has jsut compiled a shader
  6162. */
  6163. onAfterShaderCompilationObservable: Observable<Engine>;
  6164. private _gl;
  6165. private _renderingCanvas;
  6166. private _windowIsBackground;
  6167. private _webGLVersion;
  6168. readonly needPOTTextures: boolean;
  6169. private _badOS;
  6170. readonly badOS: boolean;
  6171. private _badDesktopOS;
  6172. readonly badDesktopOS: boolean;
  6173. /**
  6174. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6175. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  6176. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  6177. */
  6178. disableTextureBindingOptimization: boolean;
  6179. static audioEngine: AudioEngine;
  6180. private _onFocus;
  6181. private _onBlur;
  6182. private _onCanvasPointerOut;
  6183. private _onCanvasBlur;
  6184. private _onCanvasFocus;
  6185. private _onFullscreenChange;
  6186. private _onPointerLockChange;
  6187. private _onVRDisplayPointerRestricted;
  6188. private _onVRDisplayPointerUnrestricted;
  6189. private _onVrDisplayConnect;
  6190. private _onVrDisplayDisconnect;
  6191. private _onVrDisplayPresentChange;
  6192. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6193. onVRRequestPresentComplete: Observable<boolean>;
  6194. onVRRequestPresentStart: Observable<Engine>;
  6195. private _hardwareScalingLevel;
  6196. protected _caps: EngineCapabilities;
  6197. private _pointerLockRequested;
  6198. private _isStencilEnable;
  6199. private _colorWrite;
  6200. private _loadingScreen;
  6201. _drawCalls: PerfCounter;
  6202. _textureCollisions: PerfCounter;
  6203. private _glVersion;
  6204. private _glRenderer;
  6205. private _glVendor;
  6206. private _videoTextureSupported;
  6207. private _renderingQueueLaunched;
  6208. private _activeRenderLoops;
  6209. private _deterministicLockstep;
  6210. private _lockstepMaxSteps;
  6211. onContextLostObservable: Observable<Engine>;
  6212. onContextRestoredObservable: Observable<Engine>;
  6213. private _onContextLost;
  6214. private _onContextRestored;
  6215. private _contextWasLost;
  6216. private _doNotHandleContextLost;
  6217. private _performanceMonitor;
  6218. private _fps;
  6219. private _deltaTime;
  6220. /**
  6221. * Turn this value on if you want to pause FPS computation when in background
  6222. */
  6223. disablePerformanceMonitorInBackground: boolean;
  6224. readonly performanceMonitor: PerformanceMonitor;
  6225. protected _depthCullingState: _DepthCullingState;
  6226. protected _stencilState: _StencilState;
  6227. protected _alphaState: _AlphaState;
  6228. protected _alphaMode: number;
  6229. private _internalTexturesCache;
  6230. protected _activeChannel: number;
  6231. private _currentTextureChannel;
  6232. protected _boundTexturesCache: {
  6233. [key: string]: Nullable<InternalTexture>;
  6234. };
  6235. protected _currentEffect: Nullable<Effect>;
  6236. protected _currentProgram: Nullable<WebGLProgram>;
  6237. private _compiledEffects;
  6238. private _vertexAttribArraysEnabled;
  6239. protected _cachedViewport: Nullable<Viewport>;
  6240. private _cachedVertexArrayObject;
  6241. protected _cachedVertexBuffers: any;
  6242. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6243. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6244. protected _currentRenderTarget: Nullable<InternalTexture>;
  6245. private _uintIndicesCurrentlySet;
  6246. private _currentBoundBuffer;
  6247. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6248. private _currentBufferPointers;
  6249. private _currentInstanceLocations;
  6250. private _currentInstanceBuffers;
  6251. private _textureUnits;
  6252. private _firstBoundInternalTextureTracker;
  6253. private _lastBoundInternalTextureTracker;
  6254. private _workingCanvas;
  6255. private _workingContext;
  6256. private _rescalePostProcess;
  6257. private _dummyFramebuffer;
  6258. private _externalData;
  6259. private _bindedRenderFunction;
  6260. private _vaoRecordInProgress;
  6261. private _mustWipeVertexAttributes;
  6262. private _emptyTexture;
  6263. private _emptyCubeTexture;
  6264. private _emptyTexture3D;
  6265. private _frameHandler;
  6266. private _nextFreeTextureSlots;
  6267. private _maxSimultaneousTextures;
  6268. private _activeRequests;
  6269. private _texturesSupported;
  6270. private _textureFormatInUse;
  6271. readonly texturesSupported: Array<string>;
  6272. readonly textureFormatInUse: Nullable<string>;
  6273. readonly currentViewport: Nullable<Viewport>;
  6274. readonly emptyTexture: InternalTexture;
  6275. readonly emptyTexture3D: InternalTexture;
  6276. readonly emptyCubeTexture: InternalTexture;
  6277. /**
  6278. * @constructor
  6279. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6280. * @param antialias defines enable antialiasing (default: false)
  6281. * @param options defines further options to be sent to the getContext() function
  6282. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6283. */
  6284. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6285. private _rebuildInternalTextures();
  6286. private _rebuildEffects();
  6287. private _rebuildBuffers();
  6288. private _initGLContext();
  6289. readonly webGLVersion: number;
  6290. /**
  6291. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6292. */
  6293. readonly isStencilEnable: boolean;
  6294. private _prepareWorkingCanvas();
  6295. resetTextureCache(): void;
  6296. isDeterministicLockStep(): boolean;
  6297. getLockstepMaxSteps(): number;
  6298. getGlInfo(): {
  6299. vendor: string;
  6300. renderer: string;
  6301. version: string;
  6302. };
  6303. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6304. getRenderWidth(useScreen?: boolean): number;
  6305. getRenderHeight(useScreen?: boolean): number;
  6306. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6307. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6308. setHardwareScalingLevel(level: number): void;
  6309. getHardwareScalingLevel(): number;
  6310. getLoadedTexturesCache(): InternalTexture[];
  6311. getCaps(): EngineCapabilities;
  6312. /** The number of draw calls submitted last frame */
  6313. readonly drawCalls: number;
  6314. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6315. getDepthFunction(): Nullable<number>;
  6316. setDepthFunction(depthFunc: number): void;
  6317. setDepthFunctionToGreater(): void;
  6318. setDepthFunctionToGreaterOrEqual(): void;
  6319. setDepthFunctionToLess(): void;
  6320. setDepthFunctionToLessOrEqual(): void;
  6321. getStencilBuffer(): boolean;
  6322. setStencilBuffer(enable: boolean): void;
  6323. getStencilMask(): number;
  6324. setStencilMask(mask: number): void;
  6325. getStencilFunction(): number;
  6326. getStencilFunctionReference(): number;
  6327. getStencilFunctionMask(): number;
  6328. setStencilFunction(stencilFunc: number): void;
  6329. setStencilFunctionReference(reference: number): void;
  6330. setStencilFunctionMask(mask: number): void;
  6331. getStencilOperationFail(): number;
  6332. getStencilOperationDepthFail(): number;
  6333. getStencilOperationPass(): number;
  6334. setStencilOperationFail(operation: number): void;
  6335. setStencilOperationDepthFail(operation: number): void;
  6336. setStencilOperationPass(operation: number): void;
  6337. setDitheringState(value: boolean): void;
  6338. setRasterizerState(value: boolean): void;
  6339. /**
  6340. * stop executing a render loop function and remove it from the execution array
  6341. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  6342. */
  6343. stopRenderLoop(renderFunction?: () => void): void;
  6344. _renderLoop(): void;
  6345. /**
  6346. * Register and execute a render loop. The engine can have more than one render function.
  6347. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  6348. * @example
  6349. * engine.runRenderLoop(function () {
  6350. * scene.render()
  6351. * })
  6352. */
  6353. runRenderLoop(renderFunction: () => void): void;
  6354. /**
  6355. * Toggle full screen mode.
  6356. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  6357. * @param {any} options - an options object to be sent to the requestFullscreen function
  6358. */
  6359. switchFullscreen(requestPointerLock: boolean): void;
  6360. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6361. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6362. /**
  6363. * Set the WebGL's viewport
  6364. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  6365. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  6366. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  6367. */
  6368. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6369. /**
  6370. * Directly set the WebGL Viewport
  6371. * The x, y, width & height are directly passed to the WebGL call
  6372. * @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.
  6373. */
  6374. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6375. beginFrame(): void;
  6376. endFrame(): void;
  6377. /**
  6378. * resize the view according to the canvas' size.
  6379. * @example
  6380. * window.addEventListener("resize", function () {
  6381. * engine.resize();
  6382. * });
  6383. */
  6384. resize(): void;
  6385. /**
  6386. * force a specific size of the canvas
  6387. * @param {number} width - the new canvas' width
  6388. * @param {number} height - the new canvas' height
  6389. */
  6390. setSize(width: number, height: number): void;
  6391. isVRDevicePresent(): boolean;
  6392. getVRDevice(): any;
  6393. /**
  6394. * Initializes a webVR display and starts listening to display change events.
  6395. * The onVRDisplayChangedObservable will be notified upon these changes.
  6396. * @returns The onVRDisplayChangedObservable.
  6397. */
  6398. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6399. /**
  6400. * Initializes a webVR display and starts listening to display change events.
  6401. * The onVRDisplayChangedObservable will be notified upon these changes.
  6402. * @returns A promise containing a VRDisplay and if vr is supported.
  6403. */
  6404. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6405. enableVR(): void;
  6406. disableVR(): void;
  6407. private _onVRFullScreenTriggered;
  6408. private _getVRDisplaysAsync();
  6409. /**
  6410. * Binds the frame buffer to the specified texture.
  6411. * @param texture The texture to render to or null for the default canvas
  6412. * @param faceIndex The face of the texture to render to in case of cube texture
  6413. * @param requiredWidth The width of the target to render to
  6414. * @param requiredHeight The height of the target to render to
  6415. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6416. * @param depthStencilTexture The depth stencil texture to use to render
  6417. */
  6418. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6419. private bindUnboundFramebuffer(framebuffer);
  6420. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6421. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6422. generateMipMapsForCubemap(texture: InternalTexture): void;
  6423. flushFramebuffer(): void;
  6424. restoreDefaultFramebuffer(): void;
  6425. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6426. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6427. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6428. private _resetVertexBufferBinding();
  6429. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  6430. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  6431. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  6432. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  6433. private _resetIndexBufferBinding();
  6434. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  6435. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  6436. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  6437. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  6438. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  6439. private bindIndexBuffer(buffer);
  6440. private bindBuffer(buffer, target);
  6441. updateArrayBuffer(data: Float32Array): void;
  6442. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  6443. private _bindIndexBufferWithCache(indexBuffer);
  6444. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  6445. recordVertexArrayObject(vertexBuffers: {
  6446. [key: string]: VertexBuffer;
  6447. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  6448. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  6449. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  6450. private _unbindVertexArrayObject();
  6451. bindBuffers(vertexBuffers: {
  6452. [key: string]: Nullable<VertexBuffer>;
  6453. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  6454. unbindInstanceAttributes(): void;
  6455. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  6456. _releaseBuffer(buffer: WebGLBuffer): boolean;
  6457. createInstancesBuffer(capacity: number): WebGLBuffer;
  6458. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  6459. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  6460. applyStates(): void;
  6461. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  6462. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6463. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  6465. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6466. private _drawMode(fillMode);
  6467. _releaseEffect(effect: Effect): void;
  6468. _deleteProgram(program: WebGLProgram): void;
  6469. /**
  6470. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  6471. * @param samplers An array of string used to represent textures
  6472. */
  6473. 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;
  6474. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  6475. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6476. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6477. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  6478. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  6479. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  6480. enableEffect(effect: Nullable<Effect>): void;
  6481. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6482. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6483. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6484. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6485. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6486. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6487. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6488. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6489. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6490. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6491. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6492. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6493. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  6494. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  6495. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  6496. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  6497. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  6498. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  6499. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  6500. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  6501. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  6502. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  6503. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  6504. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  6505. /**
  6506. * Sets a Color4 on a uniform variable
  6507. * @param uniform defines the uniform location
  6508. * @param color4 defines the value to be set
  6509. */
  6510. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  6511. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  6512. setZOffset(value: number): void;
  6513. getZOffset(): number;
  6514. setDepthBuffer(enable: boolean): void;
  6515. getDepthWrite(): boolean;
  6516. setDepthWrite(enable: boolean): void;
  6517. setColorWrite(enable: boolean): void;
  6518. getColorWrite(): boolean;
  6519. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  6520. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  6521. getAlphaMode(): number;
  6522. wipeCaches(bruteForce?: boolean): void;
  6523. /**
  6524. * Set the compressed texture format to use, based on the formats you have, and the formats
  6525. * supported by the hardware / browser.
  6526. *
  6527. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  6528. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  6529. * to API arguments needed to compressed textures. This puts the burden on the container
  6530. * generator to house the arcane code for determining these for current & future formats.
  6531. *
  6532. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  6533. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  6534. *
  6535. * Note: The result of this call is not taken into account when a texture is base64.
  6536. *
  6537. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  6538. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  6539. *
  6540. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  6541. * @returns The extension selected.
  6542. */
  6543. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  6544. _createTexture(): WebGLTexture;
  6545. /**
  6546. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  6547. * @param {string} urlArg- This contains one of the following:
  6548. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  6549. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  6550. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  6551. *
  6552. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  6553. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  6554. * @param {Scene} scene- Needed for loading to the correct scene.
  6555. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  6556. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  6557. * @param {callback} onError- Optional callback to be called upon failure.
  6558. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  6559. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  6560. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  6561. *
  6562. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  6563. */
  6564. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  6565. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  6566. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  6567. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  6568. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  6569. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  6570. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  6571. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  6572. /**
  6573. * Updates a depth texture Comparison Mode and Function.
  6574. * If the comparison Function is equal to 0, the mode will be set to none.
  6575. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  6576. * @param texture The texture to set the comparison function for
  6577. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  6578. */
  6579. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  6580. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  6581. /**
  6582. * Creates a depth stencil texture.
  6583. * This is only available in WebGL 2 or with the depth texture extension available.
  6584. * @param size The size of face edge in the texture.
  6585. * @param options The options defining the texture.
  6586. * @returns The texture
  6587. */
  6588. createDepthStencilTexture(size: number | {
  6589. width: number;
  6590. height: number;
  6591. }, options: DepthTextureCreationOptions): InternalTexture;
  6592. /**
  6593. * Creates a depth stencil texture.
  6594. * This is only available in WebGL 2 or with the depth texture extension available.
  6595. * @param size The size of face edge in the texture.
  6596. * @param options The options defining the texture.
  6597. * @returns The texture
  6598. */
  6599. private _createDepthStencilTexture(size, options);
  6600. /**
  6601. * Creates a depth stencil cube texture.
  6602. * This is only available in WebGL 2.
  6603. * @param size The size of face edge in the cube texture.
  6604. * @param options The options defining the cube texture.
  6605. * @returns The cube texture
  6606. */
  6607. private _createDepthStencilCubeTexture(size, options);
  6608. /**
  6609. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  6610. * @param renderTarget The render target to set the frame buffer for
  6611. */
  6612. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  6613. createRenderTargetTexture(size: number | {
  6614. width: number;
  6615. height: number;
  6616. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  6617. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  6618. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  6619. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  6620. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  6621. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  6622. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  6623. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  6624. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  6625. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  6626. private setCubeMapTextureParams(gl, loadMipmap);
  6627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  6628. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  6629. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  6630. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  6631. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  6632. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  6633. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  6634. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  6635. _releaseFramebufferObjects(texture: InternalTexture): void;
  6636. _releaseTexture(texture: InternalTexture): void;
  6637. private setProgram(program);
  6638. private _boundUniforms;
  6639. bindSamplers(effect: Effect): void;
  6640. private _moveBoundTextureOnTop(internalTexture);
  6641. private _getCorrectTextureChannel(channel, internalTexture);
  6642. private _linkTrackers(previous, next);
  6643. private _removeDesignatedSlot(internalTexture);
  6644. private _activateCurrentTexture();
  6645. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  6646. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  6647. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  6648. /**
  6649. * Binds the output of the passed in post process to the texture channel specified
  6650. * @param channel The channel the texture should be bound to
  6651. * @param postProcess The post process which's output should be bound
  6652. */
  6653. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  6654. unbindAllTextures(): void;
  6655. /**
  6656. * Sets a texture to the according uniform.
  6657. * @param channel The texture channel
  6658. * @param uniform The uniform to set
  6659. * @param texture The texture to apply
  6660. */
  6661. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  6662. /**
  6663. * Sets a depth stencil texture from a render target to the according uniform.
  6664. * @param channel The texture channel
  6665. * @param uniform The uniform to set
  6666. * @param texture The render target texture containing the depth stencil texture to apply
  6667. */
  6668. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  6669. private _bindSamplerUniformToChannel(sourceSlot, destination);
  6670. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  6671. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  6672. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  6673. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  6674. /**
  6675. * Add an externaly attached data from its key.
  6676. * This method call will fail and return false, if such key already exists.
  6677. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  6678. * @param key the unique key that identifies the data
  6679. * @param data the data object to associate to the key for this Engine instance
  6680. * @return true if no such key were already present and the data was added successfully, false otherwise
  6681. */
  6682. addExternalData<T>(key: string, data: T): boolean;
  6683. /**
  6684. * Get an externaly attached data from its key
  6685. * @param key the unique key that identifies the data
  6686. * @return the associated data, if present (can be null), or undefined if not present
  6687. */
  6688. getExternalData<T>(key: string): T;
  6689. /**
  6690. * Get an externaly attached data from its key, create it using a factory if it's not already present
  6691. * @param key the unique key that identifies the data
  6692. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  6693. * @return the associated data, can be null if the factory returned null.
  6694. */
  6695. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  6696. /**
  6697. * Remove an externaly attached data from the Engine instance
  6698. * @param key the unique key that identifies the data
  6699. * @return true if the data was successfully removed, false if it doesn't exist
  6700. */
  6701. removeExternalData(key: string): boolean;
  6702. unbindAllAttributes(): void;
  6703. releaseEffects(): void;
  6704. dispose(): void;
  6705. displayLoadingUI(): void;
  6706. hideLoadingUI(): void;
  6707. loadingScreen: ILoadingScreen;
  6708. loadingUIText: string;
  6709. loadingUIBackgroundColor: string;
  6710. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  6711. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  6712. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  6713. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  6714. getError(): number;
  6715. getFps(): number;
  6716. getDeltaTime(): number;
  6717. private _measureFps();
  6718. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  6719. private _canRenderToFloatFramebuffer();
  6720. private _canRenderToHalfFloatFramebuffer();
  6721. private _canRenderToFramebuffer(type);
  6722. _getWebGLTextureType(type: number): number;
  6723. private _getInternalFormat(format);
  6724. /** @ignore */
  6725. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  6726. _getRGBAMultiSampleBufferFormat(type: number): number;
  6727. createQuery(): WebGLQuery;
  6728. deleteQuery(query: WebGLQuery): Engine;
  6729. isQueryResultAvailable(query: WebGLQuery): boolean;
  6730. getQueryResult(query: WebGLQuery): number;
  6731. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  6732. endOcclusionQuery(algorithmType: number): Engine;
  6733. private _createTimeQuery();
  6734. private _deleteTimeQuery(query);
  6735. private _getTimeQueryResult(query);
  6736. private _getTimeQueryAvailability(query);
  6737. private _currentNonTimestampToken;
  6738. startTimeQuery(): Nullable<_TimeToken>;
  6739. endTimeQuery(token: _TimeToken): int;
  6740. private getGlAlgorithmType(algorithmType);
  6741. createTransformFeedback(): WebGLTransformFeedback;
  6742. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  6743. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  6744. beginTransformFeedback(usePoints?: boolean): void;
  6745. endTransformFeedback(): void;
  6746. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  6747. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  6748. _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;
  6749. /** @ignore */
  6750. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  6751. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  6752. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  6753. static isSupported(): boolean;
  6754. }
  6755. }
  6756. declare module BABYLON {
  6757. class NullEngineOptions {
  6758. renderWidth: number;
  6759. renderHeight: number;
  6760. textureSize: number;
  6761. deterministicLockstep: boolean;
  6762. lockstepMaxSteps: number;
  6763. }
  6764. /**
  6765. * The null engine class provides support for headless version of babylon.js.
  6766. * This can be used in server side scenario or for testing purposes
  6767. */
  6768. class NullEngine extends Engine {
  6769. private _options;
  6770. isDeterministicLockStep(): boolean;
  6771. getLockstepMaxSteps(): number;
  6772. getHardwareScalingLevel(): number;
  6773. constructor(options?: NullEngineOptions);
  6774. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  6775. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  6776. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6777. getRenderWidth(useScreen?: boolean): number;
  6778. getRenderHeight(useScreen?: boolean): number;
  6779. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6780. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  6781. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  6782. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  6783. bindSamplers(effect: Effect): void;
  6784. enableEffect(effect: Effect): void;
  6785. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  6786. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  6787. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  6788. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  6789. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  6790. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  6791. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  6792. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  6793. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  6794. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  6795. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  6796. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  6797. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  6798. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  6799. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  6800. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  6801. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  6802. setFloat(uniform: WebGLUniformLocation, value: number): void;
  6803. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  6804. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  6805. setBool(uniform: WebGLUniformLocation, bool: number): void;
  6806. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  6807. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  6808. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  6809. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  6810. bindBuffers(vertexBuffers: {
  6811. [key: string]: VertexBuffer;
  6812. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  6813. wipeCaches(bruteForce?: boolean): void;
  6814. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  6815. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  6816. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6817. _createTexture(): WebGLTexture;
  6818. 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;
  6819. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  6820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  6821. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  6822. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6823. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  6824. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  6825. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  6826. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  6827. _bindTexture(channel: number, texture: InternalTexture): void;
  6828. _releaseBuffer(buffer: WebGLBuffer): boolean;
  6829. }
  6830. }
  6831. interface WebGLRenderingContext {
  6832. readonly RASTERIZER_DISCARD: number;
  6833. readonly DEPTH_COMPONENT24: number;
  6834. readonly TEXTURE_3D: number;
  6835. readonly TEXTURE_2D_ARRAY: number;
  6836. readonly TEXTURE_COMPARE_FUNC: number;
  6837. readonly TEXTURE_COMPARE_MODE: number;
  6838. readonly COMPARE_REF_TO_TEXTURE: number;
  6839. readonly TEXTURE_WRAP_R: number;
  6840. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  6841. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  6842. 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;
  6843. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  6844. readonly TRANSFORM_FEEDBACK: number;
  6845. readonly INTERLEAVED_ATTRIBS: number;
  6846. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  6847. createTransformFeedback(): WebGLTransformFeedback;
  6848. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  6849. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  6850. beginTransformFeedback(primitiveMode: number): void;
  6851. endTransformFeedback(): void;
  6852. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  6853. }
  6854. interface ImageBitmap {
  6855. readonly width: number;
  6856. readonly height: number;
  6857. close(): void;
  6858. }
  6859. interface WebGLQuery extends WebGLObject {
  6860. }
  6861. declare var WebGLQuery: {
  6862. prototype: WebGLQuery;
  6863. new (): WebGLQuery;
  6864. };
  6865. interface WebGLSampler extends WebGLObject {
  6866. }
  6867. declare var WebGLSampler: {
  6868. prototype: WebGLSampler;
  6869. new (): WebGLSampler;
  6870. };
  6871. interface WebGLSync extends WebGLObject {
  6872. }
  6873. declare var WebGLSync: {
  6874. prototype: WebGLSync;
  6875. new (): WebGLSync;
  6876. };
  6877. interface WebGLTransformFeedback extends WebGLObject {
  6878. }
  6879. declare var WebGLTransformFeedback: {
  6880. prototype: WebGLTransformFeedback;
  6881. new (): WebGLTransformFeedback;
  6882. };
  6883. interface WebGLVertexArrayObject extends WebGLObject {
  6884. }
  6885. declare var WebGLVertexArrayObject: {
  6886. prototype: WebGLVertexArrayObject;
  6887. new (): WebGLVertexArrayObject;
  6888. };
  6889. declare module BABYLON {
  6890. class DebugLayer {
  6891. private _scene;
  6892. static InspectorURL: string;
  6893. private _inspector;
  6894. private BJSINSPECTOR;
  6895. constructor(scene: Scene);
  6896. /** Creates the inspector window. */
  6897. private _createInspector(config?);
  6898. isVisible(): boolean;
  6899. hide(): void;
  6900. show(config?: {
  6901. popup?: boolean;
  6902. initialTab?: number;
  6903. parentElement?: HTMLElement;
  6904. newColors?: {
  6905. backgroundColor?: string;
  6906. backgroundColorLighter?: string;
  6907. backgroundColorLighter2?: string;
  6908. backgroundColorLighter3?: string;
  6909. color?: string;
  6910. colorTop?: string;
  6911. colorBot?: string;
  6912. };
  6913. }): void;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. class Debug {
  6918. static AxesViewer: {
  6919. new (scene: Scene, scaleLines?: number): {
  6920. _xline: Vector3[];
  6921. _yline: Vector3[];
  6922. _zline: Vector3[];
  6923. _xmesh: Nullable<LinesMesh>;
  6924. _ymesh: Nullable<LinesMesh>;
  6925. _zmesh: Nullable<LinesMesh>;
  6926. scene: Nullable<Scene>;
  6927. scaleLines: number;
  6928. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6929. dispose(): void;
  6930. };
  6931. };
  6932. static BoneAxesViewer: {
  6933. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  6934. mesh: Nullable<Mesh>;
  6935. bone: Nullable<Bone>;
  6936. pos: Vector3;
  6937. xaxis: Vector3;
  6938. yaxis: Vector3;
  6939. zaxis: Vector3;
  6940. update(): void;
  6941. dispose(): void;
  6942. _xline: Vector3[];
  6943. _yline: Vector3[];
  6944. _zline: Vector3[];
  6945. _xmesh: Nullable<LinesMesh>;
  6946. _ymesh: Nullable<LinesMesh>;
  6947. _zmesh: Nullable<LinesMesh>;
  6948. scene: Nullable<Scene>;
  6949. scaleLines: number;
  6950. };
  6951. };
  6952. static PhysicsViewer: {
  6953. new (scene: Scene): {
  6954. _impostors: Nullable<PhysicsImpostor>[];
  6955. _meshes: Nullable<AbstractMesh>[];
  6956. _scene: Nullable<Scene>;
  6957. _numMeshes: number;
  6958. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6959. _renderFunction: () => void;
  6960. _debugBoxMesh: Mesh;
  6961. _debugSphereMesh: Mesh;
  6962. _debugMaterial: StandardMaterial;
  6963. _updateDebugMeshes(): void;
  6964. showImpostor(impostor: PhysicsImpostor): void;
  6965. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6966. _getDebugMaterial(scene: Scene): Material;
  6967. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  6968. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  6969. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  6970. dispose(): void;
  6971. };
  6972. };
  6973. static SkeletonViewer: {
  6974. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  6975. color: Color3;
  6976. _scene: Scene;
  6977. _debugLines: Vector3[][];
  6978. _debugMesh: Nullable<LinesMesh>;
  6979. _isEnabled: boolean;
  6980. _renderFunction: () => void;
  6981. skeleton: Skeleton;
  6982. mesh: AbstractMesh;
  6983. autoUpdateBonesMatrices: boolean;
  6984. renderingGroupId: number;
  6985. isEnabled: boolean;
  6986. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  6987. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  6988. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  6989. update(): void;
  6990. dispose(): void;
  6991. };
  6992. };
  6993. }
  6994. }
  6995. declare module BABYLON {
  6996. class RayHelper {
  6997. ray: Nullable<Ray>;
  6998. private _renderPoints;
  6999. private _renderLine;
  7000. private _renderFunction;
  7001. private _scene;
  7002. private _updateToMeshFunction;
  7003. private _attachedToMesh;
  7004. private _meshSpaceDirection;
  7005. private _meshSpaceOrigin;
  7006. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7007. constructor(ray: Ray);
  7008. show(scene: Scene, color: Color3): void;
  7009. hide(): void;
  7010. private _render();
  7011. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7012. detachFromMesh(): void;
  7013. private _updateToMesh();
  7014. dispose(): void;
  7015. }
  7016. }
  7017. declare module BABYLON {
  7018. class StickValues {
  7019. x: number;
  7020. y: number;
  7021. constructor(x: number, y: number);
  7022. }
  7023. interface GamepadButtonChanges {
  7024. changed: boolean;
  7025. pressChanged: boolean;
  7026. touchChanged: boolean;
  7027. valueChanged: boolean;
  7028. }
  7029. class Gamepad {
  7030. id: string;
  7031. index: number;
  7032. browserGamepad: any;
  7033. type: number;
  7034. private _leftStick;
  7035. private _rightStick;
  7036. _isConnected: boolean;
  7037. private _leftStickAxisX;
  7038. private _leftStickAxisY;
  7039. private _rightStickAxisX;
  7040. private _rightStickAxisY;
  7041. private _onleftstickchanged;
  7042. private _onrightstickchanged;
  7043. static GAMEPAD: number;
  7044. static GENERIC: number;
  7045. static XBOX: number;
  7046. static POSE_ENABLED: number;
  7047. protected _invertLeftStickY: boolean;
  7048. readonly isConnected: boolean;
  7049. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  7050. onleftstickchanged(callback: (values: StickValues) => void): void;
  7051. onrightstickchanged(callback: (values: StickValues) => void): void;
  7052. leftStick: StickValues;
  7053. rightStick: StickValues;
  7054. update(): void;
  7055. dispose(): void;
  7056. }
  7057. class GenericPad extends Gamepad {
  7058. private _buttons;
  7059. private _onbuttondown;
  7060. private _onbuttonup;
  7061. onButtonDownObservable: Observable<number>;
  7062. onButtonUpObservable: Observable<number>;
  7063. onbuttondown(callback: (buttonPressed: number) => void): void;
  7064. onbuttonup(callback: (buttonReleased: number) => void): void;
  7065. constructor(id: string, index: number, browserGamepad: any);
  7066. private _setButtonValue(newValue, currentValue, buttonIndex);
  7067. update(): void;
  7068. dispose(): void;
  7069. }
  7070. }
  7071. declare module BABYLON {
  7072. class GamepadManager {
  7073. private _scene;
  7074. private _babylonGamepads;
  7075. private _oneGamepadConnected;
  7076. _isMonitoring: boolean;
  7077. private _gamepadEventSupported;
  7078. private _gamepadSupport;
  7079. onGamepadConnectedObservable: Observable<Gamepad>;
  7080. onGamepadDisconnectedObservable: Observable<Gamepad>;
  7081. private _onGamepadConnectedEvent;
  7082. private _onGamepadDisconnectedEvent;
  7083. constructor(_scene?: Scene | undefined);
  7084. readonly gamepads: Gamepad[];
  7085. getGamepadByType(type?: number): Nullable<Gamepad>;
  7086. dispose(): void;
  7087. private _addNewGamepad(gamepad);
  7088. private _startMonitoringGamepads();
  7089. private _stopMonitoringGamepads();
  7090. _checkGamepadsStatus(): void;
  7091. private _updateGamepadObjects();
  7092. }
  7093. }
  7094. declare module BABYLON {
  7095. enum Xbox360Button {
  7096. A = 0,
  7097. B = 1,
  7098. X = 2,
  7099. Y = 3,
  7100. Start = 4,
  7101. Back = 5,
  7102. LB = 6,
  7103. RB = 7,
  7104. LeftStick = 8,
  7105. RightStick = 9,
  7106. }
  7107. enum Xbox360Dpad {
  7108. Up = 0,
  7109. Down = 1,
  7110. Left = 2,
  7111. Right = 3,
  7112. }
  7113. class Xbox360Pad extends Gamepad {
  7114. private _leftTrigger;
  7115. private _rightTrigger;
  7116. private _onlefttriggerchanged;
  7117. private _onrighttriggerchanged;
  7118. private _onbuttondown;
  7119. private _onbuttonup;
  7120. private _ondpaddown;
  7121. private _ondpadup;
  7122. onButtonDownObservable: Observable<Xbox360Button>;
  7123. onButtonUpObservable: Observable<Xbox360Button>;
  7124. onPadDownObservable: Observable<Xbox360Dpad>;
  7125. onPadUpObservable: Observable<Xbox360Dpad>;
  7126. private _buttonA;
  7127. private _buttonB;
  7128. private _buttonX;
  7129. private _buttonY;
  7130. private _buttonBack;
  7131. private _buttonStart;
  7132. private _buttonLB;
  7133. private _buttonRB;
  7134. private _buttonLeftStick;
  7135. private _buttonRightStick;
  7136. private _dPadUp;
  7137. private _dPadDown;
  7138. private _dPadLeft;
  7139. private _dPadRight;
  7140. private _isXboxOnePad;
  7141. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  7142. onlefttriggerchanged(callback: (value: number) => void): void;
  7143. onrighttriggerchanged(callback: (value: number) => void): void;
  7144. leftTrigger: number;
  7145. rightTrigger: number;
  7146. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  7147. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  7148. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  7149. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  7150. private _setButtonValue(newValue, currentValue, buttonType);
  7151. private _setDPadValue(newValue, currentValue, buttonType);
  7152. buttonA: number;
  7153. buttonB: number;
  7154. buttonX: number;
  7155. buttonY: number;
  7156. buttonStart: number;
  7157. buttonBack: number;
  7158. buttonLB: number;
  7159. buttonRB: number;
  7160. buttonLeftStick: number;
  7161. buttonRightStick: number;
  7162. dPadUp: number;
  7163. dPadDown: number;
  7164. dPadLeft: number;
  7165. dPadRight: number;
  7166. update(): void;
  7167. dispose(): void;
  7168. }
  7169. }
  7170. declare module BABYLON {
  7171. /**
  7172. * Represents the different options available during the creation of
  7173. * a Environment helper.
  7174. *
  7175. * This can control the default ground, skybox and image processing setup of your scene.
  7176. */
  7177. interface IEnvironmentHelperOptions {
  7178. /**
  7179. * Specifies wether or not to create a ground.
  7180. * True by default.
  7181. */
  7182. createGround: boolean;
  7183. /**
  7184. * Specifies the ground size.
  7185. * 15 by default.
  7186. */
  7187. groundSize: number;
  7188. /**
  7189. * The texture used on the ground for the main color.
  7190. * Comes from the BabylonJS CDN by default.
  7191. *
  7192. * Remarks: Can be either a texture or a url.
  7193. */
  7194. groundTexture: string | BaseTexture;
  7195. /**
  7196. * The color mixed in the ground texture by default.
  7197. * BabylonJS clearColor by default.
  7198. */
  7199. groundColor: Color3;
  7200. /**
  7201. * Specifies the ground opacity.
  7202. * 1 by default.
  7203. */
  7204. groundOpacity: number;
  7205. /**
  7206. * Enables the ground to receive shadows.
  7207. * True by default.
  7208. */
  7209. enableGroundShadow: boolean;
  7210. /**
  7211. * Helps preventing the shadow to be fully black on the ground.
  7212. * 0.5 by default.
  7213. */
  7214. groundShadowLevel: number;
  7215. /**
  7216. * Creates a mirror texture attach to the ground.
  7217. * false by default.
  7218. */
  7219. enableGroundMirror: boolean;
  7220. /**
  7221. * Specifies the ground mirror size ratio.
  7222. * 0.3 by default as the default kernel is 64.
  7223. */
  7224. groundMirrorSizeRatio: number;
  7225. /**
  7226. * Specifies the ground mirror blur kernel size.
  7227. * 64 by default.
  7228. */
  7229. groundMirrorBlurKernel: number;
  7230. /**
  7231. * Specifies the ground mirror visibility amount.
  7232. * 1 by default
  7233. */
  7234. groundMirrorAmount: number;
  7235. /**
  7236. * Specifies the ground mirror reflectance weight.
  7237. * This uses the standard weight of the background material to setup the fresnel effect
  7238. * of the mirror.
  7239. * 1 by default.
  7240. */
  7241. groundMirrorFresnelWeight: number;
  7242. /**
  7243. * Specifies the ground mirror Falloff distance.
  7244. * This can helps reducing the size of the reflection.
  7245. * 0 by Default.
  7246. */
  7247. groundMirrorFallOffDistance: number;
  7248. /**
  7249. * Specifies the ground mirror texture type.
  7250. * Unsigned Int by Default.
  7251. */
  7252. groundMirrorTextureType: number;
  7253. /**
  7254. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  7255. * the shown objects.
  7256. */
  7257. groundYBias: number;
  7258. /**
  7259. * Specifies wether or not to create a skybox.
  7260. * True by default.
  7261. */
  7262. createSkybox: boolean;
  7263. /**
  7264. * Specifies the skybox size.
  7265. * 20 by default.
  7266. */
  7267. skyboxSize: number;
  7268. /**
  7269. * The texture used on the skybox for the main color.
  7270. * Comes from the BabylonJS CDN by default.
  7271. *
  7272. * Remarks: Can be either a texture or a url.
  7273. */
  7274. skyboxTexture: string | BaseTexture;
  7275. /**
  7276. * The color mixed in the skybox texture by default.
  7277. * BabylonJS clearColor by default.
  7278. */
  7279. skyboxColor: Color3;
  7280. /**
  7281. * The background rotation around the Y axis of the scene.
  7282. * This helps aligning the key lights of your scene with the background.
  7283. * 0 by default.
  7284. */
  7285. backgroundYRotation: number;
  7286. /**
  7287. * Compute automatically the size of the elements to best fit with the scene.
  7288. */
  7289. sizeAuto: boolean;
  7290. /**
  7291. * Default position of the rootMesh if autoSize is not true.
  7292. */
  7293. rootPosition: Vector3;
  7294. /**
  7295. * Sets up the image processing in the scene.
  7296. * true by default.
  7297. */
  7298. setupImageProcessing: boolean;
  7299. /**
  7300. * The texture used as your environment texture in the scene.
  7301. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  7302. *
  7303. * Remarks: Can be either a texture or a url.
  7304. */
  7305. environmentTexture: string | BaseTexture;
  7306. /**
  7307. * The value of the exposure to apply to the scene.
  7308. * 0.6 by default if setupImageProcessing is true.
  7309. */
  7310. cameraExposure: number;
  7311. /**
  7312. * The value of the contrast to apply to the scene.
  7313. * 1.6 by default if setupImageProcessing is true.
  7314. */
  7315. cameraContrast: number;
  7316. /**
  7317. * Specifies wether or not tonemapping should be enabled in the scene.
  7318. * true by default if setupImageProcessing is true.
  7319. */
  7320. toneMappingEnabled: boolean;
  7321. }
  7322. /**
  7323. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  7324. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  7325. * It also helps with the default setup of your imageProcessing configuration.
  7326. */
  7327. class EnvironmentHelper {
  7328. /**
  7329. * Default ground texture URL.
  7330. */
  7331. private static _groundTextureCDNUrl;
  7332. /**
  7333. * Default skybox texture URL.
  7334. */
  7335. private static _skyboxTextureCDNUrl;
  7336. /**
  7337. * Default environment texture URL.
  7338. */
  7339. private static _environmentTextureCDNUrl;
  7340. /**
  7341. * Creates the default options for the helper.
  7342. */
  7343. private static _getDefaultOptions();
  7344. private _rootMesh;
  7345. /**
  7346. * Gets the root mesh created by the helper.
  7347. */
  7348. readonly rootMesh: Mesh;
  7349. private _skybox;
  7350. /**
  7351. * Gets the skybox created by the helper.
  7352. */
  7353. readonly skybox: Nullable<Mesh>;
  7354. private _skyboxTexture;
  7355. /**
  7356. * Gets the skybox texture created by the helper.
  7357. */
  7358. readonly skyboxTexture: Nullable<BaseTexture>;
  7359. private _skyboxMaterial;
  7360. /**
  7361. * Gets the skybox material created by the helper.
  7362. */
  7363. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  7364. private _ground;
  7365. /**
  7366. * Gets the ground mesh created by the helper.
  7367. */
  7368. readonly ground: Nullable<Mesh>;
  7369. private _groundTexture;
  7370. /**
  7371. * Gets the ground texture created by the helper.
  7372. */
  7373. readonly groundTexture: Nullable<BaseTexture>;
  7374. private _groundMirror;
  7375. /**
  7376. * Gets the ground mirror created by the helper.
  7377. */
  7378. readonly groundMirror: Nullable<MirrorTexture>;
  7379. /**
  7380. * Gets the ground mirror render list to helps pushing the meshes
  7381. * you wish in the ground reflection.
  7382. */
  7383. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  7384. private _groundMaterial;
  7385. /**
  7386. * Gets the ground material created by the helper.
  7387. */
  7388. readonly groundMaterial: Nullable<BackgroundMaterial>;
  7389. /**
  7390. * Stores the creation options.
  7391. */
  7392. private readonly _scene;
  7393. private _options;
  7394. /**
  7395. * This observable will be notified with any error during the creation of the environment,
  7396. * mainly texture creation errors.
  7397. */
  7398. onErrorObservable: Observable<{
  7399. message?: string;
  7400. exception?: any;
  7401. }>;
  7402. /**
  7403. * constructor
  7404. * @param options
  7405. * @param scene The scene to add the material to
  7406. */
  7407. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  7408. /**
  7409. * Updates the background according to the new options
  7410. * @param options
  7411. */
  7412. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  7413. /**
  7414. * Sets the primary color of all the available elements.
  7415. * @param color
  7416. */
  7417. setMainColor(color: Color3): void;
  7418. /**
  7419. * Setup the image processing according to the specified options.
  7420. */
  7421. private _setupImageProcessing();
  7422. /**
  7423. * Setup the environment texture according to the specified options.
  7424. */
  7425. private _setupEnvironmentTexture();
  7426. /**
  7427. * Setup the background according to the specified options.
  7428. */
  7429. private _setupBackground();
  7430. /**
  7431. * Get the scene sizes according to the setup.
  7432. */
  7433. private _getSceneSize();
  7434. /**
  7435. * Setup the ground according to the specified options.
  7436. */
  7437. private _setupGround(sceneSize);
  7438. /**
  7439. * Setup the ground material according to the specified options.
  7440. */
  7441. private _setupGroundMaterial();
  7442. /**
  7443. * Setup the ground diffuse texture according to the specified options.
  7444. */
  7445. private _setupGroundDiffuseTexture();
  7446. /**
  7447. * Setup the ground mirror texture according to the specified options.
  7448. */
  7449. private _setupGroundMirrorTexture(sceneSize);
  7450. /**
  7451. * Setup the ground to receive the mirror texture.
  7452. */
  7453. private _setupMirrorInGroundMaterial();
  7454. /**
  7455. * Setup the skybox according to the specified options.
  7456. */
  7457. private _setupSkybox(sceneSize);
  7458. /**
  7459. * Setup the skybox material according to the specified options.
  7460. */
  7461. private _setupSkyboxMaterial();
  7462. /**
  7463. * Setup the skybox reflection texture according to the specified options.
  7464. */
  7465. private _setupSkyboxReflectionTexture();
  7466. private _errorHandler;
  7467. /**
  7468. * Dispose all the elements created by the Helper.
  7469. */
  7470. dispose(): void;
  7471. }
  7472. }
  7473. declare module BABYLON {
  7474. /**
  7475. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  7476. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  7477. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  7478. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  7479. */
  7480. class VideoDome extends Node {
  7481. /**
  7482. * The video texture being displayed on the sphere
  7483. */
  7484. protected _videoTexture: VideoTexture;
  7485. /**
  7486. * The skybox material
  7487. */
  7488. protected _material: BackgroundMaterial;
  7489. /**
  7490. * The surface used for the skybox
  7491. */
  7492. protected _mesh: Mesh;
  7493. /**
  7494. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  7495. * Also see the options.resolution property.
  7496. */
  7497. fovMultiplier: number;
  7498. /**
  7499. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  7500. * @param name Element's name, child elements will append suffixes for their own names.
  7501. * @param urlsOrVideo
  7502. * @param options An object containing optional or exposed sub element properties:
  7503. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  7504. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  7505. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  7506. * @param options **loop=true** Automatically loop video on end.
  7507. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  7508. */
  7509. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  7510. resolution?: number;
  7511. clickToPlay?: boolean;
  7512. autoPlay?: boolean;
  7513. loop?: boolean;
  7514. size?: number;
  7515. }, scene: Scene);
  7516. /**
  7517. * Releases resources associated with this node.
  7518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7520. */
  7521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. class LensFlare {
  7526. size: number;
  7527. position: number;
  7528. color: Color3;
  7529. texture: Nullable<Texture>;
  7530. alphaMode: number;
  7531. private _system;
  7532. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  7533. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  7534. dispose(): void;
  7535. }
  7536. }
  7537. declare module BABYLON {
  7538. class LensFlareSystem {
  7539. name: string;
  7540. lensFlares: LensFlare[];
  7541. borderLimit: number;
  7542. viewportBorder: number;
  7543. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  7544. layerMask: number;
  7545. id: string;
  7546. private _scene;
  7547. private _emitter;
  7548. private _vertexBuffers;
  7549. private _indexBuffer;
  7550. private _effect;
  7551. private _positionX;
  7552. private _positionY;
  7553. private _isEnabled;
  7554. constructor(name: string, emitter: any, scene: Scene);
  7555. isEnabled: boolean;
  7556. getScene(): Scene;
  7557. getEmitter(): any;
  7558. setEmitter(newEmitter: any): void;
  7559. getEmitterPosition(): Vector3;
  7560. computeEffectivePosition(globalViewport: Viewport): boolean;
  7561. _isVisible(): boolean;
  7562. render(): boolean;
  7563. dispose(): void;
  7564. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  7565. serialize(): any;
  7566. }
  7567. }
  7568. declare module BABYLON {
  7569. /**
  7570. * A directional light is defined by a direction (what a surprise!).
  7571. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  7572. * 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.
  7573. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7574. */
  7575. class DirectionalLight extends ShadowLight {
  7576. private _shadowFrustumSize;
  7577. /**
  7578. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  7579. */
  7580. /**
  7581. * Specifies a fix frustum size for the shadow generation.
  7582. */
  7583. shadowFrustumSize: number;
  7584. private _shadowOrthoScale;
  7585. /**
  7586. * Gets the shadow projection scale against the optimal computed one.
  7587. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  7588. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  7589. */
  7590. /**
  7591. * Sets the shadow projection scale against the optimal computed one.
  7592. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  7593. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  7594. */
  7595. shadowOrthoScale: number;
  7596. /**
  7597. * Automatically compute the projection matrix to best fit (including all the casters)
  7598. * on each frame.
  7599. */
  7600. autoUpdateExtends: boolean;
  7601. private _orthoLeft;
  7602. private _orthoRight;
  7603. private _orthoTop;
  7604. private _orthoBottom;
  7605. /**
  7606. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  7607. * The directional light is emitted from everywhere in the given direction.
  7608. * It can cast shawdows.
  7609. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7610. * @param name The friendly name of the light
  7611. * @param direction The direction of the light
  7612. * @param scene The scene the light belongs to
  7613. */
  7614. constructor(name: string, direction: Vector3, scene: Scene);
  7615. /**
  7616. * Returns the string "DirectionalLight".
  7617. * @return The class name
  7618. */
  7619. getClassName(): string;
  7620. /**
  7621. * Returns the integer 1.
  7622. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7623. */
  7624. getTypeID(): number;
  7625. /**
  7626. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  7627. * Returns the DirectionalLight Shadow projection matrix.
  7628. */
  7629. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7630. /**
  7631. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  7632. * Returns the DirectionalLight Shadow projection matrix.
  7633. */
  7634. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  7635. /**
  7636. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  7637. * Returns the DirectionalLight Shadow projection matrix.
  7638. */
  7639. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7640. protected _buildUniformLayout(): void;
  7641. /**
  7642. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  7643. * @param effect The effect to update
  7644. * @param lightIndex The index of the light in the effect to update
  7645. * @returns The directional light
  7646. */
  7647. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  7648. /**
  7649. * Gets the minZ used for shadow according to both the scene and the light.
  7650. *
  7651. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  7652. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  7653. * @param activeCamera The camera we are returning the min for
  7654. * @returns the depth min z
  7655. */
  7656. getDepthMinZ(activeCamera: Camera): number;
  7657. /**
  7658. * Gets the maxZ used for shadow according to both the scene and the light.
  7659. *
  7660. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  7661. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  7662. * @param activeCamera The camera we are returning the max for
  7663. * @returns the depth max z
  7664. */
  7665. getDepthMaxZ(activeCamera: Camera): number;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. /**
  7670. * The HemisphericLight simulates the ambient environment light,
  7671. * so the passed direction is the light reflection direction, not the incoming direction.
  7672. */
  7673. class HemisphericLight extends Light {
  7674. /**
  7675. * The groundColor is the light in the opposite direction to the one specified during creation.
  7676. * 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.
  7677. */
  7678. groundColor: Color3;
  7679. /**
  7680. * The light reflection direction, not the incoming direction.
  7681. */
  7682. direction: Vector3;
  7683. private _worldMatrix;
  7684. /**
  7685. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  7686. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  7687. * The HemisphericLight can't cast shadows.
  7688. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7689. * @param name The friendly name of the light
  7690. * @param direction The direction of the light reflection
  7691. * @param scene The scene the light belongs to
  7692. */
  7693. constructor(name: string, direction: Vector3, scene: Scene);
  7694. protected _buildUniformLayout(): void;
  7695. /**
  7696. * Returns the string "HemisphericLight".
  7697. * @return The class name
  7698. */
  7699. getClassName(): string;
  7700. /**
  7701. * Sets the HemisphericLight direction towards the passed target (Vector3).
  7702. * Returns the updated direction.
  7703. * @param target The target the direction should point to
  7704. * @return The computed direction
  7705. */
  7706. setDirectionToTarget(target: Vector3): Vector3;
  7707. /**
  7708. * Returns the shadow generator associated to the light.
  7709. * @returns Always null for hemispheric lights because it does not support shadows.
  7710. */
  7711. getShadowGenerator(): Nullable<ShadowGenerator>;
  7712. /**
  7713. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  7714. * @param effect The effect to update
  7715. * @param lightIndex The index of the light in the effect to update
  7716. * @returns The hemispheric light
  7717. */
  7718. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  7719. /**
  7720. * @ignore internal use only.
  7721. */
  7722. _getWorldMatrix(): Matrix;
  7723. /**
  7724. * Returns the integer 3.
  7725. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7726. */
  7727. getTypeID(): number;
  7728. }
  7729. }
  7730. declare module BABYLON {
  7731. /**
  7732. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  7733. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  7734. * 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.
  7735. */
  7736. abstract class Light extends Node {
  7737. private static _LIGHTMAP_DEFAULT;
  7738. private static _LIGHTMAP_SPECULAR;
  7739. private static _LIGHTMAP_SHADOWSONLY;
  7740. /**
  7741. * If every light affecting the material is in this lightmapMode,
  7742. * material.lightmapTexture adds or multiplies
  7743. * (depends on material.useLightmapAsShadowmap)
  7744. * after every other light calculations.
  7745. */
  7746. static readonly LIGHTMAP_DEFAULT: number;
  7747. /**
  7748. * material.lightmapTexture as only diffuse lighting from this light
  7749. * adds only specular lighting from this light
  7750. * adds dynamic shadows
  7751. */
  7752. static readonly LIGHTMAP_SPECULAR: number;
  7753. /**
  7754. * material.lightmapTexture as only lighting
  7755. * no light calculation from this light
  7756. * only adds dynamic shadows from this light
  7757. */
  7758. static readonly LIGHTMAP_SHADOWSONLY: number;
  7759. private static _INTENSITYMODE_AUTOMATIC;
  7760. private static _INTENSITYMODE_LUMINOUSPOWER;
  7761. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  7762. private static _INTENSITYMODE_ILLUMINANCE;
  7763. private static _INTENSITYMODE_LUMINANCE;
  7764. /**
  7765. * Each light type uses the default quantity according to its type:
  7766. * point/spot lights use luminous intensity
  7767. * directional lights use illuminance
  7768. */
  7769. static readonly INTENSITYMODE_AUTOMATIC: number;
  7770. /**
  7771. * lumen (lm)
  7772. */
  7773. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  7774. /**
  7775. * candela (lm/sr)
  7776. */
  7777. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  7778. /**
  7779. * lux (lm/m^2)
  7780. */
  7781. static readonly INTENSITYMODE_ILLUMINANCE: number;
  7782. /**
  7783. * nit (cd/m^2)
  7784. */
  7785. static readonly INTENSITYMODE_LUMINANCE: number;
  7786. private static _LIGHTTYPEID_POINTLIGHT;
  7787. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  7788. private static _LIGHTTYPEID_SPOTLIGHT;
  7789. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  7790. /**
  7791. * Light type const id of the point light.
  7792. */
  7793. static readonly LIGHTTYPEID_POINTLIGHT: number;
  7794. /**
  7795. * Light type const id of the directional light.
  7796. */
  7797. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  7798. /**
  7799. * Light type const id of the spot light.
  7800. */
  7801. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  7802. /**
  7803. * Light type const id of the hemispheric light.
  7804. */
  7805. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  7806. /**
  7807. * Diffuse gives the basic color to an object.
  7808. */
  7809. diffuse: Color3;
  7810. /**
  7811. * Specular produces a highlight color on an object.
  7812. * Note: This is note affecting PBR materials.
  7813. */
  7814. specular: Color3;
  7815. /**
  7816. * Strength of the light.
  7817. * Note: By default it is define in the framework own unit.
  7818. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  7819. */
  7820. intensity: number;
  7821. /**
  7822. * Defines how far from the source the light is impacting in scene units.
  7823. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  7824. */
  7825. range: number;
  7826. /**
  7827. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  7828. * of light.
  7829. */
  7830. private _photometricScale;
  7831. private _intensityMode;
  7832. /**
  7833. * Gets the photometric scale used to interpret the intensity.
  7834. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7835. */
  7836. /**
  7837. * Sets the photometric scale used to interpret the intensity.
  7838. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7839. */
  7840. intensityMode: number;
  7841. private _radius;
  7842. /**
  7843. * Gets the light radius used by PBR Materials to simulate soft area lights.
  7844. */
  7845. /**
  7846. * sets the light radius used by PBR Materials to simulate soft area lights.
  7847. */
  7848. radius: number;
  7849. private _renderPriority;
  7850. /**
  7851. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  7852. * exceeding the number allowed of the materials.
  7853. */
  7854. renderPriority: number;
  7855. /**
  7856. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  7857. * the current shadow generator.
  7858. */
  7859. shadowEnabled: boolean;
  7860. private _includedOnlyMeshes;
  7861. /**
  7862. * Gets the only meshes impacted by this light.
  7863. */
  7864. /**
  7865. * Sets the only meshes impacted by this light.
  7866. */
  7867. includedOnlyMeshes: AbstractMesh[];
  7868. private _excludedMeshes;
  7869. /**
  7870. * Gets the meshes not impacted by this light.
  7871. */
  7872. /**
  7873. * Sets the meshes not impacted by this light.
  7874. */
  7875. excludedMeshes: AbstractMesh[];
  7876. private _excludeWithLayerMask;
  7877. /**
  7878. * Gets the layer id use to find what meshes are not impacted by the light.
  7879. * Inactive if 0
  7880. */
  7881. /**
  7882. * Sets the layer id use to find what meshes are not impacted by the light.
  7883. * Inactive if 0
  7884. */
  7885. excludeWithLayerMask: number;
  7886. private _includeOnlyWithLayerMask;
  7887. /**
  7888. * Gets the layer id use to find what meshes are impacted by the light.
  7889. * Inactive if 0
  7890. */
  7891. /**
  7892. * Sets the layer id use to find what meshes are impacted by the light.
  7893. * Inactive if 0
  7894. */
  7895. includeOnlyWithLayerMask: number;
  7896. private _lightmapMode;
  7897. /**
  7898. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7899. */
  7900. /**
  7901. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7902. */
  7903. lightmapMode: number;
  7904. private _parentedWorldMatrix;
  7905. /**
  7906. * Shadow generator associted to the light.
  7907. * Internal use only.
  7908. */
  7909. _shadowGenerator: Nullable<IShadowGenerator>;
  7910. /**
  7911. * @ignore Internal use only.
  7912. */
  7913. _excludedMeshesIds: string[];
  7914. /**
  7915. * @ignore Internal use only.
  7916. */
  7917. _includedOnlyMeshesIds: string[];
  7918. /**
  7919. * The current light unifom buffer.
  7920. * @ignore Internal use only.
  7921. */
  7922. _uniformBuffer: UniformBuffer;
  7923. /**
  7924. * Creates a Light object in the scene.
  7925. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7926. * @param name The firendly name of the light
  7927. * @param scene The scene the light belongs too
  7928. */
  7929. constructor(name: string, scene: Scene);
  7930. protected abstract _buildUniformLayout(): void;
  7931. /**
  7932. * Sets the passed Effect "effect" with the Light information.
  7933. * @param effect The effect to update
  7934. * @param lightIndex The index of the light in the effect to update
  7935. * @returns The light
  7936. */
  7937. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  7938. /**
  7939. * @ignore internal use only.
  7940. */
  7941. abstract _getWorldMatrix(): Matrix;
  7942. /**
  7943. * Returns the string "Light".
  7944. * @returns the class name
  7945. */
  7946. getClassName(): string;
  7947. /**
  7948. * Converts the light information to a readable string for debug purpose.
  7949. * @param fullDetails Supports for multiple levels of logging within scene loading
  7950. * @returns the human readable light info
  7951. */
  7952. toString(fullDetails?: boolean): string;
  7953. /**
  7954. * Set the enabled state of this node.
  7955. * @param value - the new enabled state
  7956. */
  7957. setEnabled(value: boolean): void;
  7958. /**
  7959. * Returns the Light associated shadow generator if any.
  7960. * @return the associated shadow generator.
  7961. */
  7962. getShadowGenerator(): Nullable<IShadowGenerator>;
  7963. /**
  7964. * Returns a Vector3, the absolute light position in the World.
  7965. * @returns the world space position of the light
  7966. */
  7967. getAbsolutePosition(): Vector3;
  7968. /**
  7969. * Specifies if the light will affect the passed mesh.
  7970. * @param mesh The mesh to test against the light
  7971. * @return true the mesh is affected otherwise, false.
  7972. */
  7973. canAffectMesh(mesh: AbstractMesh): boolean;
  7974. /**
  7975. * Computes and Returns the light World matrix.
  7976. * @returns the world matrix
  7977. */
  7978. getWorldMatrix(): Matrix;
  7979. /**
  7980. * Sort function to order lights for rendering.
  7981. * @param a First Light object to compare to second.
  7982. * @param b Second Light object to compare first.
  7983. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  7984. */
  7985. static CompareLightsPriority(a: Light, b: Light): number;
  7986. /**
  7987. * Releases resources associated with this node.
  7988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7990. */
  7991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7992. /**
  7993. * Returns the light type ID (integer).
  7994. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7995. */
  7996. getTypeID(): number;
  7997. /**
  7998. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  7999. * @returns the scaled intensity in intensity mode unit
  8000. */
  8001. getScaledIntensity(): number;
  8002. /**
  8003. * Returns a new Light object, named "name", from the current one.
  8004. * @param name The name of the cloned light
  8005. * @returns the new created light
  8006. */
  8007. clone(name: string): Nullable<Light>;
  8008. /**
  8009. * Serializes the current light into a Serialization object.
  8010. * @returns the serialized object.
  8011. */
  8012. serialize(): any;
  8013. /**
  8014. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8015. * This new light is named "name" and added to the passed scene.
  8016. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8017. * @param name The friendly name of the light
  8018. * @param scene The scene the new light will belong to
  8019. * @returns the constructor function
  8020. */
  8021. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8022. /**
  8023. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8024. * @param parsedLight The JSON representation of the light
  8025. * @param scene The scene to create the parsed light in
  8026. * @returns the created light after parsing
  8027. */
  8028. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8029. private _hookArrayForExcluded(array);
  8030. private _hookArrayForIncludedOnly(array);
  8031. private _resyncMeshes();
  8032. /**
  8033. * Forces the meshes to update their light related information in their rendering used effects
  8034. * @ignore Internal Use Only
  8035. */
  8036. _markMeshesAsLightDirty(): void;
  8037. /**
  8038. * Recomputes the cached photometric scale if needed.
  8039. */
  8040. private _computePhotometricScale();
  8041. /**
  8042. * Returns the Photometric Scale according to the light type and intensity mode.
  8043. */
  8044. private _getPhotometricScale();
  8045. /**
  8046. * Reorder the light in the scene according to their defined priority.
  8047. * @ignore Internal Use Only
  8048. */
  8049. _reorderLightsInScene(): void;
  8050. }
  8051. }
  8052. declare module BABYLON {
  8053. /**
  8054. * A point light is a light defined by an unique point in world space.
  8055. * The light is emitted in every direction from this point.
  8056. * A good example of a point light is a standard light bulb.
  8057. * Documentation: https://doc.babylonjs.com/babylon101/lights
  8058. */
  8059. class PointLight extends ShadowLight {
  8060. private _shadowAngle;
  8061. /**
  8062. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8063. * This specifies what angle the shadow will use to be created.
  8064. *
  8065. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  8066. */
  8067. /**
  8068. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8069. * This specifies what angle the shadow will use to be created.
  8070. *
  8071. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  8072. */
  8073. shadowAngle: number;
  8074. /**
  8075. * Gets the direction if it has been set.
  8076. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8077. */
  8078. /**
  8079. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  8080. */
  8081. direction: Vector3;
  8082. /**
  8083. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  8084. * A PointLight emits the light in every direction.
  8085. * It can cast shadows.
  8086. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  8087. * ```javascript
  8088. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  8089. * ```
  8090. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8091. * @param name The light friendly name
  8092. * @param position The position of the point light in the scene
  8093. * @param scene The scene the lights belongs to
  8094. */
  8095. constructor(name: string, position: Vector3, scene: Scene);
  8096. /**
  8097. * Returns the string "PointLight"
  8098. * @returns the class name
  8099. */
  8100. getClassName(): string;
  8101. /**
  8102. * Returns the integer 0.
  8103. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8104. */
  8105. getTypeID(): number;
  8106. /**
  8107. * Specifies wether or not the shadowmap should be a cube texture.
  8108. * @returns true if the shadowmap needs to be a cube texture.
  8109. */
  8110. needCube(): boolean;
  8111. /**
  8112. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  8113. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8114. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8115. */
  8116. getShadowDirection(faceIndex?: number): Vector3;
  8117. /**
  8118. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  8119. * - fov = PI / 2
  8120. * - aspect ratio : 1.0
  8121. * - z-near and far equal to the active camera minZ and maxZ.
  8122. * Returns the PointLight.
  8123. */
  8124. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8125. protected _buildUniformLayout(): void;
  8126. /**
  8127. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  8128. * @param effect The effect to update
  8129. * @param lightIndex The index of the light in the effect to update
  8130. * @returns The point light
  8131. */
  8132. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  8133. }
  8134. }
  8135. declare module BABYLON {
  8136. /**
  8137. * Interface describing all the common properties and methods a shadow light needs to implement.
  8138. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8139. * as well as binding the different shadow properties to the effects.
  8140. */
  8141. interface IShadowLight extends Light {
  8142. /**
  8143. * The light id in the scene (used in scene.findLighById for instance)
  8144. */
  8145. id: string;
  8146. /**
  8147. * The position the shdow will be casted from.
  8148. */
  8149. position: Vector3;
  8150. /**
  8151. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8152. */
  8153. direction: Vector3;
  8154. /**
  8155. * The transformed position. Position of the light in world space taking parenting in account.
  8156. */
  8157. transformedPosition: Vector3;
  8158. /**
  8159. * The transformed direction. Direction of the light in world space taking parenting in account.
  8160. */
  8161. transformedDirection: Vector3;
  8162. /**
  8163. * The friendly name of the light in the scene.
  8164. */
  8165. name: string;
  8166. /**
  8167. * Defines the shadow projection clipping minimum z value.
  8168. */
  8169. shadowMinZ: number;
  8170. /**
  8171. * Defines the shadow projection clipping maximum z value.
  8172. */
  8173. shadowMaxZ: number;
  8174. /**
  8175. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8176. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8177. */
  8178. computeTransformedInformation(): boolean;
  8179. /**
  8180. * Gets the scene the light belongs to.
  8181. * @returns The scene
  8182. */
  8183. getScene(): Scene;
  8184. /**
  8185. * Callback defining a custom Projection Matrix Builder.
  8186. * This can be used to override the default projection matrix computation.
  8187. */
  8188. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8189. /**
  8190. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8191. * @param matrix The materix to updated with the projection information
  8192. * @param viewMatrix The transform matrix of the light
  8193. * @param renderList The list of mesh to render in the map
  8194. * @returns The current light
  8195. */
  8196. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8197. /**
  8198. * Gets the current depth scale used in ESM.
  8199. * @returns The scale
  8200. */
  8201. getDepthScale(): number;
  8202. /**
  8203. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8204. * @returns true if a cube texture needs to be use
  8205. */
  8206. needCube(): boolean;
  8207. /**
  8208. * Detects if the projection matrix requires to be recomputed this frame.
  8209. * @returns true if it requires to be recomputed otherwise, false.
  8210. */
  8211. needProjectionMatrixCompute(): boolean;
  8212. /**
  8213. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8214. */
  8215. forceProjectionMatrixCompute(): void;
  8216. /**
  8217. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8218. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8219. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8220. */
  8221. getShadowDirection(faceIndex?: number): Vector3;
  8222. /**
  8223. * Gets the minZ used for shadow according to both the scene and the light.
  8224. * @param activeCamera The camera we are returning the min for
  8225. * @returns the depth min z
  8226. */
  8227. getDepthMinZ(activeCamera: Camera): number;
  8228. /**
  8229. * Gets the maxZ used for shadow according to both the scene and the light.
  8230. * @param activeCamera The camera we are returning the max for
  8231. * @returns the depth max z
  8232. */
  8233. getDepthMaxZ(activeCamera: Camera): number;
  8234. }
  8235. /**
  8236. * Base implementation IShadowLight
  8237. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8238. */
  8239. abstract class ShadowLight extends Light implements IShadowLight {
  8240. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8241. protected _position: Vector3;
  8242. protected _setPosition(value: Vector3): void;
  8243. /**
  8244. * Sets the position the shadow will be casted from. Also use as the light position for both
  8245. * point and spot lights.
  8246. */
  8247. /**
  8248. * Sets the position the shadow will be casted from. Also use as the light position for both
  8249. * point and spot lights.
  8250. */
  8251. position: Vector3;
  8252. protected _direction: Vector3;
  8253. protected _setDirection(value: Vector3): void;
  8254. /**
  8255. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8256. * Also use as the light direction on spot and directional lights.
  8257. */
  8258. /**
  8259. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8260. * Also use as the light direction on spot and directional lights.
  8261. */
  8262. direction: Vector3;
  8263. private _shadowMinZ;
  8264. /**
  8265. * Gets the shadow projection clipping minimum z value.
  8266. */
  8267. /**
  8268. * Sets the shadow projection clipping minimum z value.
  8269. */
  8270. shadowMinZ: number;
  8271. private _shadowMaxZ;
  8272. /**
  8273. * Sets the shadow projection clipping maximum z value.
  8274. */
  8275. /**
  8276. * Gets the shadow projection clipping maximum z value.
  8277. */
  8278. shadowMaxZ: number;
  8279. /**
  8280. * Callback defining a custom Projection Matrix Builder.
  8281. * This can be used to override the default projection matrix computation.
  8282. */
  8283. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8284. /**
  8285. * The transformed position. Position of the light in world space taking parenting in account.
  8286. */
  8287. transformedPosition: Vector3;
  8288. /**
  8289. * The transformed direction. Direction of the light in world space taking parenting in account.
  8290. */
  8291. transformedDirection: Vector3;
  8292. private _worldMatrix;
  8293. private _needProjectionMatrixCompute;
  8294. /**
  8295. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8296. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8297. */
  8298. computeTransformedInformation(): boolean;
  8299. /**
  8300. * Return the depth scale used for the shadow map.
  8301. * @returns the depth scale.
  8302. */
  8303. getDepthScale(): number;
  8304. /**
  8305. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8306. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8307. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8308. */
  8309. getShadowDirection(faceIndex?: number): Vector3;
  8310. /**
  8311. * Returns the ShadowLight absolute position in the World.
  8312. * @returns the position vector in world space
  8313. */
  8314. getAbsolutePosition(): Vector3;
  8315. /**
  8316. * Sets the ShadowLight direction toward the passed target.
  8317. * @param target The point tot target in local space
  8318. * @returns the updated ShadowLight direction
  8319. */
  8320. setDirectionToTarget(target: Vector3): Vector3;
  8321. /**
  8322. * Returns the light rotation in euler definition.
  8323. * @returns the x y z rotation in local space.
  8324. */
  8325. getRotation(): Vector3;
  8326. /**
  8327. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8328. * @returns true if a cube texture needs to be use
  8329. */
  8330. needCube(): boolean;
  8331. /**
  8332. * Detects if the projection matrix requires to be recomputed this frame.
  8333. * @returns true if it requires to be recomputed otherwise, false.
  8334. */
  8335. needProjectionMatrixCompute(): boolean;
  8336. /**
  8337. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8338. */
  8339. forceProjectionMatrixCompute(): void;
  8340. /**
  8341. * Get the world matrix of the sahdow lights.
  8342. * @ignore Internal Use Only
  8343. */
  8344. _getWorldMatrix(): Matrix;
  8345. /**
  8346. * Gets the minZ used for shadow according to both the scene and the light.
  8347. * @param activeCamera The camera we are returning the min for
  8348. * @returns the depth min z
  8349. */
  8350. getDepthMinZ(activeCamera: Camera): number;
  8351. /**
  8352. * Gets the maxZ used for shadow according to both the scene and the light.
  8353. * @param activeCamera The camera we are returning the max for
  8354. * @returns the depth max z
  8355. */
  8356. getDepthMaxZ(activeCamera: Camera): number;
  8357. /**
  8358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8359. * @param matrix The materix to updated with the projection information
  8360. * @param viewMatrix The transform matrix of the light
  8361. * @param renderList The list of mesh to render in the map
  8362. * @returns The current light
  8363. */
  8364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8365. }
  8366. }
  8367. declare module BABYLON {
  8368. /**
  8369. * A spot light is defined by a position, a direction, an angle, and an exponent.
  8370. * These values define a cone of light starting from the position, emitting toward the direction.
  8371. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  8372. * and the exponent defines the speed of the decay of the light with distance (reach).
  8373. * Documentation: https://doc.babylonjs.com/babylon101/lights
  8374. */
  8375. class SpotLight extends ShadowLight {
  8376. private _angle;
  8377. /**
  8378. * Gets the cone angle of the spot light in Radians.
  8379. */
  8380. /**
  8381. * Sets the cone angle of the spot light in Radians.
  8382. */
  8383. angle: number;
  8384. private _shadowAngleScale;
  8385. /**
  8386. * Allows scaling the angle of the light for shadow generation only.
  8387. */
  8388. /**
  8389. * Allows scaling the angle of the light for shadow generation only.
  8390. */
  8391. shadowAngleScale: number;
  8392. /**
  8393. * The light decay speed with the distance from the emission spot.
  8394. */
  8395. exponent: number;
  8396. private _projectionTextureMatrix;
  8397. /**
  8398. * Allows reading the projecton texture
  8399. */
  8400. readonly projectionTextureMatrix: Matrix;
  8401. protected _projectionTextureLightNear: number;
  8402. /**
  8403. * Gets the near clip of the Spotlight for texture projection.
  8404. */
  8405. /**
  8406. * Sets the near clip of the Spotlight for texture projection.
  8407. */
  8408. projectionTextureLightNear: number;
  8409. protected _projectionTextureLightFar: number;
  8410. /**
  8411. * Gets the far clip of the Spotlight for texture projection.
  8412. */
  8413. /**
  8414. * Sets the far clip of the Spotlight for texture projection.
  8415. */
  8416. projectionTextureLightFar: number;
  8417. protected _projectionTextureUpDirection: Vector3;
  8418. /**
  8419. * Gets the Up vector of the Spotlight for texture projection.
  8420. */
  8421. /**
  8422. * Sets the Up vector of the Spotlight for texture projection.
  8423. */
  8424. projectionTextureUpDirection: Vector3;
  8425. private _projectionTexture;
  8426. /**
  8427. * Gets the projection texture of the light.
  8428. */
  8429. /**
  8430. * Sets the projection texture of the light.
  8431. */
  8432. projectionTexture: Nullable<BaseTexture>;
  8433. private _projectionTextureViewLightDirty;
  8434. private _projectionTextureProjectionLightDirty;
  8435. private _projectionTextureDirty;
  8436. private _projectionTextureViewTargetVector;
  8437. private _projectionTextureViewLightMatrix;
  8438. private _projectionTextureProjectionLightMatrix;
  8439. private _projectionTextureScalingMatrix;
  8440. /**
  8441. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  8442. * It can cast shadows.
  8443. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8444. * @param name The light friendly name
  8445. * @param position The position of the spot light in the scene
  8446. * @param direction The direction of the light in the scene
  8447. * @param angle The cone angle of the light in Radians
  8448. * @param exponent The light decay speed with the distance from the emission spot
  8449. * @param scene The scene the lights belongs to
  8450. */
  8451. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  8452. /**
  8453. * Returns the string "SpotLight".
  8454. * @returns the class name
  8455. */
  8456. getClassName(): string;
  8457. /**
  8458. * Returns the integer 2.
  8459. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8460. */
  8461. getTypeID(): number;
  8462. /**
  8463. * Overrides the direction setter to recompute the projection texture view light Matrix.
  8464. */
  8465. protected _setDirection(value: Vector3): void;
  8466. /**
  8467. * Overrides the position setter to recompute the projection texture view light Matrix.
  8468. */
  8469. protected _setPosition(value: Vector3): void;
  8470. /**
  8471. * 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.
  8472. * Returns the SpotLight.
  8473. */
  8474. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8475. protected _computeProjectionTextureViewLightMatrix(): void;
  8476. protected _computeProjectionTextureProjectionLightMatrix(): void;
  8477. /**
  8478. * Main function for light texture projection matrix computing.
  8479. */
  8480. protected _computeProjectionTextureMatrix(): void;
  8481. protected _buildUniformLayout(): void;
  8482. /**
  8483. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  8484. * @param effect The effect to update
  8485. * @param lightIndex The index of the light in the effect to update
  8486. * @returns The spot light
  8487. */
  8488. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  8489. /**
  8490. * Disposes the light and the associated resources.
  8491. */
  8492. dispose(): void;
  8493. }
  8494. }
  8495. declare module BABYLON {
  8496. /**
  8497. * Effect layer options. This helps customizing the behaviour
  8498. * of the effect layer.
  8499. */
  8500. interface IEffectLayerOptions {
  8501. /**
  8502. * Multiplication factor apply to the canvas size to compute the render target size
  8503. * used to generated the objects (the smaller the faster).
  8504. */
  8505. mainTextureRatio: number;
  8506. /**
  8507. * Enforces a fixed size texture to ensure effect stability across devices.
  8508. */
  8509. mainTextureFixedSize?: number;
  8510. /**
  8511. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  8512. */
  8513. alphaBlendingMode: number;
  8514. /**
  8515. * The camera attached to the layer.
  8516. */
  8517. camera: Nullable<Camera>;
  8518. }
  8519. /**
  8520. * The effect layer Helps adding post process effect blended with the main pass.
  8521. *
  8522. * This can be for instance use to generate glow or higlight effects on the scene.
  8523. *
  8524. * The effect layer class can not be used directly and is intented to inherited from to be
  8525. * customized per effects.
  8526. */
  8527. abstract class EffectLayer {
  8528. /** The Friendly of the effect in the scene */
  8529. name: string;
  8530. private _vertexBuffers;
  8531. private _indexBuffer;
  8532. private _cachedDefines;
  8533. private _effectLayerMapGenerationEffect;
  8534. private _effectLayerOptions;
  8535. private _mergeEffect;
  8536. protected _scene: Scene;
  8537. protected _engine: Engine;
  8538. protected _maxSize: number;
  8539. protected _mainTextureDesiredSize: ISize;
  8540. protected _mainTexture: RenderTargetTexture;
  8541. protected _shouldRender: boolean;
  8542. protected _postProcesses: PostProcess[];
  8543. protected _textures: BaseTexture[];
  8544. protected _emissiveTextureAndColor: {
  8545. texture: Nullable<BaseTexture>;
  8546. color: Color4;
  8547. };
  8548. /**
  8549. * The clear color of the texture used to generate the glow map.
  8550. */
  8551. neutralColor: Color4;
  8552. /**
  8553. * Specifies wether the highlight layer is enabled or not.
  8554. */
  8555. isEnabled: boolean;
  8556. /**
  8557. * Gets the camera attached to the layer.
  8558. */
  8559. readonly camera: Nullable<Camera>;
  8560. /**
  8561. * An event triggered when the effect layer has been disposed.
  8562. */
  8563. onDisposeObservable: Observable<EffectLayer>;
  8564. /**
  8565. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  8566. */
  8567. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  8568. /**
  8569. * An event triggered when the generated texture is being merged in the scene.
  8570. */
  8571. onBeforeComposeObservable: Observable<EffectLayer>;
  8572. /**
  8573. * An event triggered when the generated texture has been merged in the scene.
  8574. */
  8575. onAfterComposeObservable: Observable<EffectLayer>;
  8576. /**
  8577. * An event triggered when the efffect layer changes its size.
  8578. */
  8579. onSizeChangedObservable: Observable<EffectLayer>;
  8580. /**
  8581. * Instantiates a new effect Layer and references it in the scene.
  8582. * @param name The name of the layer
  8583. * @param scene The scene to use the layer in
  8584. */
  8585. constructor(
  8586. /** The Friendly of the effect in the scene */
  8587. name: string, scene: Scene);
  8588. /**
  8589. * Get the effect name of the layer.
  8590. * @return The effect name
  8591. */
  8592. abstract getEffectName(): string;
  8593. /**
  8594. * Checks for the readiness of the element composing the layer.
  8595. * @param subMesh the mesh to check for
  8596. * @param useInstances specify wether or not to use instances to render the mesh
  8597. * @return true if ready otherwise, false
  8598. */
  8599. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8600. /**
  8601. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  8602. * @returns true if the effect requires stencil during the main canvas render pass.
  8603. */
  8604. abstract needStencil(): boolean;
  8605. /**
  8606. * Create the merge effect. This is the shader use to blit the information back
  8607. * to the main canvas at the end of the scene rendering.
  8608. * @returns The effect containing the shader used to merge the effect on the main canvas
  8609. */
  8610. protected abstract _createMergeEffect(): Effect;
  8611. /**
  8612. * Creates the render target textures and post processes used in the effect layer.
  8613. */
  8614. protected abstract _createTextureAndPostProcesses(): void;
  8615. /**
  8616. * Implementation specific of rendering the generating effect on the main canvas.
  8617. * @param effect The effect used to render through
  8618. */
  8619. protected abstract _internalRender(effect: Effect): void;
  8620. /**
  8621. * Sets the required values for both the emissive texture and and the main color.
  8622. */
  8623. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  8624. /**
  8625. * Free any resources and references associated to a mesh.
  8626. * Internal use
  8627. * @param mesh The mesh to free.
  8628. */
  8629. abstract _disposeMesh(mesh: Mesh): void;
  8630. /**
  8631. * Initializes the effect layer with the required options.
  8632. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  8633. */
  8634. protected _init(options: Partial<IEffectLayerOptions>): void;
  8635. /**
  8636. * Generates the index buffer of the full screen quad blending to the main canvas.
  8637. */
  8638. private _generateIndexBuffer();
  8639. /**
  8640. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  8641. */
  8642. private _genrateVertexBuffer();
  8643. /**
  8644. * Sets the main texture desired size which is the closest power of two
  8645. * of the engine canvas size.
  8646. */
  8647. private _setMainTextureSize();
  8648. /**
  8649. * Creates the main texture for the effect layer.
  8650. */
  8651. protected _createMainTexture(): void;
  8652. /**
  8653. * Checks for the readiness of the element composing the layer.
  8654. * @param subMesh the mesh to check for
  8655. * @param useInstances specify wether or not to use instances to render the mesh
  8656. * @param emissiveTexture the associated emissive texture used to generate the glow
  8657. * @return true if ready otherwise, false
  8658. */
  8659. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  8660. /**
  8661. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  8662. */
  8663. render(): void;
  8664. /**
  8665. * Determine if a given mesh will be used in the current effect.
  8666. * @param mesh mesh to test
  8667. * @returns true if the mesh will be used
  8668. */
  8669. hasMesh(mesh: AbstractMesh): boolean;
  8670. /**
  8671. * Returns true if the layer contains information to display, otherwise false.
  8672. * @returns true if the glow layer should be rendered
  8673. */
  8674. shouldRender(): boolean;
  8675. /**
  8676. * Returns true if the mesh should render, otherwise false.
  8677. * @param mesh The mesh to render
  8678. * @returns true if it should render otherwise false
  8679. */
  8680. protected _shouldRenderMesh(mesh: Mesh): boolean;
  8681. /**
  8682. * Returns true if the mesh should render, otherwise false.
  8683. * @param mesh The mesh to render
  8684. * @returns true if it should render otherwise false
  8685. */
  8686. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  8687. /**
  8688. * Renders the submesh passed in parameter to the generation map.
  8689. */
  8690. protected _renderSubMesh(subMesh: SubMesh): void;
  8691. /**
  8692. * Rebuild the required buffers.
  8693. * @ignore Internal use only.
  8694. */
  8695. _rebuild(): void;
  8696. /**
  8697. * Dispose only the render target textures and post process.
  8698. */
  8699. private _disposeTextureAndPostProcesses();
  8700. /**
  8701. * Dispose the highlight layer and free resources.
  8702. */
  8703. dispose(): void;
  8704. }
  8705. }
  8706. declare module BABYLON {
  8707. /**
  8708. * Glow layer options. This helps customizing the behaviour
  8709. * of the glow layer.
  8710. */
  8711. interface IGlowLayerOptions {
  8712. /**
  8713. * Multiplication factor apply to the canvas size to compute the render target size
  8714. * used to generated the glowing objects (the smaller the faster).
  8715. */
  8716. mainTextureRatio: number;
  8717. /**
  8718. * Enforces a fixed size texture to ensure resize independant blur.
  8719. */
  8720. mainTextureFixedSize?: number;
  8721. /**
  8722. * How big is the kernel of the blur texture.
  8723. */
  8724. blurKernelSize: number;
  8725. /**
  8726. * The camera attached to the layer.
  8727. */
  8728. camera: Nullable<Camera>;
  8729. /**
  8730. * Enable MSAA by chosing the number of samples.
  8731. */
  8732. mainTextureSamples?: number;
  8733. }
  8734. /**
  8735. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  8736. *
  8737. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  8738. * glowy meshes to your scene.
  8739. *
  8740. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  8741. */
  8742. class GlowLayer extends EffectLayer {
  8743. name: string;
  8744. /**
  8745. * Effect Name of the layer.
  8746. */
  8747. static readonly EffectName: string;
  8748. /**
  8749. * The default blur kernel size used for the glow.
  8750. */
  8751. static DefaultBlurKernelSize: number;
  8752. /**
  8753. * The default texture size ratio used for the glow.
  8754. */
  8755. static DefaultTextureRatio: number;
  8756. /**
  8757. * Gets the kernel size of the blur.
  8758. */
  8759. /**
  8760. * Sets the kernel size of the blur.
  8761. */
  8762. blurKernelSize: number;
  8763. /**
  8764. * Gets the glow intensity.
  8765. */
  8766. /**
  8767. * Sets the glow intensity.
  8768. */
  8769. intensity: number;
  8770. private _options;
  8771. private _intensity;
  8772. private _horizontalBlurPostprocess1;
  8773. private _verticalBlurPostprocess1;
  8774. private _horizontalBlurPostprocess2;
  8775. private _verticalBlurPostprocess2;
  8776. private _blurTexture1;
  8777. private _blurTexture2;
  8778. private _postProcesses1;
  8779. private _postProcesses2;
  8780. private _includedOnlyMeshes;
  8781. private _excludedMeshes;
  8782. /**
  8783. * Callback used to let the user override the color selection on a per mesh basis
  8784. */
  8785. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  8786. /**
  8787. * Callback used to let the user override the texture selection on a per mesh basis
  8788. */
  8789. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  8790. /**
  8791. * Instantiates a new glow Layer and references it to the scene.
  8792. * @param name The name of the layer
  8793. * @param scene The scene to use the layer in
  8794. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  8795. */
  8796. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  8797. /**
  8798. * Get the effect name of the layer.
  8799. * @return The effect name
  8800. */
  8801. getEffectName(): string;
  8802. /**
  8803. * Create the merge effect. This is the shader use to blit the information back
  8804. * to the main canvas at the end of the scene rendering.
  8805. */
  8806. protected _createMergeEffect(): Effect;
  8807. /**
  8808. * Creates the render target textures and post processes used in the glow layer.
  8809. */
  8810. protected _createTextureAndPostProcesses(): void;
  8811. /**
  8812. * Checks for the readiness of the element composing the layer.
  8813. * @param subMesh the mesh to check for
  8814. * @param useInstances specify wether or not to use instances to render the mesh
  8815. * @param emissiveTexture the associated emissive texture used to generate the glow
  8816. * @return true if ready otherwise, false
  8817. */
  8818. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8819. /**
  8820. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  8821. */
  8822. needStencil(): boolean;
  8823. /**
  8824. * Implementation specific of rendering the generating effect on the main canvas.
  8825. * @param effect The effect used to render through
  8826. */
  8827. protected _internalRender(effect: Effect): void;
  8828. /**
  8829. * Sets the required values for both the emissive texture and and the main color.
  8830. */
  8831. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  8832. /**
  8833. * Returns true if the mesh should render, otherwise false.
  8834. * @param mesh The mesh to render
  8835. * @returns true if it should render otherwise false
  8836. */
  8837. protected _shouldRenderMesh(mesh: Mesh): boolean;
  8838. /**
  8839. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  8840. * @param mesh The mesh to exclude from the glow layer
  8841. */
  8842. addExcludedMesh(mesh: Mesh): void;
  8843. /**
  8844. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  8845. * @param mesh The mesh to remove
  8846. */
  8847. removeExcludedMesh(mesh: Mesh): void;
  8848. /**
  8849. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  8850. * @param mesh The mesh to include in the glow layer
  8851. */
  8852. addIncludedOnlyMesh(mesh: Mesh): void;
  8853. /**
  8854. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  8855. * @param mesh The mesh to remove
  8856. */
  8857. removeIncludedOnlyMesh(mesh: Mesh): void;
  8858. /**
  8859. * Determine if a given mesh will be used in the glow layer
  8860. * @param mesh The mesh to test
  8861. * @returns true if the mesh will be highlighted by the current glow layer
  8862. */
  8863. hasMesh(mesh: AbstractMesh): boolean;
  8864. /**
  8865. * Free any resources and references associated to a mesh.
  8866. * Internal use
  8867. * @param mesh The mesh to free.
  8868. */
  8869. _disposeMesh(mesh: Mesh): void;
  8870. }
  8871. }
  8872. declare module BABYLON {
  8873. /**
  8874. * Highlight layer options. This helps customizing the behaviour
  8875. * of the highlight layer.
  8876. */
  8877. interface IHighlightLayerOptions {
  8878. /**
  8879. * Multiplication factor apply to the canvas size to compute the render target size
  8880. * used to generated the glowing objects (the smaller the faster).
  8881. */
  8882. mainTextureRatio: number;
  8883. /**
  8884. * Enforces a fixed size texture to ensure resize independant blur.
  8885. */
  8886. mainTextureFixedSize?: number;
  8887. /**
  8888. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  8889. * of the picture to blur (the smaller the faster).
  8890. */
  8891. blurTextureSizeRatio: number;
  8892. /**
  8893. * How big in texel of the blur texture is the vertical blur.
  8894. */
  8895. blurVerticalSize: number;
  8896. /**
  8897. * How big in texel of the blur texture is the horizontal blur.
  8898. */
  8899. blurHorizontalSize: number;
  8900. /**
  8901. * Alpha blending mode used to apply the blur. Default is combine.
  8902. */
  8903. alphaBlendingMode: number;
  8904. /**
  8905. * The camera attached to the layer.
  8906. */
  8907. camera: Nullable<Camera>;
  8908. /**
  8909. * Should we display highlight as a solid stroke?
  8910. */
  8911. isStroke?: boolean;
  8912. }
  8913. /**
  8914. * The highlight layer Helps adding a glow effect around a mesh.
  8915. *
  8916. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  8917. * glowy meshes to your scene.
  8918. *
  8919. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  8920. */
  8921. class HighlightLayer extends EffectLayer {
  8922. name: string;
  8923. /**
  8924. * Effect Name of the highlight layer.
  8925. */
  8926. static readonly EffectName: string;
  8927. /**
  8928. * The neutral color used during the preparation of the glow effect.
  8929. * This is black by default as the blend operation is a blend operation.
  8930. */
  8931. static NeutralColor: Color4;
  8932. /**
  8933. * Stencil value used for glowing meshes.
  8934. */
  8935. static GlowingMeshStencilReference: number;
  8936. /**
  8937. * Stencil value used for the other meshes in the scene.
  8938. */
  8939. static NormalMeshStencilReference: number;
  8940. /**
  8941. * Specifies whether or not the inner glow is ACTIVE in the layer.
  8942. */
  8943. innerGlow: boolean;
  8944. /**
  8945. * Specifies whether or not the outer glow is ACTIVE in the layer.
  8946. */
  8947. outerGlow: boolean;
  8948. /**
  8949. * Gets the horizontal size of the blur.
  8950. */
  8951. /**
  8952. * Specifies the horizontal size of the blur.
  8953. */
  8954. blurHorizontalSize: number;
  8955. /**
  8956. * Gets the vertical size of the blur.
  8957. */
  8958. /**
  8959. * Specifies the vertical size of the blur.
  8960. */
  8961. blurVerticalSize: number;
  8962. /**
  8963. * An event triggered when the highlight layer is being blurred.
  8964. */
  8965. onBeforeBlurObservable: Observable<HighlightLayer>;
  8966. /**
  8967. * An event triggered when the highlight layer has been blurred.
  8968. */
  8969. onAfterBlurObservable: Observable<HighlightLayer>;
  8970. private _instanceGlowingMeshStencilReference;
  8971. private _options;
  8972. private _downSamplePostprocess;
  8973. private _horizontalBlurPostprocess;
  8974. private _verticalBlurPostprocess;
  8975. private _blurTexture;
  8976. private _meshes;
  8977. private _excludedMeshes;
  8978. /**
  8979. * Instantiates a new highlight Layer and references it to the scene..
  8980. * @param name The name of the layer
  8981. * @param scene The scene to use the layer in
  8982. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  8983. */
  8984. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  8985. /**
  8986. * Get the effect name of the layer.
  8987. * @return The effect name
  8988. */
  8989. getEffectName(): string;
  8990. /**
  8991. * Create the merge effect. This is the shader use to blit the information back
  8992. * to the main canvas at the end of the scene rendering.
  8993. */
  8994. protected _createMergeEffect(): Effect;
  8995. /**
  8996. * Creates the render target textures and post processes used in the highlight layer.
  8997. */
  8998. protected _createTextureAndPostProcesses(): void;
  8999. /**
  9000. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9001. */
  9002. needStencil(): boolean;
  9003. /**
  9004. * Checks for the readiness of the element composing the layer.
  9005. * @param subMesh the mesh to check for
  9006. * @param useInstances specify wether or not to use instances to render the mesh
  9007. * @param emissiveTexture the associated emissive texture used to generate the glow
  9008. * @return true if ready otherwise, false
  9009. */
  9010. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9011. /**
  9012. * Implementation specific of rendering the generating effect on the main canvas.
  9013. * @param effect The effect used to render through
  9014. */
  9015. protected _internalRender(effect: Effect): void;
  9016. /**
  9017. * Returns true if the layer contains information to display, otherwise false.
  9018. */
  9019. shouldRender(): boolean;
  9020. /**
  9021. * Returns true if the mesh should render, otherwise false.
  9022. * @param mesh The mesh to render
  9023. * @returns true if it should render otherwise false
  9024. */
  9025. protected _shouldRenderMesh(mesh: Mesh): boolean;
  9026. /**
  9027. * Sets the required values for both the emissive texture and and the main color.
  9028. */
  9029. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9030. /**
  9031. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  9032. * @param mesh The mesh to exclude from the highlight layer
  9033. */
  9034. addExcludedMesh(mesh: Mesh): void;
  9035. /**
  9036. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  9037. * @param mesh The mesh to highlight
  9038. */
  9039. removeExcludedMesh(mesh: Mesh): void;
  9040. /**
  9041. * Determine if a given mesh will be highlighted by the current HighlightLayer
  9042. * @param mesh mesh to test
  9043. * @returns true if the mesh will be highlighted by the current HighlightLayer
  9044. */
  9045. hasMesh(mesh: AbstractMesh): boolean;
  9046. /**
  9047. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  9048. * @param mesh The mesh to highlight
  9049. * @param color The color of the highlight
  9050. * @param glowEmissiveOnly Extract the glow from the emissive texture
  9051. */
  9052. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  9053. /**
  9054. * Remove a mesh from the highlight layer in order to make it stop glowing.
  9055. * @param mesh The mesh to highlight
  9056. */
  9057. removeMesh(mesh: Mesh): void;
  9058. /**
  9059. * Force the stencil to the normal expected value for none glowing parts
  9060. */
  9061. private _defaultStencilReference(mesh);
  9062. /**
  9063. * Free any resources and references associated to a mesh.
  9064. * Internal use
  9065. * @param mesh The mesh to free.
  9066. */
  9067. _disposeMesh(mesh: Mesh): void;
  9068. /**
  9069. * Dispose the highlight layer and free resources.
  9070. */
  9071. dispose(): void;
  9072. }
  9073. }
  9074. declare module BABYLON {
  9075. class Layer {
  9076. name: string;
  9077. texture: Nullable<Texture>;
  9078. isBackground: boolean;
  9079. color: Color4;
  9080. scale: Vector2;
  9081. offset: Vector2;
  9082. alphaBlendingMode: number;
  9083. alphaTest: boolean;
  9084. layerMask: number;
  9085. private _scene;
  9086. private _vertexBuffers;
  9087. private _indexBuffer;
  9088. private _effect;
  9089. private _alphaTestEffect;
  9090. /**
  9091. * An event triggered when the layer is disposed.
  9092. * @type {BABYLON.Observable}
  9093. */
  9094. onDisposeObservable: Observable<Layer>;
  9095. private _onDisposeObserver;
  9096. onDispose: () => void;
  9097. /**
  9098. * An event triggered before rendering the scene
  9099. * @type {BABYLON.Observable}
  9100. */
  9101. onBeforeRenderObservable: Observable<Layer>;
  9102. private _onBeforeRenderObserver;
  9103. onBeforeRender: () => void;
  9104. /**
  9105. * An event triggered after rendering the scene
  9106. * @type {BABYLON.Observable}
  9107. */
  9108. onAfterRenderObservable: Observable<Layer>;
  9109. private _onAfterRenderObserver;
  9110. onAfterRender: () => void;
  9111. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  9112. private _createIndexBuffer();
  9113. _rebuild(): void;
  9114. render(): void;
  9115. dispose(): void;
  9116. }
  9117. }
  9118. declare module BABYLON {
  9119. class Scalar {
  9120. /**
  9121. * Two pi constants convenient for computation.
  9122. */
  9123. static TwoPi: number;
  9124. /**
  9125. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  9126. */
  9127. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  9128. /**
  9129. * Returns a string : the upper case translation of the number i to hexadecimal.
  9130. */
  9131. static ToHex(i: number): string;
  9132. /**
  9133. * Returns -1 if value is negative and +1 is value is positive.
  9134. * Returns the value itself if it's equal to zero.
  9135. */
  9136. static Sign(value: number): number;
  9137. /**
  9138. * Returns the value itself if it's between min and max.
  9139. * Returns min if the value is lower than min.
  9140. * Returns max if the value is greater than max.
  9141. */
  9142. static Clamp(value: number, min?: number, max?: number): number;
  9143. /**
  9144. * Returns the log2 of value.
  9145. */
  9146. static Log2(value: number): number;
  9147. /**
  9148. * Loops the value, so that it is never larger than length and never smaller than 0.
  9149. *
  9150. * This is similar to the modulo operator but it works with floating point numbers.
  9151. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  9152. * With t = 5 and length = 2.5, the result would be 0.0.
  9153. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  9154. */
  9155. static Repeat(value: number, length: number): number;
  9156. /**
  9157. * Normalize the value between 0.0 and 1.0 using min and max values
  9158. */
  9159. static Normalize(value: number, min: number, max: number): number;
  9160. /**
  9161. * Denormalize the value from 0.0 and 1.0 using min and max values
  9162. */
  9163. static Denormalize(normalized: number, min: number, max: number): number;
  9164. /**
  9165. * Calculates the shortest difference between two given angles given in degrees.
  9166. */
  9167. static DeltaAngle(current: number, target: number): number;
  9168. /**
  9169. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  9170. *
  9171. * The returned value will move back and forth between 0 and length
  9172. */
  9173. static PingPong(tx: number, length: number): number;
  9174. /**
  9175. * Interpolates between min and max with smoothing at the limits.
  9176. *
  9177. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  9178. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  9179. */
  9180. static SmoothStep(from: number, to: number, tx: number): number;
  9181. /**
  9182. * Moves a value current towards target.
  9183. *
  9184. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  9185. * Negative values of maxDelta pushes the value away from target.
  9186. */
  9187. static MoveTowards(current: number, target: number, maxDelta: number): number;
  9188. /**
  9189. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  9190. *
  9191. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  9192. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  9193. */
  9194. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  9195. /**
  9196. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  9197. */
  9198. static Lerp(start: number, end: number, amount: number): number;
  9199. /**
  9200. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  9201. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  9202. */
  9203. static LerpAngle(start: number, end: number, amount: number): number;
  9204. /**
  9205. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  9206. */
  9207. static InverseLerp(a: number, b: number, value: number): number;
  9208. /**
  9209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  9210. */
  9211. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  9212. /**
  9213. * Returns a random float number between and min and max values
  9214. */
  9215. static RandomRange(min: number, max: number): number;
  9216. /**
  9217. * This function returns percentage of a number in a given range.
  9218. *
  9219. * RangeToPercent(40,20,60) will return 0.5 (50%)
  9220. * RangeToPercent(34,0,100) will return 0.34 (34%)
  9221. */
  9222. static RangeToPercent(number: number, min: number, max: number): number;
  9223. /**
  9224. * This function returns number that corresponds to the percentage in a given range.
  9225. *
  9226. * PercentToRange(0.34,0,100) will return 34.
  9227. */
  9228. static PercentToRange(percent: number, min: number, max: number): number;
  9229. /**
  9230. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  9231. * @param angle The angle to normalize in radian.
  9232. * @return The converted angle.
  9233. */
  9234. static NormalizeRadians(angle: number): number;
  9235. }
  9236. }
  9237. declare module BABYLON {
  9238. const ToGammaSpace: number;
  9239. const ToLinearSpace = 2.2;
  9240. const Epsilon = 0.001;
  9241. /**
  9242. * Class used to hold a RBG color
  9243. */
  9244. class Color3 {
  9245. /**
  9246. * Defines the red component (between 0 and 1, default is 0)
  9247. */
  9248. r: number;
  9249. /**
  9250. * Defines the green component (between 0 and 1, default is 0)
  9251. */
  9252. g: number;
  9253. /**
  9254. * Defines the blue component (between 0 and 1, default is 0)
  9255. */
  9256. b: number;
  9257. /**
  9258. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  9259. * @param r defines the red component (between 0 and 1, default is 0)
  9260. * @param g defines the green component (between 0 and 1, default is 0)
  9261. * @param b defines the blue component (between 0 and 1, default is 0)
  9262. */
  9263. constructor(
  9264. /**
  9265. * Defines the red component (between 0 and 1, default is 0)
  9266. */
  9267. r?: number,
  9268. /**
  9269. * Defines the green component (between 0 and 1, default is 0)
  9270. */
  9271. g?: number,
  9272. /**
  9273. * Defines the blue component (between 0 and 1, default is 0)
  9274. */
  9275. b?: number);
  9276. /**
  9277. * Creates a string with the Color3 current values
  9278. * @returns the string representation of the Color3 object
  9279. */
  9280. toString(): string;
  9281. /**
  9282. * Returns the string "Color3"
  9283. * @returns "Color3"
  9284. */
  9285. getClassName(): string;
  9286. /**
  9287. * Compute the Color3 hash code
  9288. * @returns an unique number that can be used to hash Color3 objects
  9289. */
  9290. getHashCode(): number;
  9291. /**
  9292. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  9293. * @param array defines the array where to store the r,g,b components
  9294. * @param index defines an optional index in the target array to define where to start storing values
  9295. * @returns the current Color3 object
  9296. */
  9297. toArray(array: FloatArray, index?: number): Color3;
  9298. /**
  9299. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  9300. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  9301. * @returns a new {BABYLON.Color4} object
  9302. */
  9303. toColor4(alpha?: number): Color4;
  9304. /**
  9305. * Returns a new array populated with 3 numeric elements : red, green and blue values
  9306. * @returns the new array
  9307. */
  9308. asArray(): number[];
  9309. /**
  9310. * Returns the luminance value
  9311. * @returns a float value
  9312. */
  9313. toLuminance(): number;
  9314. /**
  9315. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  9316. * @param otherColor defines the second operand
  9317. * @returns the new Color3 object
  9318. */
  9319. multiply(otherColor: Color3): Color3;
  9320. /**
  9321. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  9322. * @param otherColor defines the second operand
  9323. * @param result defines the Color3 object where to store the result
  9324. * @returns the current Color3
  9325. */
  9326. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  9327. /**
  9328. * Determines equality between Color3 objects
  9329. * @param otherColor defines the second operand
  9330. * @returns true if the rgb values are equal to the passed ones
  9331. */
  9332. equals(otherColor: Color3): boolean;
  9333. /**
  9334. * Determines equality between the current Color3 object and a set of r,b,g values
  9335. * @param r defines the red component to check
  9336. * @param g defines the green component to check
  9337. * @param b defines the blue component to check
  9338. * @returns true if the rgb values are equal to the passed ones
  9339. */
  9340. equalsFloats(r: number, g: number, b: number): boolean;
  9341. /**
  9342. * Multiplies in place each rgb value by scale
  9343. * @param scale defines the scaling factor
  9344. * @returns the updated Color3
  9345. */
  9346. scale(scale: number): Color3;
  9347. /**
  9348. * Multiplies the rgb values by scale and stores the result into "result"
  9349. * @param scale defines the scaling factor
  9350. * @param result defines the Color3 object where to store the result
  9351. * @returns the unmodified current Color3
  9352. */
  9353. scaleToRef(scale: number, result: Color3): Color3;
  9354. /**
  9355. * Scale the current Color3 values by a factor and add the result to a given Color3
  9356. * @param scale defines the scale factor
  9357. * @param result defines color to store the result into
  9358. * @returns the unmodified current Color3
  9359. */
  9360. scaleAndAddToRef(scale: number, result: Color3): Color3;
  9361. /**
  9362. * Clamps the rgb values by the min and max values and stores the result into "result"
  9363. * @param min defines minimum clamping value (default is 0)
  9364. * @param max defines maximum clamping value (default is 1)
  9365. * @param result defines color to store the result into
  9366. * @returns the original Color3
  9367. */
  9368. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  9369. /**
  9370. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  9371. * @param otherColor defines the second operand
  9372. * @returns the new Color3
  9373. */
  9374. add(otherColor: Color3): Color3;
  9375. /**
  9376. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  9377. * @param otherColor defines the second operand
  9378. * @param result defines Color3 object to store the result into
  9379. * @returns the unmodified current Color3
  9380. */
  9381. addToRef(otherColor: Color3, result: Color3): Color3;
  9382. /**
  9383. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  9384. * @param otherColor defines the second operand
  9385. * @returns the new Color3
  9386. */
  9387. subtract(otherColor: Color3): Color3;
  9388. /**
  9389. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  9390. * @param otherColor defines the second operand
  9391. * @param result defines Color3 object to store the result into
  9392. * @returns the unmodified current Color3
  9393. */
  9394. subtractToRef(otherColor: Color3, result: Color3): Color3;
  9395. /**
  9396. * Copy the current object
  9397. * @returns a new Color3 copied the current one
  9398. */
  9399. clone(): Color3;
  9400. /**
  9401. * Copies the rgb values from the source in the current Color3
  9402. * @param source defines the source Color3 object
  9403. * @returns the updated Color3 object
  9404. */
  9405. copyFrom(source: Color3): Color3;
  9406. /**
  9407. * Updates the Color3 rgb values from the passed floats
  9408. * @param r defines the red component to read from
  9409. * @param g defines the green component to read from
  9410. * @param b defines the blue component to read from
  9411. * @returns the current Color3 object
  9412. */
  9413. copyFromFloats(r: number, g: number, b: number): Color3;
  9414. /**
  9415. * Updates the Color3 rgb values from the passed floats
  9416. * @param r defines the red component to read from
  9417. * @param g defines the green component to read from
  9418. * @param b defines the blue component to read from
  9419. * @returns the current Color3 object
  9420. */
  9421. set(r: number, g: number, b: number): Color3;
  9422. /**
  9423. * Compute the Color3 hexadecimal code as a string
  9424. * @returns a string containing the hexadecimal representation of the Color3 object
  9425. */
  9426. toHexString(): string;
  9427. /**
  9428. * Computes a new Color3 converted from the current one to linear space
  9429. * @returns a new Color3 object
  9430. */
  9431. toLinearSpace(): Color3;
  9432. /**
  9433. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  9434. * @param convertedColor defines the Color3 object where to store the linear space version
  9435. * @returns the unmodified Color3
  9436. */
  9437. toLinearSpaceToRef(convertedColor: Color3): Color3;
  9438. /**
  9439. * Computes a new Color3 converted from the current one to gamma space
  9440. * @returns a new Color3 object
  9441. */
  9442. toGammaSpace(): Color3;
  9443. /**
  9444. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  9445. * @param convertedColor defines the Color3 object where to store the gamma space version
  9446. * @returns the unmodified Color3
  9447. */
  9448. toGammaSpaceToRef(convertedColor: Color3): Color3;
  9449. /**
  9450. * Creates a new Color3 from the string containing valid hexadecimal values
  9451. * @param hex defines a string containing valid hexadecimal values
  9452. * @returns a new Color3 object
  9453. */
  9454. static FromHexString(hex: string): Color3;
  9455. /**
  9456. * Creates a new Vector3 from the starting index of the passed array
  9457. * @param array defines the source array
  9458. * @param offset defines an offset in the source array
  9459. * @returns a new Color3 object
  9460. */
  9461. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  9462. /**
  9463. * Creates a new Color3 from integer values (< 256)
  9464. * @param r defines the red component to read from (value between 0 and 255)
  9465. * @param g defines the green component to read from (value between 0 and 255)
  9466. * @param b defines the blue component to read from (value between 0 and 255)
  9467. * @returns a new Color3 object
  9468. */
  9469. static FromInts(r: number, g: number, b: number): Color3;
  9470. /**
  9471. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  9472. * @param start defines the start Color3 value
  9473. * @param end defines the end Color3 value
  9474. * @param amount defines the gradient value between start and end
  9475. * @returns a new Color3 object
  9476. */
  9477. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  9478. /**
  9479. * Returns a Color3 value containing a red color
  9480. * @returns a new Color3 object
  9481. */
  9482. static Red(): Color3;
  9483. /**
  9484. * Returns a Color3 value containing a green color
  9485. * @returns a new Color3 object
  9486. */
  9487. static Green(): Color3;
  9488. /**
  9489. * Returns a Color3 value containing a blue color
  9490. * @returns a new Color3 object
  9491. */
  9492. static Blue(): Color3;
  9493. /**
  9494. * Returns a Color3 value containing a black color
  9495. * @returns a new Color3 object
  9496. */
  9497. static Black(): Color3;
  9498. /**
  9499. * Returns a Color3 value containing a white color
  9500. * @returns a new Color3 object
  9501. */
  9502. static White(): Color3;
  9503. /**
  9504. * Returns a Color3 value containing a purple color
  9505. * @returns a new Color3 object
  9506. */
  9507. static Purple(): Color3;
  9508. /**
  9509. * Returns a Color3 value containing a magenta color
  9510. * @returns a new Color3 object
  9511. */
  9512. static Magenta(): Color3;
  9513. /**
  9514. * Returns a Color3 value containing a yellow color
  9515. * @returns a new Color3 object
  9516. */
  9517. static Yellow(): Color3;
  9518. /**
  9519. * Returns a Color3 value containing a gray color
  9520. * @returns a new Color3 object
  9521. */
  9522. static Gray(): Color3;
  9523. /**
  9524. * Returns a Color3 value containing a teal color
  9525. * @returns a new Color3 object
  9526. */
  9527. static Teal(): Color3;
  9528. /**
  9529. * Returns a Color3 value containing a random color
  9530. * @returns a new Color3 object
  9531. */
  9532. static Random(): Color3;
  9533. }
  9534. /**
  9535. * Class used to hold a RBGA color
  9536. */
  9537. class Color4 {
  9538. /**
  9539. * Defines the red component (between 0 and 1, default is 0)
  9540. */
  9541. r: number;
  9542. /**
  9543. * Defines the green component (between 0 and 1, default is 0)
  9544. */
  9545. g: number;
  9546. /**
  9547. * Defines the blue component (between 0 and 1, default is 0)
  9548. */
  9549. b: number;
  9550. /**
  9551. * Defines the alpha component (between 0 and 1, default is 1)
  9552. */
  9553. a: number;
  9554. /**
  9555. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  9556. * @param r defines the red component (between 0 and 1, default is 0)
  9557. * @param g defines the green component (between 0 and 1, default is 0)
  9558. * @param b defines the blue component (between 0 and 1, default is 0)
  9559. * @param a defines the alpha component (between 0 and 1, default is 1)
  9560. */
  9561. constructor(
  9562. /**
  9563. * Defines the red component (between 0 and 1, default is 0)
  9564. */
  9565. r?: number,
  9566. /**
  9567. * Defines the green component (between 0 and 1, default is 0)
  9568. */
  9569. g?: number,
  9570. /**
  9571. * Defines the blue component (between 0 and 1, default is 0)
  9572. */
  9573. b?: number,
  9574. /**
  9575. * Defines the alpha component (between 0 and 1, default is 1)
  9576. */
  9577. a?: number);
  9578. /**
  9579. * Adds in place the passed Color4 values to the current Color4 object
  9580. * @param right defines the second operand
  9581. * @returns the current updated Color4 object
  9582. */
  9583. addInPlace(right: Color4): Color4;
  9584. /**
  9585. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  9586. * @returns the new array
  9587. */
  9588. asArray(): number[];
  9589. /**
  9590. * Stores from the starting index in the passed array the Color4 successive values
  9591. * @param array defines the array where to store the r,g,b components
  9592. * @param index defines an optional index in the target array to define where to start storing values
  9593. * @returns the current Color4 object
  9594. */
  9595. toArray(array: number[], index?: number): Color4;
  9596. /**
  9597. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  9598. * @param right defines the second operand
  9599. * @returns a new Color4 object
  9600. */
  9601. add(right: Color4): Color4;
  9602. /**
  9603. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  9604. * @param right defines the second operand
  9605. * @returns a new Color4 object
  9606. */
  9607. subtract(right: Color4): Color4;
  9608. /**
  9609. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  9610. * @param right defines the second operand
  9611. * @param result defines the Color4 object where to store the result
  9612. * @returns the current Color4 object
  9613. */
  9614. subtractToRef(right: Color4, result: Color4): Color4;
  9615. /**
  9616. * Creates a new Color4 with the current Color4 values multiplied by scale
  9617. * @param scale defines the scaling factor to apply
  9618. * @returns a new Color4 object
  9619. */
  9620. scale(scale: number): Color4;
  9621. /**
  9622. * Multiplies the current Color4 values by scale and stores the result in "result"
  9623. * @param scale defines the scaling factor to apply
  9624. * @param result defines the Color4 object where to store the result
  9625. * @returns the current unmodified Color4
  9626. */
  9627. scaleToRef(scale: number, result: Color4): Color4;
  9628. /**
  9629. * Scale the current Color4 values by a factor and add the result to a given Color4
  9630. * @param scale defines the scale factor
  9631. * @param result defines the Color4 object where to store the result
  9632. * @returns the unmodified current Color4
  9633. */
  9634. scaleAndAddToRef(scale: number, result: Color4): Color4;
  9635. /**
  9636. * Clamps the rgb values by the min and max values and stores the result into "result"
  9637. * @param min defines minimum clamping value (default is 0)
  9638. * @param max defines maximum clamping value (default is 1)
  9639. * @param result defines color to store the result into.
  9640. * @returns the cuurent Color4
  9641. */
  9642. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  9643. /**
  9644. * Multipy an Color4 value by another and return a new Color4 object
  9645. * @param color defines the Color4 value to multiply by
  9646. * @returns a new Color4 object
  9647. */
  9648. multiply(color: Color4): Color4;
  9649. /**
  9650. * Multipy a Color4 value by another and push the result in a reference value
  9651. * @param color defines the Color4 value to multiply by
  9652. * @param result defines the Color4 to fill the result in
  9653. * @returns the result Color4
  9654. */
  9655. multiplyToRef(color: Color4, result: Color4): Color4;
  9656. /**
  9657. * Creates a string with the Color4 current values
  9658. * @returns the string representation of the Color4 object
  9659. */
  9660. toString(): string;
  9661. /**
  9662. * Returns the string "Color4"
  9663. * @returns "Color4"
  9664. */
  9665. getClassName(): string;
  9666. /**
  9667. * Compute the Color4 hash code
  9668. * @returns an unique number that can be used to hash Color4 objects
  9669. */
  9670. getHashCode(): number;
  9671. /**
  9672. * Creates a new Color4 copied from the current one
  9673. * @returns a new Color4 object
  9674. */
  9675. clone(): Color4;
  9676. /**
  9677. * Copies the passed Color4 values into the current one
  9678. * @param source defines the source Color4 object
  9679. * @returns the current updated Color4 object
  9680. */
  9681. copyFrom(source: Color4): Color4;
  9682. /**
  9683. * Copies the passed float values into the current one
  9684. * @param r defines the red component to read from
  9685. * @param g defines the green component to read from
  9686. * @param b defines the blue component to read from
  9687. * @param a defines the alpha component to read from
  9688. * @returns the current updated Color4 object
  9689. */
  9690. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  9691. /**
  9692. * Copies the passed float values into the current one
  9693. * @param r defines the red component to read from
  9694. * @param g defines the green component to read from
  9695. * @param b defines the blue component to read from
  9696. * @param a defines the alpha component to read from
  9697. * @returns the current updated Color4 object
  9698. */
  9699. set(r: number, g: number, b: number, a: number): Color4;
  9700. /**
  9701. * Compute the Color4 hexadecimal code as a string
  9702. * @returns a string containing the hexadecimal representation of the Color4 object
  9703. */
  9704. toHexString(): string;
  9705. /**
  9706. * Computes a new Color4 converted from the current one to linear space
  9707. * @returns a new Color4 object
  9708. */
  9709. toLinearSpace(): Color4;
  9710. /**
  9711. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  9712. * @param convertedColor defines the Color4 object where to store the linear space version
  9713. * @returns the unmodified Color4
  9714. */
  9715. toLinearSpaceToRef(convertedColor: Color4): Color4;
  9716. /**
  9717. * Computes a new Color4 converted from the current one to gamma space
  9718. * @returns a new Color4 object
  9719. */
  9720. toGammaSpace(): Color4;
  9721. /**
  9722. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  9723. * @param convertedColor defines the Color4 object where to store the gamma space version
  9724. * @returns the unmodified Color4
  9725. */
  9726. toGammaSpaceToRef(convertedColor: Color4): Color4;
  9727. /**
  9728. * Creates a new Color4 from the string containing valid hexadecimal values
  9729. * @param hex defines a string containing valid hexadecimal values
  9730. * @returns a new Color4 object
  9731. */
  9732. static FromHexString(hex: string): Color4;
  9733. /**
  9734. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  9735. * @param left defines the start value
  9736. * @param right defines the end value
  9737. * @param amount defines the gradient factor
  9738. * @returns a new Color4 object
  9739. */
  9740. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  9741. /**
  9742. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  9743. * @param left defines the start value
  9744. * @param right defines the end value
  9745. * @param amount defines the gradient factor
  9746. * @param result defines the Color4 object where to store data
  9747. */
  9748. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  9749. /**
  9750. * Creates a new Color4 from the starting index element of the passed array
  9751. * @param array defines the source array to read from
  9752. * @param offset defines the offset in the source array
  9753. * @returns a new Color4 object
  9754. */
  9755. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  9756. /**
  9757. * Creates a new Color3 from integer values (< 256)
  9758. * @param r defines the red component to read from (value between 0 and 255)
  9759. * @param g defines the green component to read from (value between 0 and 255)
  9760. * @param b defines the blue component to read from (value between 0 and 255)
  9761. * @param a defines the alpha component to read from (value between 0 and 255)
  9762. * @returns a new Color3 object
  9763. */
  9764. static FromInts(r: number, g: number, b: number, a: number): Color4;
  9765. /**
  9766. * Check the content of a given array and convert it to an array containing RGBA data
  9767. * If the original array was already containing count * 4 values then it is returned directly
  9768. * @param colors defines the array to check
  9769. * @param count defines the number of RGBA data to expect
  9770. * @returns an array containing count * 4 values (RGBA)
  9771. */
  9772. static CheckColors4(colors: number[], count: number): number[];
  9773. }
  9774. class Vector2 {
  9775. x: number;
  9776. y: number;
  9777. /**
  9778. * Creates a new Vector2 from the passed x and y coordinates.
  9779. */
  9780. constructor(x: number, y: number);
  9781. /**
  9782. * Returns a string with the Vector2 coordinates.
  9783. */
  9784. toString(): string;
  9785. /**
  9786. * Returns the string "Vector2"
  9787. */
  9788. getClassName(): string;
  9789. /**
  9790. * Returns the Vector2 hash code as a number.
  9791. */
  9792. getHashCode(): number;
  9793. /**
  9794. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  9795. * Returns the Vector2.
  9796. */
  9797. toArray(array: FloatArray, index?: number): Vector2;
  9798. /**
  9799. * Returns a new array with 2 elements : the Vector2 coordinates.
  9800. */
  9801. asArray(): number[];
  9802. /**
  9803. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  9804. * Returns the updated Vector2.
  9805. */
  9806. copyFrom(source: Vector2): Vector2;
  9807. /**
  9808. * Sets the Vector2 coordinates with the passed floats.
  9809. * Returns the updated Vector2.
  9810. */
  9811. copyFromFloats(x: number, y: number): Vector2;
  9812. /**
  9813. * Sets the Vector2 coordinates with the passed floats.
  9814. * Returns the updated Vector2.
  9815. */
  9816. set(x: number, y: number): Vector2;
  9817. /**
  9818. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  9819. */
  9820. add(otherVector: Vector2): Vector2;
  9821. /**
  9822. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  9823. * Returns the Vector2.
  9824. */
  9825. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  9826. /**
  9827. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  9828. * Returns the updated Vector2.
  9829. */
  9830. addInPlace(otherVector: Vector2): Vector2;
  9831. /**
  9832. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  9833. */
  9834. addVector3(otherVector: Vector3): Vector2;
  9835. /**
  9836. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  9837. */
  9838. subtract(otherVector: Vector2): Vector2;
  9839. /**
  9840. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  9841. * Returns the Vector2.
  9842. */
  9843. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  9844. /**
  9845. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  9846. * Returns the updated Vector2.
  9847. */
  9848. subtractInPlace(otherVector: Vector2): Vector2;
  9849. /**
  9850. * Multiplies in place the current Vector2 coordinates by the passed ones.
  9851. * Returns the updated Vector2.
  9852. */
  9853. multiplyInPlace(otherVector: Vector2): Vector2;
  9854. /**
  9855. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  9856. */
  9857. multiply(otherVector: Vector2): Vector2;
  9858. /**
  9859. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  9860. * Returns the Vector2.
  9861. */
  9862. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  9863. /**
  9864. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  9865. */
  9866. multiplyByFloats(x: number, y: number): Vector2;
  9867. /**
  9868. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  9869. */
  9870. divide(otherVector: Vector2): Vector2;
  9871. /**
  9872. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  9873. * Returns the Vector2.
  9874. */
  9875. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  9876. /**
  9877. * Divides the current Vector3 coordinates by the passed ones.
  9878. * Returns the updated Vector3.
  9879. */
  9880. divideInPlace(otherVector: Vector2): Vector2;
  9881. /**
  9882. * Returns a new Vector2 with current Vector2 negated coordinates.
  9883. */
  9884. negate(): Vector2;
  9885. /**
  9886. * Multiply the Vector2 coordinates by scale.
  9887. * Returns the updated Vector2.
  9888. */
  9889. scaleInPlace(scale: number): Vector2;
  9890. /**
  9891. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  9892. */
  9893. scale(scale: number): Vector2;
  9894. /**
  9895. * Scale the current Vector2 values by a factor to a given Vector2
  9896. * @param scale defines the scale factor
  9897. * @param result defines the Vector2 object where to store the result
  9898. * @returns the unmodified current Vector2
  9899. */
  9900. scaleToRef(scale: number, result: Vector2): Vector2;
  9901. /**
  9902. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  9903. * @param scale defines the scale factor
  9904. * @param result defines the Vector2 object where to store the result
  9905. * @returns the unmodified current Vector2
  9906. */
  9907. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  9908. /**
  9909. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  9910. */
  9911. equals(otherVector: Vector2): boolean;
  9912. /**
  9913. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  9914. */
  9915. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  9916. /**
  9917. * Returns the vector length (float).
  9918. */
  9919. length(): number;
  9920. /**
  9921. * Returns the vector squared length (float);
  9922. */
  9923. lengthSquared(): number;
  9924. /**
  9925. * Normalize the vector.
  9926. * Returns the updated Vector2.
  9927. */
  9928. normalize(): Vector2;
  9929. /**
  9930. * Returns a new Vector2 copied from the Vector2.
  9931. */
  9932. clone(): Vector2;
  9933. /**
  9934. * Returns a new Vector2(0, 0)
  9935. */
  9936. static Zero(): Vector2;
  9937. /**
  9938. * Returns a new Vector2(1, 1)
  9939. */
  9940. static One(): Vector2;
  9941. /**
  9942. * Returns a new Vector2 set from the passed index element of the passed array.
  9943. */
  9944. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  9945. /**
  9946. * Sets "result" from the passed index element of the passed array.
  9947. */
  9948. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  9949. /**
  9950. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  9951. */
  9952. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  9953. /**
  9954. * 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".
  9955. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  9956. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  9957. */
  9958. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  9959. /**
  9960. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  9961. */
  9962. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  9963. /**
  9964. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  9965. */
  9966. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  9967. /**
  9968. * Returns the dot product (float) of the vector "left" and the vector "right".
  9969. */
  9970. static Dot(left: Vector2, right: Vector2): number;
  9971. /**
  9972. * Returns a new Vector2 equal to the normalized passed vector.
  9973. */
  9974. static Normalize(vector: Vector2): Vector2;
  9975. /**
  9976. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  9977. */
  9978. static Minimize(left: Vector2, right: Vector2): Vector2;
  9979. /**
  9980. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  9981. */
  9982. static Maximize(left: Vector2, right: Vector2): Vector2;
  9983. /**
  9984. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  9985. */
  9986. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  9987. /**
  9988. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  9989. */
  9990. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  9991. /**
  9992. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  9993. */
  9994. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  9995. /**
  9996. * Returns the distance (float) between the vectors "value1" and "value2".
  9997. */
  9998. static Distance(value1: Vector2, value2: Vector2): number;
  9999. /**
  10000. * Returns the squared distance (float) between the vectors "value1" and "value2".
  10001. */
  10002. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  10003. /**
  10004. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  10005. */
  10006. static Center(value1: Vector2, value2: Vector2): Vector2;
  10007. /**
  10008. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  10009. */
  10010. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  10011. }
  10012. /**
  10013. * Classed used to store (x,y,z) vector representation
  10014. * A Vector3 is the main object used in 3D geometry
  10015. * It can represent etiher the coordinates of a point the space, either a direction
  10016. * Reminder: Babylon.js uses a left handed forward facing system
  10017. */
  10018. class Vector3 {
  10019. /**
  10020. * Defines the first coordinates (on X axis)
  10021. */
  10022. x: number;
  10023. /**
  10024. * Defines the second coordinates (on Y axis)
  10025. */
  10026. y: number;
  10027. /**
  10028. * Defines the third coordinates (on Z axis)
  10029. */
  10030. z: number;
  10031. /**
  10032. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  10033. * @param x defines the first coordinates (on X axis)
  10034. * @param y defines the second coordinates (on Y axis)
  10035. * @param z defines the third coordinates (on Z axis)
  10036. */
  10037. constructor(
  10038. /**
  10039. * Defines the first coordinates (on X axis)
  10040. */
  10041. x: number,
  10042. /**
  10043. * Defines the second coordinates (on Y axis)
  10044. */
  10045. y: number,
  10046. /**
  10047. * Defines the third coordinates (on Z axis)
  10048. */
  10049. z: number);
  10050. /**
  10051. * Creates a string representation of the Vector3
  10052. * @returns a string with the Vector3 coordinates.
  10053. */
  10054. toString(): string;
  10055. /**
  10056. * Gets the class name
  10057. * @returns the string "Vector3"
  10058. */
  10059. getClassName(): string;
  10060. /**
  10061. * Creates the Vector3 hash code
  10062. * @returns a number which tends to be unique between Vector3 instances
  10063. */
  10064. getHashCode(): number;
  10065. /**
  10066. * Creates an array containing three elements : the coordinates of the Vector3
  10067. * @returns a new array of numbers
  10068. */
  10069. asArray(): number[];
  10070. /**
  10071. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  10072. * @param array defines the destination array
  10073. * @param index defines the offset in the destination array
  10074. * @returns the current Vector3
  10075. */
  10076. toArray(array: FloatArray, index?: number): Vector3;
  10077. /**
  10078. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  10079. * @returns a new Quaternion object, computed from the Vector3 coordinates
  10080. */
  10081. toQuaternion(): Quaternion;
  10082. /**
  10083. * Adds the passed vector to the current Vector3
  10084. * @param otherVector defines the second operand
  10085. * @returns the current updated Vector3
  10086. */
  10087. addInPlace(otherVector: Vector3): Vector3;
  10088. /**
  10089. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  10090. * @param otherVector defines the second operand
  10091. * @returns the resulting Vector3
  10092. */
  10093. add(otherVector: Vector3): Vector3;
  10094. /**
  10095. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  10096. * @param otherVector defines the second operand
  10097. * @param result defines the Vector3 object where to store the result
  10098. * @returns the current Vector3
  10099. */
  10100. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  10101. /**
  10102. * Subtract the passed vector from the current Vector3
  10103. * @param otherVector defines the second operand
  10104. * @returns the current updated Vector3
  10105. */
  10106. subtractInPlace(otherVector: Vector3): Vector3;
  10107. /**
  10108. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  10109. * @param otherVector defines the second operand
  10110. * @returns the resulting Vector3
  10111. */
  10112. subtract(otherVector: Vector3): Vector3;
  10113. /**
  10114. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  10115. * @param otherVector defines the second operand
  10116. * @param result defines the Vector3 object where to store the result
  10117. * @returns the current Vector3
  10118. */
  10119. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  10120. /**
  10121. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  10122. * @param x defines the x coordinate of the operand
  10123. * @param y defines the y coordinate of the operand
  10124. * @param z defines the z coordinate of the operand
  10125. * @returns the resulting Vector3
  10126. */
  10127. subtractFromFloats(x: number, y: number, z: number): Vector3;
  10128. /**
  10129. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  10130. * @param x defines the x coordinate of the operand
  10131. * @param y defines the y coordinate of the operand
  10132. * @param z defines the z coordinate of the operand
  10133. * @param result defines the Vector3 object where to store the result
  10134. * @returns the current Vector3
  10135. */
  10136. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  10137. /**
  10138. * Gets a new Vector3 set with the current Vector3 negated coordinates
  10139. * @returns a new Vector3
  10140. */
  10141. negate(): Vector3;
  10142. /**
  10143. * Multiplies the Vector3 coordinates by the float "scale"
  10144. * @param scale defines the multiplier factor
  10145. * @returns the current updated Vector3
  10146. */
  10147. scaleInPlace(scale: number): Vector3;
  10148. /**
  10149. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  10150. * @param scale defines the multiplier factor
  10151. * @returns a new Vector3
  10152. */
  10153. scale(scale: number): Vector3;
  10154. /**
  10155. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  10156. * @param scale defines the multiplier factor
  10157. * @param result defines the Vector3 object where to store the result
  10158. * @returns the current Vector3
  10159. */
  10160. scaleToRef(scale: number, result: Vector3): Vector3;
  10161. /**
  10162. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  10163. * @param scale defines the scale factor
  10164. * @param result defines the Vector3 object where to store the result
  10165. * @returns the unmodified current Vector3
  10166. */
  10167. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  10168. /**
  10169. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  10170. * @param otherVector defines the second operand
  10171. * @returns true if both vectors are equals
  10172. */
  10173. equals(otherVector: Vector3): boolean;
  10174. /**
  10175. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  10176. * @param otherVector defines the second operand
  10177. * @param epsilon defines the minimal distance to define values as equals
  10178. * @returns true if both vectors are distant less than epsilon
  10179. */
  10180. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  10181. /**
  10182. * Returns true if the current Vector3 coordinates equals the passed floats
  10183. * @param x defines the x coordinate of the operand
  10184. * @param y defines the y coordinate of the operand
  10185. * @param z defines the z coordinate of the operand
  10186. * @returns true if both vectors are equals
  10187. */
  10188. equalsToFloats(x: number, y: number, z: number): boolean;
  10189. /**
  10190. * Multiplies the current Vector3 coordinates by the passed ones
  10191. * @param otherVector defines the second operand
  10192. * @returns the current updated Vector3
  10193. */
  10194. multiplyInPlace(otherVector: Vector3): Vector3;
  10195. /**
  10196. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  10197. * @param otherVector defines the second operand
  10198. * @returns the new Vector3
  10199. */
  10200. multiply(otherVector: Vector3): Vector3;
  10201. /**
  10202. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  10203. * @param otherVector defines the second operand
  10204. * @param result defines the Vector3 object where to store the result
  10205. * @returns the current Vector3
  10206. */
  10207. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  10208. /**
  10209. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  10210. * @param x defines the x coordinate of the operand
  10211. * @param y defines the y coordinate of the operand
  10212. * @param z defines the z coordinate of the operand
  10213. * @returns the new Vector3
  10214. */
  10215. multiplyByFloats(x: number, y: number, z: number): Vector3;
  10216. /**
  10217. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  10218. * @param otherVector defines the second operand
  10219. * @returns the new Vector3
  10220. */
  10221. divide(otherVector: Vector3): Vector3;
  10222. /**
  10223. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  10224. * @param otherVector defines the second operand
  10225. * @param result defines the Vector3 object where to store the result
  10226. * @returns the current Vector3
  10227. */
  10228. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  10229. /**
  10230. * Divides the current Vector3 coordinates by the passed ones.
  10231. * @param otherVector defines the second operand
  10232. * @returns the current updated Vector3
  10233. */
  10234. divideInPlace(otherVector: Vector3): Vector3;
  10235. /**
  10236. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  10237. * @param other defines the second operand
  10238. * @returns the current updated Vector3
  10239. */
  10240. minimizeInPlace(other: Vector3): Vector3;
  10241. /**
  10242. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  10243. * @param other defines the second operand
  10244. * @returns the current updated Vector3
  10245. */
  10246. maximizeInPlace(other: Vector3): Vector3;
  10247. /**
  10248. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  10249. */
  10250. readonly isNonUniform: boolean;
  10251. /**
  10252. * Gets the length of the Vector3
  10253. * @returns the length of the Vecto3
  10254. */
  10255. length(): number;
  10256. /**
  10257. * Gets the squared length of the Vector3
  10258. * @returns squared length of the Vector3
  10259. */
  10260. lengthSquared(): number;
  10261. /**
  10262. * Normalize the current Vector3.
  10263. * Please note that this is an in place operation.
  10264. * @returns the current updated Vector3
  10265. */
  10266. normalize(): Vector3;
  10267. /**
  10268. * Normalize the current Vector3 to a new vector
  10269. * @returns the new Vector3
  10270. */
  10271. normalizeToNew(): Vector3;
  10272. /**
  10273. * Normalize the current Vector3 to the reference
  10274. * @param reference define the Vector3 to update
  10275. * @returns the updated Vector3
  10276. */
  10277. normalizeToRef(reference: Vector3): Vector3;
  10278. /**
  10279. * Creates a new Vector3 copied from the current Vector3
  10280. * @returns the new Vector3
  10281. */
  10282. clone(): Vector3;
  10283. /**
  10284. * Copies the passed vector coordinates to the current Vector3 ones
  10285. * @param source defines the source Vector3
  10286. * @returns the current updated Vector3
  10287. */
  10288. copyFrom(source: Vector3): Vector3;
  10289. /**
  10290. * Copies the passed floats to the current Vector3 coordinates
  10291. * @param x defines the x coordinate of the operand
  10292. * @param y defines the y coordinate of the operand
  10293. * @param z defines the z coordinate of the operand
  10294. * @returns the current updated Vector3
  10295. */
  10296. copyFromFloats(x: number, y: number, z: number): Vector3;
  10297. /**
  10298. * Copies the passed floats to the current Vector3 coordinates
  10299. * @param x defines the x coordinate of the operand
  10300. * @param y defines the y coordinate of the operand
  10301. * @param z defines the z coordinate of the operand
  10302. * @returns the current updated Vector3
  10303. */
  10304. set(x: number, y: number, z: number): Vector3;
  10305. /**
  10306. * Get the clip factor between two vectors
  10307. * @param vector0 defines the first operand
  10308. * @param vector1 defines the second operand
  10309. * @param axis defines the axis to use
  10310. * @param size defines the size along the axis
  10311. * @returns the clip factor
  10312. */
  10313. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  10314. /**
  10315. * Get angle between two vectors
  10316. * @param vector0 angle between vector0 and vector1
  10317. * @param vector1 angle between vector0 and vector1
  10318. * @param normal direction of the normal
  10319. * @return the angle between vector0 and vector1
  10320. */
  10321. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  10322. /**
  10323. * Returns a new Vector3 set from the index "offset" of the passed array
  10324. * @param array defines the source array
  10325. * @param offset defines the offset in the source array
  10326. * @returns the new Vector3
  10327. */
  10328. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  10329. /**
  10330. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  10331. * This function is deprecated. Use FromArray instead
  10332. * @param array defines the source array
  10333. * @param offset defines the offset in the source array
  10334. * @returns the new Vector3
  10335. */
  10336. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  10337. /**
  10338. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  10339. * @param array defines the source array
  10340. * @param offset defines the offset in the source array
  10341. * @param result defines the Vector3 where to store the result
  10342. */
  10343. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  10344. /**
  10345. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  10346. * This function is deprecated. Use FromArrayToRef instead.
  10347. * @param array defines the source array
  10348. * @param offset defines the offset in the source array
  10349. * @param result defines the Vector3 where to store the result
  10350. */
  10351. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  10352. /**
  10353. * Sets the passed vector "result" with the passed floats.
  10354. * @param x defines the x coordinate of the source
  10355. * @param y defines the y coordinate of the source
  10356. * @param z defines the z coordinate of the source
  10357. * @param result defines the Vector3 where to store the result
  10358. */
  10359. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  10360. /**
  10361. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  10362. * @returns a new empty Vector3
  10363. */
  10364. static Zero(): Vector3;
  10365. /**
  10366. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  10367. * @returns a new unit Vector3
  10368. */
  10369. static One(): Vector3;
  10370. /**
  10371. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  10372. * @returns a new up Vector3
  10373. */
  10374. static Up(): Vector3;
  10375. /**
  10376. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  10377. * @returns a new forward Vector3
  10378. */
  10379. static Forward(): Vector3;
  10380. /**
  10381. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  10382. * @returns a new right Vector3
  10383. */
  10384. static Right(): Vector3;
  10385. /**
  10386. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  10387. * @returns a new left Vector3
  10388. */
  10389. static Left(): Vector3;
  10390. /**
  10391. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  10392. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  10393. * @param vector defines the Vector3 to transform
  10394. * @param transformation defines the transformation matrix
  10395. * @returns the transformed Vector3
  10396. */
  10397. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  10398. /**
  10399. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  10400. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  10401. * @param vector defines the Vector3 to transform
  10402. * @param transformation defines the transformation matrix
  10403. * @param result defines the Vector3 where to store the result
  10404. */
  10405. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  10406. /**
  10407. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  10408. * This method computes tranformed coordinates only, not transformed direction vectors
  10409. * @param x define the x coordinate of the source vector
  10410. * @param y define the y coordinate of the source vector
  10411. * @param z define the z coordinate of the source vector
  10412. * @param transformation defines the transformation matrix
  10413. * @param result defines the Vector3 where to store the result
  10414. */
  10415. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  10416. /**
  10417. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  10418. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  10419. * @param vector defines the Vector3 to transform
  10420. * @param transformation defines the transformation matrix
  10421. * @returns the new Vector3
  10422. */
  10423. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  10424. /**
  10425. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  10426. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  10427. * @param vector defines the Vector3 to transform
  10428. * @param transformation defines the transformation matrix
  10429. * @param result defines the Vector3 where to store the result
  10430. */
  10431. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  10432. /**
  10433. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  10434. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  10435. * @param x define the x coordinate of the source vector
  10436. * @param y define the y coordinate of the source vector
  10437. * @param z define the z coordinate of the source vector
  10438. * @param transformation defines the transformation matrix
  10439. * @param result defines the Vector3 where to store the result
  10440. */
  10441. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  10442. /**
  10443. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  10444. * @param value1 defines the first control point
  10445. * @param value2 defines the second control point
  10446. * @param value3 defines the third control point
  10447. * @param value4 defines the fourth control point
  10448. * @param amount defines the amount on the spline to use
  10449. * @returns the new Vector3
  10450. */
  10451. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  10452. /**
  10453. * 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"
  10454. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  10455. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  10456. * @param value defines the current value
  10457. * @param min defines the lower range value
  10458. * @param max defines the upper range value
  10459. * @returns the new Vector3
  10460. */
  10461. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  10462. /**
  10463. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  10464. * @param value1 defines the first control point
  10465. * @param tangent1 defines the first tangent vector
  10466. * @param value2 defines the second control point
  10467. * @param tangent2 defines the second tangent vector
  10468. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  10469. * @returns the new Vector3
  10470. */
  10471. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  10472. /**
  10473. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  10474. * @param start defines the start value
  10475. * @param end defines the end value
  10476. * @param amount max defines amount between both (between 0 and 1)
  10477. * @returns the new Vector3
  10478. */
  10479. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  10480. /**
  10481. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  10482. * @param start defines the start value
  10483. * @param end defines the end value
  10484. * @param amount max defines amount between both (between 0 and 1)
  10485. * @param result defines the Vector3 where to store the result
  10486. */
  10487. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  10488. /**
  10489. * Returns the dot product (float) between the vectors "left" and "right"
  10490. * @param left defines the left operand
  10491. * @param right defines the right operand
  10492. * @returns the dot product
  10493. */
  10494. static Dot(left: Vector3, right: Vector3): number;
  10495. /**
  10496. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  10497. * The cross product is then orthogonal to both "left" and "right"
  10498. * @param left defines the left operand
  10499. * @param right defines the right operand
  10500. * @returns the cross product
  10501. */
  10502. static Cross(left: Vector3, right: Vector3): Vector3;
  10503. /**
  10504. * Sets the passed vector "result" with the cross product of "left" and "right"
  10505. * The cross product is then orthogonal to both "left" and "right"
  10506. * @param left defines the left operand
  10507. * @param right defines the right operand
  10508. * @param result defines the Vector3 where to store the result
  10509. */
  10510. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  10511. /**
  10512. * Returns a new Vector3 as the normalization of the passed vector
  10513. * @param vector defines the Vector3 to normalize
  10514. * @returns the new Vector3
  10515. */
  10516. static Normalize(vector: Vector3): Vector3;
  10517. /**
  10518. * Sets the passed vector "result" with the normalization of the passed first vector
  10519. * @param vector defines the Vector3 to normalize
  10520. * @param result defines the Vector3 where to store the result
  10521. */
  10522. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  10523. private static _viewportMatrixCache;
  10524. /**
  10525. * Project a Vector3 onto screen space
  10526. * @param vector defines the Vector3 to project
  10527. * @param world defines the world matrix to use
  10528. * @param transform defines the transform (view x projection) matrix to use
  10529. * @param viewport defines the screen viewport to use
  10530. * @returns the new Vector3
  10531. */
  10532. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  10533. /**
  10534. * Unproject from screen space to object space
  10535. * @param source defines the screen space Vector3 to use
  10536. * @param viewportWidth defines the current width of the viewport
  10537. * @param viewportHeight defines the current height of the viewport
  10538. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10539. * @param transform defines the transform (view x projection) matrix to use
  10540. * @returns the new Vector3
  10541. */
  10542. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  10543. /**
  10544. * Unproject from screen space to object space
  10545. * @param source defines the screen space Vector3 to use
  10546. * @param viewportWidth defines the current width of the viewport
  10547. * @param viewportHeight defines the current height of the viewport
  10548. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10549. * @param view defines the view matrix to use
  10550. * @param projection defines the projection matrix to use
  10551. * @returns the new Vector3
  10552. */
  10553. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  10554. /**
  10555. * Unproject from screen space to object space
  10556. * @param source defines the screen space Vector3 to use
  10557. * @param viewportWidth defines the current width of the viewport
  10558. * @param viewportHeight defines the current height of the viewport
  10559. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10560. * @param view defines the view matrix to use
  10561. * @param projection defines the projection matrix to use
  10562. * @param result defines the Vector3 where to store the result
  10563. */
  10564. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  10565. /**
  10566. * Unproject from screen space to object space
  10567. * @param sourceX defines the screen space x coordinate to use
  10568. * @param sourceY defines the screen space y coordinate to use
  10569. * @param sourceZ defines the screen space z coordinate to use
  10570. * @param viewportWidth defines the current width of the viewport
  10571. * @param viewportHeight defines the current height of the viewport
  10572. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10573. * @param view defines the view matrix to use
  10574. * @param projection defines the projection matrix to use
  10575. * @param result defines the Vector3 where to store the result
  10576. */
  10577. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  10578. /**
  10579. * Gets the minimal coordinate values between two Vector3
  10580. * @param left defines the first operand
  10581. * @param right defines the second operand
  10582. * @returns the new Vector3
  10583. */
  10584. static Minimize(left: Vector3, right: Vector3): Vector3;
  10585. /**
  10586. * Gets the maximal coordinate values between two Vector3
  10587. * @param left defines the first operand
  10588. * @param right defines the second operand
  10589. * @returns the new Vector3
  10590. */
  10591. static Maximize(left: Vector3, right: Vector3): Vector3;
  10592. /**
  10593. * Returns the distance between the vectors "value1" and "value2"
  10594. * @param value1 defines the first operand
  10595. * @param value2 defines the second operand
  10596. * @returns the distance
  10597. */
  10598. static Distance(value1: Vector3, value2: Vector3): number;
  10599. /**
  10600. * Returns the squared distance between the vectors "value1" and "value2"
  10601. * @param value1 defines the first operand
  10602. * @param value2 defines the second operand
  10603. * @returns the squared distance
  10604. */
  10605. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  10606. /**
  10607. * Returns a new Vector3 located at the center between "value1" and "value2"
  10608. * @param value1 defines the first operand
  10609. * @param value2 defines the second operand
  10610. * @returns the new Vector3
  10611. */
  10612. static Center(value1: Vector3, value2: Vector3): Vector3;
  10613. /**
  10614. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  10615. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  10616. * to something in order to rotate it from its local system to the given target system
  10617. * Note: axis1, axis2 and axis3 are normalized during this operation
  10618. * @param axis1 defines the first axis
  10619. * @param axis2 defines the second axis
  10620. * @param axis3 defines the third axis
  10621. * @returns a new Vector3
  10622. */
  10623. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  10624. /**
  10625. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  10626. * @param axis1 defines the first axis
  10627. * @param axis2 defines the second axis
  10628. * @param axis3 defines the third axis
  10629. * @param ref defines the Vector3 where to store the result
  10630. */
  10631. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  10632. }
  10633. class Vector4 {
  10634. x: number;
  10635. y: number;
  10636. z: number;
  10637. w: number;
  10638. /**
  10639. * Creates a Vector4 object from the passed floats.
  10640. */
  10641. constructor(x: number, y: number, z: number, w: number);
  10642. /**
  10643. * Returns the string with the Vector4 coordinates.
  10644. */
  10645. toString(): string;
  10646. /**
  10647. * Returns the string "Vector4".
  10648. */
  10649. getClassName(): string;
  10650. /**
  10651. * Returns the Vector4 hash code.
  10652. */
  10653. getHashCode(): number;
  10654. /**
  10655. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  10656. */
  10657. asArray(): number[];
  10658. /**
  10659. * Populates the passed array from the passed index with the Vector4 coordinates.
  10660. * Returns the Vector4.
  10661. */
  10662. toArray(array: FloatArray, index?: number): Vector4;
  10663. /**
  10664. * Adds the passed vector to the current Vector4.
  10665. * Returns the updated Vector4.
  10666. */
  10667. addInPlace(otherVector: Vector4): Vector4;
  10668. /**
  10669. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  10670. */
  10671. add(otherVector: Vector4): Vector4;
  10672. /**
  10673. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  10674. * Returns the current Vector4.
  10675. */
  10676. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  10677. /**
  10678. * Subtract in place the passed vector from the current Vector4.
  10679. * Returns the updated Vector4.
  10680. */
  10681. subtractInPlace(otherVector: Vector4): Vector4;
  10682. /**
  10683. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  10684. */
  10685. subtract(otherVector: Vector4): Vector4;
  10686. /**
  10687. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  10688. * Returns the current Vector4.
  10689. */
  10690. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  10691. /**
  10692. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  10693. */
  10694. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  10695. /**
  10696. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  10697. * Returns the current Vector4.
  10698. */
  10699. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  10700. /**
  10701. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  10702. */
  10703. negate(): Vector4;
  10704. /**
  10705. * Multiplies the current Vector4 coordinates by scale (float).
  10706. * Returns the updated Vector4.
  10707. */
  10708. scaleInPlace(scale: number): Vector4;
  10709. /**
  10710. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  10711. */
  10712. scale(scale: number): Vector4;
  10713. /**
  10714. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  10715. * Returns the current Vector4.
  10716. */
  10717. scaleToRef(scale: number, result: Vector4): Vector4;
  10718. /**
  10719. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  10720. * @param scale defines the scale factor
  10721. * @param result defines the Vector4 object where to store the result
  10722. * @returns the unmodified current Vector4
  10723. */
  10724. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  10725. /**
  10726. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  10727. */
  10728. equals(otherVector: Vector4): boolean;
  10729. /**
  10730. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  10731. */
  10732. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  10733. /**
  10734. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  10735. */
  10736. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  10737. /**
  10738. * Multiplies in place the current Vector4 by the passed one.
  10739. * Returns the updated Vector4.
  10740. */
  10741. multiplyInPlace(otherVector: Vector4): Vector4;
  10742. /**
  10743. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  10744. */
  10745. multiply(otherVector: Vector4): Vector4;
  10746. /**
  10747. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  10748. * Returns the current Vector4.
  10749. */
  10750. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  10751. /**
  10752. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  10753. */
  10754. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  10755. /**
  10756. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  10757. */
  10758. divide(otherVector: Vector4): Vector4;
  10759. /**
  10760. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  10761. * Returns the current Vector4.
  10762. */
  10763. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  10764. /**
  10765. * Divides the current Vector3 coordinates by the passed ones.
  10766. * @returns the updated Vector3.
  10767. */
  10768. divideInPlace(otherVector: Vector4): Vector4;
  10769. /**
  10770. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  10771. * @param other defines the second operand
  10772. * @returns the current updated Vector4
  10773. */
  10774. minimizeInPlace(other: Vector4): Vector4;
  10775. /**
  10776. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  10777. * @param other defines the second operand
  10778. * @returns the current updated Vector4
  10779. */
  10780. maximizeInPlace(other: Vector4): Vector4;
  10781. /**
  10782. * Returns the Vector4 length (float).
  10783. */
  10784. length(): number;
  10785. /**
  10786. * Returns the Vector4 squared length (float).
  10787. */
  10788. lengthSquared(): number;
  10789. /**
  10790. * Normalizes in place the Vector4.
  10791. * Returns the updated Vector4.
  10792. */
  10793. normalize(): Vector4;
  10794. /**
  10795. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  10796. */
  10797. toVector3(): Vector3;
  10798. /**
  10799. * Returns a new Vector4 copied from the current one.
  10800. */
  10801. clone(): Vector4;
  10802. /**
  10803. * Updates the current Vector4 with the passed one coordinates.
  10804. * Returns the updated Vector4.
  10805. */
  10806. copyFrom(source: Vector4): Vector4;
  10807. /**
  10808. * Updates the current Vector4 coordinates with the passed floats.
  10809. * Returns the updated Vector4.
  10810. */
  10811. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  10812. /**
  10813. * Updates the current Vector4 coordinates with the passed floats.
  10814. * Returns the updated Vector4.
  10815. */
  10816. set(x: number, y: number, z: number, w: number): Vector4;
  10817. /**
  10818. * Returns a new Vector4 set from the starting index of the passed array.
  10819. */
  10820. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  10821. /**
  10822. * Updates the passed vector "result" from the starting index of the passed array.
  10823. */
  10824. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  10825. /**
  10826. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  10827. */
  10828. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  10829. /**
  10830. * Updates the passed vector "result" coordinates from the passed floats.
  10831. */
  10832. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  10833. /**
  10834. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  10835. */
  10836. static Zero(): Vector4;
  10837. /**
  10838. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  10839. */
  10840. static One(): Vector4;
  10841. /**
  10842. * Returns a new normalized Vector4 from the passed one.
  10843. */
  10844. static Normalize(vector: Vector4): Vector4;
  10845. /**
  10846. * Updates the passed vector "result" from the normalization of the passed one.
  10847. */
  10848. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  10849. static Minimize(left: Vector4, right: Vector4): Vector4;
  10850. static Maximize(left: Vector4, right: Vector4): Vector4;
  10851. /**
  10852. * Returns the distance (float) between the vectors "value1" and "value2".
  10853. */
  10854. static Distance(value1: Vector4, value2: Vector4): number;
  10855. /**
  10856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  10857. */
  10858. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  10859. /**
  10860. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  10861. */
  10862. static Center(value1: Vector4, value2: Vector4): Vector4;
  10863. /**
  10864. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  10865. * This methods computes transformed normalized direction vectors only.
  10866. */
  10867. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  10868. /**
  10869. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  10870. * This methods computes transformed normalized direction vectors only.
  10871. */
  10872. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  10873. /**
  10874. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  10875. * This methods computes transformed normalized direction vectors only.
  10876. */
  10877. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  10878. }
  10879. interface ISize {
  10880. width: number;
  10881. height: number;
  10882. }
  10883. class Size implements ISize {
  10884. width: number;
  10885. height: number;
  10886. /**
  10887. * Creates a Size object from the passed width and height (floats).
  10888. */
  10889. constructor(width: number, height: number);
  10890. toString(): string;
  10891. /**
  10892. * Returns the string "Size"
  10893. */
  10894. getClassName(): string;
  10895. /**
  10896. * Returns the Size hash code.
  10897. */
  10898. getHashCode(): number;
  10899. /**
  10900. * Updates the current size from the passed one.
  10901. * Returns the updated Size.
  10902. */
  10903. copyFrom(src: Size): void;
  10904. /**
  10905. * Updates in place the current Size from the passed floats.
  10906. * Returns the updated Size.
  10907. */
  10908. copyFromFloats(width: number, height: number): Size;
  10909. /**
  10910. * Updates in place the current Size from the passed floats.
  10911. * Returns the updated Size.
  10912. */
  10913. set(width: number, height: number): Size;
  10914. /**
  10915. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  10916. */
  10917. multiplyByFloats(w: number, h: number): Size;
  10918. /**
  10919. * Returns a new Size copied from the passed one.
  10920. */
  10921. clone(): Size;
  10922. /**
  10923. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  10924. */
  10925. equals(other: Size): boolean;
  10926. /**
  10927. * Returns the surface of the Size : width * height (float).
  10928. */
  10929. readonly surface: number;
  10930. /**
  10931. * Returns a new Size set to (0.0, 0.0)
  10932. */
  10933. static Zero(): Size;
  10934. /**
  10935. * Returns a new Size set as the addition result of the current Size and the passed one.
  10936. */
  10937. add(otherSize: Size): Size;
  10938. /**
  10939. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  10940. */
  10941. subtract(otherSize: Size): Size;
  10942. /**
  10943. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  10944. */
  10945. static Lerp(start: Size, end: Size, amount: number): Size;
  10946. }
  10947. class Quaternion {
  10948. x: number;
  10949. y: number;
  10950. z: number;
  10951. w: number;
  10952. /**
  10953. * Creates a new Quaternion from the passed floats.
  10954. */
  10955. constructor(x?: number, y?: number, z?: number, w?: number);
  10956. /**
  10957. * Returns a string with the Quaternion coordinates.
  10958. */
  10959. toString(): string;
  10960. /**
  10961. * Returns the string "Quaternion".
  10962. */
  10963. getClassName(): string;
  10964. /**
  10965. * Returns the Quaternion hash code.
  10966. */
  10967. getHashCode(): number;
  10968. /**
  10969. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  10970. */
  10971. asArray(): number[];
  10972. /**
  10973. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  10974. */
  10975. equals(otherQuaternion: Quaternion): boolean;
  10976. /**
  10977. * Returns a new Quaternion copied from the current one.
  10978. */
  10979. clone(): Quaternion;
  10980. /**
  10981. * Updates the current Quaternion from the passed one coordinates.
  10982. * Returns the updated Quaterion.
  10983. */
  10984. copyFrom(other: Quaternion): Quaternion;
  10985. /**
  10986. * Updates the current Quaternion from the passed float coordinates.
  10987. * Returns the updated Quaterion.
  10988. */
  10989. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  10990. /**
  10991. * Updates the current Quaternion from the passed float coordinates.
  10992. * Returns the updated Quaterion.
  10993. */
  10994. set(x: number, y: number, z: number, w: number): Quaternion;
  10995. /**
  10996. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  10997. */
  10998. add(other: Quaternion): Quaternion;
  10999. /**
  11000. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  11001. */
  11002. subtract(other: Quaternion): Quaternion;
  11003. /**
  11004. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  11005. */
  11006. scale(value: number): Quaternion;
  11007. /**
  11008. * Scale the current Quaternion values by a factor to a given Quaternion
  11009. * @param scale defines the scale factor
  11010. * @param result defines the Quaternion object where to store the result
  11011. * @returns the unmodified current Quaternion
  11012. */
  11013. scaleToRef(scale: number, result: Quaternion): Quaternion;
  11014. /**
  11015. * Scale the current Quaternion values by a factor and add the result to a given Quaternion
  11016. * @param scale defines the scale factor
  11017. * @param result defines the Quaternion object where to store the result
  11018. * @returns the unmodified current Quaternion
  11019. */
  11020. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  11021. /**
  11022. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  11023. */
  11024. multiply(q1: Quaternion): Quaternion;
  11025. /**
  11026. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  11027. * Returns the current Quaternion.
  11028. */
  11029. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  11030. /**
  11031. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  11032. * Returns the updated Quaternion.
  11033. */
  11034. multiplyInPlace(q1: Quaternion): Quaternion;
  11035. /**
  11036. * Sets the passed "ref" with the conjugation of the current Quaternion.
  11037. * Returns the current Quaternion.
  11038. */
  11039. conjugateToRef(ref: Quaternion): Quaternion;
  11040. /**
  11041. * Conjugates in place the current Quaternion.
  11042. * Returns the updated Quaternion.
  11043. */
  11044. conjugateInPlace(): Quaternion;
  11045. /**
  11046. * Returns a new Quaternion as the conjugate of the current Quaternion.
  11047. */
  11048. conjugate(): Quaternion;
  11049. /**
  11050. * Returns the Quaternion length (float).
  11051. */
  11052. length(): number;
  11053. /**
  11054. * Normalize in place the current Quaternion.
  11055. * Returns the updated Quaternion.
  11056. */
  11057. normalize(): Quaternion;
  11058. /**
  11059. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion
  11060. * @param order is a reserved parameter and is ignore for now
  11061. * @returns the new Vector3
  11062. */
  11063. toEulerAngles(order?: string): Vector3;
  11064. /**
  11065. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion
  11066. * @param result defines the vector which will be filled with the Euler angles
  11067. * @param order is a reserved parameter and is ignore for now
  11068. * @returns the current Quaternion
  11069. */
  11070. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  11071. /**
  11072. * Updates the passed rotation matrix with the current Quaternion values.
  11073. * Returns the current Quaternion.
  11074. */
  11075. toRotationMatrix(result: Matrix): Quaternion;
  11076. /**
  11077. * Updates the current Quaternion from the passed rotation matrix values.
  11078. * Returns the updated Quaternion.
  11079. */
  11080. fromRotationMatrix(matrix: Matrix): Quaternion;
  11081. /**
  11082. * Returns a new Quaternion set from the passed rotation matrix values.
  11083. */
  11084. static FromRotationMatrix(matrix: Matrix): Quaternion;
  11085. /**
  11086. * Updates the passed quaternion "result" with the passed rotation matrix values.
  11087. */
  11088. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  11089. /**
  11090. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  11091. */
  11092. static Zero(): Quaternion;
  11093. /**
  11094. * Returns a new Quaternion as the inverted current Quaternion.
  11095. */
  11096. static Inverse(q: Quaternion): Quaternion;
  11097. /**
  11098. * Returns the identity Quaternion.
  11099. */
  11100. static Identity(): Quaternion;
  11101. static IsIdentity(quaternion: Quaternion): boolean;
  11102. /**
  11103. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  11104. */
  11105. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  11106. /**
  11107. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  11108. */
  11109. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  11110. /**
  11111. * Retuns a new Quaternion set from the starting index of the passed array.
  11112. */
  11113. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  11114. /**
  11115. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  11116. */
  11117. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  11118. /**
  11119. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  11120. */
  11121. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  11122. /**
  11123. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  11124. */
  11125. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  11126. /**
  11127. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  11128. */
  11129. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  11130. /**
  11131. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  11132. * cf to Vector3.RotationFromAxis() documentation.
  11133. * Note : axis1, axis2 and axis3 are normalized during this operation.
  11134. */
  11135. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  11136. /**
  11137. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  11138. * cf to Vector3.RotationFromAxis() documentation.
  11139. * Note : axis1, axis2 and axis3 are normalized during this operation.
  11140. */
  11141. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  11142. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  11143. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  11144. /**
  11145. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  11146. */
  11147. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  11148. }
  11149. class Matrix {
  11150. private static _tempQuaternion;
  11151. private static _xAxis;
  11152. private static _yAxis;
  11153. private static _zAxis;
  11154. private static _updateFlagSeed;
  11155. private static _identityReadOnly;
  11156. private _isIdentity;
  11157. private _isIdentityDirty;
  11158. updateFlag: number;
  11159. m: Float32Array;
  11160. _markAsUpdated(): void;
  11161. constructor();
  11162. /**
  11163. * Boolean : True is the matrix is the identity matrix
  11164. */
  11165. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  11166. /**
  11167. * Returns the matrix determinant (float).
  11168. */
  11169. determinant(): number;
  11170. /**
  11171. * Returns the matrix underlying array.
  11172. */
  11173. toArray(): Float32Array;
  11174. /**
  11175. * Returns the matrix underlying array.
  11176. */
  11177. asArray(): Float32Array;
  11178. /**
  11179. * Inverts in place the Matrix.
  11180. * Returns the Matrix inverted.
  11181. */
  11182. invert(): Matrix;
  11183. /**
  11184. * Sets all the matrix elements to zero.
  11185. * Returns the Matrix.
  11186. */
  11187. reset(): Matrix;
  11188. /**
  11189. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  11190. */
  11191. add(other: Matrix): Matrix;
  11192. /**
  11193. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  11194. * Returns the Matrix.
  11195. */
  11196. addToRef(other: Matrix, result: Matrix): Matrix;
  11197. /**
  11198. * Adds in place the passed matrix to the current Matrix.
  11199. * Returns the updated Matrix.
  11200. */
  11201. addToSelf(other: Matrix): Matrix;
  11202. /**
  11203. * Sets the passed matrix with the current inverted Matrix.
  11204. * Returns the unmodified current Matrix.
  11205. */
  11206. invertToRef(other: Matrix): Matrix;
  11207. /**
  11208. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  11209. * Returns the updated Matrix.
  11210. */
  11211. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  11212. /**
  11213. * Inserts the translation vector in the current Matrix.
  11214. * Returns the updated Matrix.
  11215. */
  11216. setTranslation(vector3: Vector3): Matrix;
  11217. /**
  11218. * Returns a new Vector3 as the extracted translation from the Matrix.
  11219. */
  11220. getTranslation(): Vector3;
  11221. /**
  11222. * Fill a Vector3 with the extracted translation from the Matrix.
  11223. */
  11224. getTranslationToRef(result: Vector3): Matrix;
  11225. /**
  11226. * Remove rotation and scaling part from the Matrix.
  11227. * Returns the updated Matrix.
  11228. */
  11229. removeRotationAndScaling(): Matrix;
  11230. /**
  11231. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  11232. */
  11233. multiply(other: Matrix): Matrix;
  11234. /**
  11235. * Updates the current Matrix from the passed one values.
  11236. * Returns the updated Matrix.
  11237. */
  11238. copyFrom(other: Matrix): Matrix;
  11239. /**
  11240. * Populates the passed array from the starting index with the Matrix values.
  11241. * Returns the Matrix.
  11242. */
  11243. copyToArray(array: Float32Array, offset?: number): Matrix;
  11244. /**
  11245. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  11246. */
  11247. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  11248. /**
  11249. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  11250. */
  11251. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  11252. /**
  11253. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  11254. */
  11255. equals(value: Matrix): boolean;
  11256. /**
  11257. * Returns a new Matrix from the current Matrix.
  11258. */
  11259. clone(): Matrix;
  11260. /**
  11261. * Returns the string "Matrix"
  11262. */
  11263. getClassName(): string;
  11264. /**
  11265. * Returns the Matrix hash code.
  11266. */
  11267. getHashCode(): number;
  11268. /**
  11269. * Decomposes the current Matrix into :
  11270. * - a scale vector3 passed as a reference to update,
  11271. * - a rotation quaternion passed as a reference to update,
  11272. * - a translation vector3 passed as a reference to update.
  11273. * Returns the true if operation was successful.
  11274. */
  11275. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  11276. /**
  11277. * Returns the index-th row of the current matrix as a new Vector4.
  11278. */
  11279. getRow(index: number): Nullable<Vector4>;
  11280. /**
  11281. * Sets the index-th row of the current matrix with the passed Vector4 values.
  11282. * Returns the updated Matrix.
  11283. */
  11284. setRow(index: number, row: Vector4): Matrix;
  11285. /**
  11286. * Compute the transpose of the matrix.
  11287. * Returns a new Matrix.
  11288. */
  11289. transpose(): Matrix;
  11290. /**
  11291. * Compute the transpose of the matrix.
  11292. * Returns the current matrix.
  11293. */
  11294. transposeToRef(result: Matrix): Matrix;
  11295. /**
  11296. * Sets the index-th row of the current matrix with the passed 4 x float values.
  11297. * Returns the updated Matrix.
  11298. */
  11299. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  11300. /**
  11301. * Compute a new Matrix set with the current Matrix values multiplied by scale (float)
  11302. * @param scale defines the scale factor
  11303. * @returns a new Matrix
  11304. */
  11305. scale(scale: number): Matrix;
  11306. /**
  11307. * Scale the current Matrix values by a factor to a given result Matrix
  11308. * @param scale defines the scale factor
  11309. * @param result defines the Matrix to store the result
  11310. * @returns the current Matrix
  11311. */
  11312. scaleToRef(scale: number, result: Matrix): Matrix;
  11313. /**
  11314. * Scale the current Matrix values by a factor and add the result to a given Matrix
  11315. * @param scale defines the scale factor
  11316. * @param result defines the Matrix to store the result
  11317. * @returns the current Matrix
  11318. */
  11319. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  11320. /**
  11321. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  11322. * @param ref matrix to store the result
  11323. */
  11324. toNormalMatrix(ref: Matrix): void;
  11325. /**
  11326. * Returns a new Matrix as the extracted rotation matrix from the current one.
  11327. */
  11328. getRotationMatrix(): Matrix;
  11329. /**
  11330. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  11331. * Returns the current Matrix.
  11332. */
  11333. getRotationMatrixToRef(result: Matrix): Matrix;
  11334. /**
  11335. * Returns a new Matrix set from the starting index of the passed array.
  11336. */
  11337. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  11338. /**
  11339. * Sets the passed "result" matrix from the starting index of the passed array.
  11340. */
  11341. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  11342. /**
  11343. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  11344. */
  11345. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  11346. /**
  11347. * Sets the passed matrix "result" with the 16 passed floats.
  11348. */
  11349. 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;
  11350. /**
  11351. * Static identity matrix to be used as readonly matrix
  11352. * Must not be updated.
  11353. */
  11354. static readonly IdentityReadOnly: Matrix;
  11355. /**
  11356. * Returns a new Matrix set from the 16 passed floats.
  11357. */
  11358. 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;
  11359. /**
  11360. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  11361. */
  11362. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  11363. /**
  11364. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  11365. */
  11366. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  11367. /**
  11368. * Returns a new indentity Matrix.
  11369. */
  11370. static Identity(): Matrix;
  11371. /**
  11372. * Sets the passed "result" as an identity matrix.
  11373. */
  11374. static IdentityToRef(result: Matrix): void;
  11375. /**
  11376. * Returns a new zero Matrix.
  11377. */
  11378. static Zero(): Matrix;
  11379. /**
  11380. * Returns a new rotation matrix for "angle" radians around the X axis.
  11381. */
  11382. static RotationX(angle: number): Matrix;
  11383. /**
  11384. * Returns a new Matrix as the passed inverted one.
  11385. */
  11386. static Invert(source: Matrix): Matrix;
  11387. /**
  11388. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  11389. */
  11390. static RotationXToRef(angle: number, result: Matrix): void;
  11391. /**
  11392. * Returns a new rotation matrix for "angle" radians around the Y axis.
  11393. */
  11394. static RotationY(angle: number): Matrix;
  11395. /**
  11396. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  11397. */
  11398. static RotationYToRef(angle: number, result: Matrix): void;
  11399. /**
  11400. * Returns a new rotation matrix for "angle" radians around the Z axis.
  11401. */
  11402. static RotationZ(angle: number): Matrix;
  11403. /**
  11404. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  11405. */
  11406. static RotationZToRef(angle: number, result: Matrix): void;
  11407. /**
  11408. * Returns a new rotation matrix for "angle" radians around the passed axis.
  11409. */
  11410. static RotationAxis(axis: Vector3, angle: number): Matrix;
  11411. /**
  11412. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  11413. */
  11414. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  11415. /**
  11416. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  11417. */
  11418. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  11419. /**
  11420. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  11421. */
  11422. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  11423. /**
  11424. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  11425. */
  11426. static Scaling(x: number, y: number, z: number): Matrix;
  11427. /**
  11428. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  11429. */
  11430. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  11431. /**
  11432. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  11433. */
  11434. static Translation(x: number, y: number, z: number): Matrix;
  11435. /**
  11436. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  11437. */
  11438. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  11439. /**
  11440. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  11441. * @param startValue defines the start value
  11442. * @param endValue defines the end value
  11443. * @param gradient defines the gradient factor
  11444. * @returns the new matrix
  11445. */
  11446. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  11447. /**
  11448. * Set the passed matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  11449. * @param startValue defines the start value
  11450. * @param endValue defines the end value
  11451. * @param gradient defines the gradient factor
  11452. * @param result defines the Matrix object where to store data
  11453. */
  11454. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  11455. /**
  11456. * Returns a new Matrix whose values are computed by :
  11457. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  11458. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  11459. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  11460. */
  11461. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  11462. /**
  11463. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  11464. * This methods works for a Left-Handed system.
  11465. */
  11466. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  11467. /**
  11468. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  11469. * This methods works for a Left-Handed system.
  11470. */
  11471. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  11472. /**
  11473. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  11474. * This methods works for a Right-Handed system.
  11475. */
  11476. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  11477. /**
  11478. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  11479. * This methods works for a Left-Handed system.
  11480. */
  11481. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  11482. /**
  11483. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  11484. */
  11485. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  11486. /**
  11487. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  11488. */
  11489. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  11490. /**
  11491. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  11492. */
  11493. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  11494. /**
  11495. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  11496. */
  11497. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  11498. /**
  11499. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  11500. */
  11501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  11502. /**
  11503. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  11504. */
  11505. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  11506. /**
  11507. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  11508. */
  11509. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  11510. /**
  11511. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  11512. */
  11513. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  11514. /**
  11515. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  11516. */
  11517. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  11518. /**
  11519. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  11520. */
  11521. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  11522. /**
  11523. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  11524. */
  11525. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  11526. /**
  11527. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  11528. */
  11529. static PerspectiveFovWebVRToRef(fov: {
  11530. upDegrees: number;
  11531. downDegrees: number;
  11532. leftDegrees: number;
  11533. rightDegrees: number;
  11534. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  11535. /**
  11536. * Returns the final transformation matrix : world * view * projection * viewport
  11537. */
  11538. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  11539. /**
  11540. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  11541. */
  11542. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  11543. /**
  11544. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  11545. */
  11546. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  11547. /**
  11548. * Compute the transpose of the passed Matrix.
  11549. * Returns a new Matrix.
  11550. */
  11551. static Transpose(matrix: Matrix): Matrix;
  11552. /**
  11553. * Compute the transpose of the passed Matrix and store it in the result matrix.
  11554. */
  11555. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  11556. /**
  11557. * Returns a new Matrix as the reflection matrix across the passed plane.
  11558. */
  11559. static Reflection(plane: Plane): Matrix;
  11560. /**
  11561. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  11562. */
  11563. static ReflectionToRef(plane: Plane, result: Matrix): void;
  11564. /**
  11565. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  11566. */
  11567. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  11568. /**
  11569. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  11570. */
  11571. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  11572. }
  11573. class Plane {
  11574. normal: Vector3;
  11575. d: number;
  11576. /**
  11577. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  11578. */
  11579. constructor(a: number, b: number, c: number, d: number);
  11580. /**
  11581. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  11582. */
  11583. asArray(): number[];
  11584. /**
  11585. * Returns a new plane copied from the current Plane.
  11586. */
  11587. clone(): Plane;
  11588. /**
  11589. * Returns the string "Plane".
  11590. */
  11591. getClassName(): string;
  11592. /**
  11593. * Returns the Plane hash code.
  11594. */
  11595. getHashCode(): number;
  11596. /**
  11597. * Normalize the current Plane in place.
  11598. * Returns the updated Plane.
  11599. */
  11600. normalize(): Plane;
  11601. /**
  11602. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  11603. */
  11604. transform(transformation: Matrix): Plane;
  11605. /**
  11606. * Returns the dot product (float) of the point coordinates and the plane normal.
  11607. */
  11608. dotCoordinate(point: Vector3): number;
  11609. /**
  11610. * Updates the current Plane from the plane defined by the three passed points.
  11611. * Returns the updated Plane.
  11612. */
  11613. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  11614. /**
  11615. * Boolean : True is the vector "direction" is the same side than the plane normal.
  11616. */
  11617. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  11618. /**
  11619. * Returns the signed distance (float) from the passed point to the Plane.
  11620. */
  11621. signedDistanceTo(point: Vector3): number;
  11622. /**
  11623. * Returns a new Plane from the passed array.
  11624. */
  11625. static FromArray(array: ArrayLike<number>): Plane;
  11626. /**
  11627. * Returns a new Plane defined by the three passed points.
  11628. */
  11629. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  11630. /**
  11631. * Returns a new Plane the normal vector to this plane at the passed origin point.
  11632. * Note : the vector "normal" is updated because normalized.
  11633. */
  11634. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  11635. /**
  11636. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  11637. */
  11638. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  11639. }
  11640. class Viewport {
  11641. x: number;
  11642. y: number;
  11643. width: number;
  11644. height: number;
  11645. /**
  11646. * Creates a Viewport object located at (x, y) and sized (width, height).
  11647. */
  11648. constructor(x: number, y: number, width: number, height: number);
  11649. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  11650. /**
  11651. * Returns a new Viewport copied from the current one.
  11652. */
  11653. clone(): Viewport;
  11654. }
  11655. class Frustum {
  11656. /**
  11657. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  11658. */
  11659. static GetPlanes(transform: Matrix): Plane[];
  11660. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  11661. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  11662. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  11663. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  11664. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  11665. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  11666. /**
  11667. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  11668. */
  11669. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  11670. }
  11671. enum Space {
  11672. LOCAL = 0,
  11673. WORLD = 1,
  11674. BONE = 2,
  11675. }
  11676. class Axis {
  11677. static X: Vector3;
  11678. static Y: Vector3;
  11679. static Z: Vector3;
  11680. }
  11681. class BezierCurve {
  11682. /**
  11683. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  11684. */
  11685. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  11686. }
  11687. enum Orientation {
  11688. CW = 0,
  11689. CCW = 1,
  11690. }
  11691. class Angle {
  11692. private _radians;
  11693. /**
  11694. * Creates an Angle object of "radians" radians (float).
  11695. */
  11696. constructor(radians: number);
  11697. /**
  11698. * Returns the Angle value in degrees (float).
  11699. */
  11700. degrees: () => number;
  11701. /**
  11702. * Returns the Angle value in radians (float).
  11703. */
  11704. radians: () => number;
  11705. /**
  11706. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  11707. */
  11708. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  11709. /**
  11710. * Returns a new Angle object from the passed float in radians.
  11711. */
  11712. static FromRadians(radians: number): Angle;
  11713. /**
  11714. * Returns a new Angle object from the passed float in degrees.
  11715. */
  11716. static FromDegrees(degrees: number): Angle;
  11717. }
  11718. class Arc2 {
  11719. startPoint: Vector2;
  11720. midPoint: Vector2;
  11721. endPoint: Vector2;
  11722. centerPoint: Vector2;
  11723. radius: number;
  11724. angle: Angle;
  11725. startAngle: Angle;
  11726. orientation: Orientation;
  11727. /**
  11728. * Creates an Arc object from the three passed points : start, middle and end.
  11729. */
  11730. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  11731. }
  11732. class Path2 {
  11733. private _points;
  11734. private _length;
  11735. closed: boolean;
  11736. /**
  11737. * Creates a Path2 object from the starting 2D coordinates x and y.
  11738. */
  11739. constructor(x: number, y: number);
  11740. /**
  11741. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  11742. * Returns the updated Path2.
  11743. */
  11744. addLineTo(x: number, y: number): Path2;
  11745. /**
  11746. * 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.
  11747. * Returns the updated Path2.
  11748. */
  11749. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  11750. /**
  11751. * Closes the Path2.
  11752. * Returns the Path2.
  11753. */
  11754. close(): Path2;
  11755. /**
  11756. * Returns the Path2 total length (float).
  11757. */
  11758. length(): number;
  11759. /**
  11760. * Returns the Path2 internal array of points.
  11761. */
  11762. getPoints(): Vector2[];
  11763. /**
  11764. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  11765. */
  11766. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  11767. /**
  11768. * Returns a new Path2 starting at the coordinates (x, y).
  11769. */
  11770. static StartingAt(x: number, y: number): Path2;
  11771. }
  11772. class Path3D {
  11773. path: Vector3[];
  11774. private _curve;
  11775. private _distances;
  11776. private _tangents;
  11777. private _normals;
  11778. private _binormals;
  11779. private _raw;
  11780. /**
  11781. * new Path3D(path, normal, raw)
  11782. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  11783. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  11784. * path : an array of Vector3, the curve axis of the Path3D
  11785. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  11786. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  11787. */
  11788. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  11789. /**
  11790. * Returns the Path3D array of successive Vector3 designing its curve.
  11791. */
  11792. getCurve(): Vector3[];
  11793. /**
  11794. * Returns an array populated with tangent vectors on each Path3D curve point.
  11795. */
  11796. getTangents(): Vector3[];
  11797. /**
  11798. * Returns an array populated with normal vectors on each Path3D curve point.
  11799. */
  11800. getNormals(): Vector3[];
  11801. /**
  11802. * Returns an array populated with binormal vectors on each Path3D curve point.
  11803. */
  11804. getBinormals(): Vector3[];
  11805. /**
  11806. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  11807. */
  11808. getDistances(): number[];
  11809. /**
  11810. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  11811. * Returns the same object updated.
  11812. */
  11813. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  11814. private _compute(firstNormal);
  11815. private _getFirstNonNullVector(index);
  11816. private _getLastNonNullVector(index);
  11817. private _normalVector(v0, vt, va);
  11818. }
  11819. class Curve3 {
  11820. private _points;
  11821. private _length;
  11822. /**
  11823. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  11824. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  11825. * @param v1 (Vector3) the control point
  11826. * @param v2 (Vector3) the end point of the Quadratic Bezier
  11827. * @param nbPoints (integer) the wanted number of points in the curve
  11828. */
  11829. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  11830. /**
  11831. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  11832. * @param v0 (Vector3) the origin point of the Cubic Bezier
  11833. * @param v1 (Vector3) the first control point
  11834. * @param v2 (Vector3) the second control point
  11835. * @param v3 (Vector3) the end point of the Cubic Bezier
  11836. * @param nbPoints (integer) the wanted number of points in the curve
  11837. */
  11838. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  11839. /**
  11840. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  11841. * @param p1 (Vector3) the origin point of the Hermite Spline
  11842. * @param t1 (Vector3) the tangent vector at the origin point
  11843. * @param p2 (Vector3) the end point of the Hermite Spline
  11844. * @param t2 (Vector3) the tangent vector at the end point
  11845. * @param nbPoints (integer) the wanted number of points in the curve
  11846. */
  11847. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  11848. /**
  11849. * Returns a Curve3 object along a CatmullRom Spline curve :
  11850. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  11851. * @param nbPoints (integer) the wanted number of points between each curve control points.
  11852. */
  11853. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  11854. /**
  11855. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  11856. * A Curve3 is designed from a series of successive Vector3.
  11857. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  11858. */
  11859. constructor(points: Vector3[]);
  11860. /**
  11861. * Returns the Curve3 stored array of successive Vector3
  11862. */
  11863. getPoints(): Vector3[];
  11864. /**
  11865. * Returns the computed length (float) of the curve.
  11866. */
  11867. length(): number;
  11868. /**
  11869. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  11870. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  11871. * curveA and curveB keep unchanged.
  11872. */
  11873. continue(curve: Curve3): Curve3;
  11874. private _computeLength(path);
  11875. }
  11876. class PositionNormalVertex {
  11877. position: Vector3;
  11878. normal: Vector3;
  11879. constructor(position?: Vector3, normal?: Vector3);
  11880. clone(): PositionNormalVertex;
  11881. }
  11882. class PositionNormalTextureVertex {
  11883. position: Vector3;
  11884. normal: Vector3;
  11885. uv: Vector2;
  11886. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  11887. clone(): PositionNormalTextureVertex;
  11888. }
  11889. class Tmp {
  11890. static Color3: Color3[];
  11891. static Vector2: Vector2[];
  11892. static Vector3: Vector3[];
  11893. static Vector4: Vector4[];
  11894. static Quaternion: Quaternion[];
  11895. static Matrix: Matrix[];
  11896. }
  11897. }
  11898. declare module BABYLON {
  11899. class SphericalPolynomial {
  11900. x: Vector3;
  11901. y: Vector3;
  11902. z: Vector3;
  11903. xx: Vector3;
  11904. yy: Vector3;
  11905. zz: Vector3;
  11906. xy: Vector3;
  11907. yz: Vector3;
  11908. zx: Vector3;
  11909. addAmbient(color: Color3): void;
  11910. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  11911. scale(scale: number): void;
  11912. }
  11913. class SphericalHarmonics {
  11914. L00: Vector3;
  11915. L1_1: Vector3;
  11916. L10: Vector3;
  11917. L11: Vector3;
  11918. L2_2: Vector3;
  11919. L2_1: Vector3;
  11920. L20: Vector3;
  11921. L21: Vector3;
  11922. L22: Vector3;
  11923. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  11924. scale(scale: number): void;
  11925. convertIncidentRadianceToIrradiance(): void;
  11926. convertIrradianceToLambertianRadiance(): void;
  11927. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  11928. }
  11929. }
  11930. declare module BABYLON {
  11931. interface ILoadingScreen {
  11932. displayLoadingUI: () => void;
  11933. hideLoadingUI: () => void;
  11934. loadingUIBackgroundColor: string;
  11935. loadingUIText: string;
  11936. }
  11937. class DefaultLoadingScreen implements ILoadingScreen {
  11938. private _renderingCanvas;
  11939. private _loadingText;
  11940. private _loadingDivBackgroundColor;
  11941. private _loadingDiv;
  11942. private _loadingTextDiv;
  11943. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11944. displayLoadingUI(): void;
  11945. hideLoadingUI(): void;
  11946. loadingUIText: string;
  11947. loadingUIBackgroundColor: string;
  11948. private _resizeLoadingUI;
  11949. }
  11950. }
  11951. declare module BABYLON {
  11952. class SceneLoaderProgressEvent {
  11953. readonly lengthComputable: boolean;
  11954. readonly loaded: number;
  11955. readonly total: number;
  11956. constructor(lengthComputable: boolean, loaded: number, total: number);
  11957. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11958. }
  11959. interface ISceneLoaderPluginExtensions {
  11960. [extension: string]: {
  11961. isBinary: boolean;
  11962. };
  11963. }
  11964. interface ISceneLoaderPluginFactory {
  11965. name: string;
  11966. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11967. canDirectLoad?: (data: string) => boolean;
  11968. }
  11969. interface ISceneLoaderPlugin {
  11970. /**
  11971. * The friendly name of this plugin.
  11972. */
  11973. name: string;
  11974. /**
  11975. * The file extensions supported by this plugin.
  11976. */
  11977. extensions: string | ISceneLoaderPluginExtensions;
  11978. /**
  11979. * Import meshes into a scene.
  11980. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11981. * @param scene The scene to import into
  11982. * @param data The data to import
  11983. * @param rootUrl The root url for scene and resources
  11984. * @param meshes The meshes array to import into
  11985. * @param particleSystems The particle systems array to import into
  11986. * @param skeletons The skeletons array to import into
  11987. * @param onError The callback when import fails
  11988. * @returns True if successful or false otherwise
  11989. */
  11990. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11991. /**
  11992. * Load into a scene.
  11993. * @param scene The scene to load into
  11994. * @param data The data to import
  11995. * @param rootUrl The root url for scene and resources
  11996. * @param onError The callback when import fails
  11997. * @returns true if successful or false otherwise
  11998. */
  11999. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12000. /**
  12001. * The callback that returns true if the data can be directly loaded.
  12002. */
  12003. canDirectLoad?: (data: string) => boolean;
  12004. /**
  12005. * The callback that allows custom handling of the root url based on the response url.
  12006. */
  12007. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12008. /**
  12009. * Load into an asset container.
  12010. * @param scene The scene to load into
  12011. * @param data The data to import
  12012. * @param rootUrl The root url for scene and resources
  12013. * @param onError The callback when import fails
  12014. * @returns The loaded asset container
  12015. */
  12016. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12017. }
  12018. interface ISceneLoaderPluginAsync {
  12019. /**
  12020. * The friendly name of this plugin.
  12021. */
  12022. name: string;
  12023. /**
  12024. * The file extensions supported by this plugin.
  12025. */
  12026. extensions: string | ISceneLoaderPluginExtensions;
  12027. /**
  12028. * Import meshes into a scene.
  12029. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12030. * @param scene The scene to import into
  12031. * @param data The data to import
  12032. * @param rootUrl The root url for scene and resources
  12033. * @param onProgress The callback when the load progresses
  12034. * @returns The loaded meshes, particle systems, and skeletons
  12035. */
  12036. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12037. meshes: AbstractMesh[];
  12038. particleSystems: ParticleSystem[];
  12039. skeletons: Skeleton[];
  12040. }>;
  12041. /**
  12042. * Load into a scene.
  12043. * @param scene The scene to load into
  12044. * @param data The data to import
  12045. * @param rootUrl The root url for scene and resources
  12046. * @param onProgress The callback when the load progresses
  12047. * @returns Nothing
  12048. */
  12049. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12050. /**
  12051. * The callback that returns true if the data can be directly loaded.
  12052. */
  12053. canDirectLoad?: (data: string) => boolean;
  12054. /**
  12055. * The callback that allows custom handling of the root url based on the response url.
  12056. */
  12057. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12058. /**
  12059. * Load into an asset container.
  12060. * @param scene The scene to load into
  12061. * @param data The data to import
  12062. * @param rootUrl The root url for scene and resources
  12063. * @param onProgress The callback when the load progresses
  12064. * @returns The loaded asset container
  12065. */
  12066. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12067. }
  12068. class SceneLoader {
  12069. private static _ForceFullSceneLoadingForIncremental;
  12070. private static _ShowLoadingScreen;
  12071. private static _CleanBoneMatrixWeights;
  12072. static readonly NO_LOGGING: number;
  12073. static readonly MINIMAL_LOGGING: number;
  12074. static readonly SUMMARY_LOGGING: number;
  12075. static readonly DETAILED_LOGGING: number;
  12076. private static _loggingLevel;
  12077. static ForceFullSceneLoadingForIncremental: boolean;
  12078. static ShowLoadingScreen: boolean;
  12079. static loggingLevel: number;
  12080. static CleanBoneMatrixWeights: boolean;
  12081. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12082. private static _registeredPlugins;
  12083. private static _getDefaultPlugin();
  12084. private static _getPluginForExtension(extension);
  12085. private static _getPluginForDirectLoad(data);
  12086. private static _getPluginForFilename(sceneFilename);
  12087. private static _getDirectLoad(sceneFilename);
  12088. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12089. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12090. static IsPluginForExtensionAvailable(extension: string): boolean;
  12091. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12092. /**
  12093. * Import meshes into a scene
  12094. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12095. * @param rootUrl a string that defines the root url for scene and resources
  12096. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12097. * @param scene the instance of BABYLON.Scene to append to
  12098. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12099. * @param onProgress a callback with a progress event for each file being loaded
  12100. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12101. * @param pluginExtension the extension used to determine the plugin
  12102. * @returns The loaded plugin
  12103. */
  12104. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12105. /**
  12106. * Import meshes into a scene
  12107. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12108. * @param rootUrl a string that defines the root url for scene and resources
  12109. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12110. * @param scene the instance of BABYLON.Scene to append to
  12111. * @param onProgress a callback with a progress event for each file being loaded
  12112. * @param pluginExtension the extension used to determine the plugin
  12113. * @returns The loaded list of imported meshes, particleSystems, and skeletons
  12114. */
  12115. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12116. meshes: AbstractMesh[];
  12117. particleSystems: ParticleSystem[];
  12118. skeletons: Skeleton[];
  12119. }>;
  12120. /**
  12121. * Load a scene
  12122. * @param rootUrl a string that defines the root url for scene and resources
  12123. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12124. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12125. * @param onSuccess a callback with the scene when import succeeds
  12126. * @param onProgress a callback with a progress event for each file being loaded
  12127. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12128. * @param pluginExtension the extension used to determine the plugin
  12129. * @returns The loaded plugin
  12130. */
  12131. 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>;
  12132. /**
  12133. * Load a scene
  12134. * @param rootUrl a string that defines the root url for scene and resources
  12135. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12136. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12137. * @param onProgress a callback with a progress event for each file being loaded
  12138. * @param pluginExtension the extension used to determine the plugin
  12139. * @returns The loaded scene
  12140. */
  12141. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12142. /**
  12143. * Append a scene
  12144. * @param rootUrl a string that defines the root url for scene and resources
  12145. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12146. * @param scene is the instance of BABYLON.Scene to append to
  12147. * @param onSuccess a callback with the scene when import succeeds
  12148. * @param onProgress a callback with a progress event for each file being loaded
  12149. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12150. * @param pluginExtension the extension used to determine the plugin
  12151. * @returns The loaded plugin
  12152. */
  12153. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12154. /**
  12155. * Append a scene
  12156. * @param rootUrl a string that defines the root url for scene and resources
  12157. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12158. * @param scene is the instance of BABYLON.Scene to append to
  12159. * @param onProgress a callback with a progress event for each file being loaded
  12160. * @param pluginExtension the extension used to determine the plugin
  12161. * @returns The given scene
  12162. */
  12163. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12164. /**
  12165. * Load a scene into an asset container
  12166. * @param rootUrl a string that defines the root url for scene and resources
  12167. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12168. * @param scene is the instance of BABYLON.Scene to append to
  12169. * @param onSuccess a callback with the scene when import succeeds
  12170. * @param onProgress a callback with a progress event for each file being loaded
  12171. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12172. * @param pluginExtension the extension used to determine the plugin
  12173. * @returns The loaded plugin
  12174. */
  12175. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12176. /**
  12177. * Load a scene into an asset container
  12178. * @param rootUrl a string that defines the root url for scene and resources
  12179. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  12180. * @param scene is the instance of BABYLON.Scene to append to
  12181. * @param onProgress a callback with a progress event for each file being loaded
  12182. * @param pluginExtension the extension used to determine the plugin
  12183. * @returns The loaded asset container
  12184. */
  12185. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12186. }
  12187. }
  12188. declare module BABYLON {
  12189. class MorphTarget {
  12190. name: string;
  12191. animations: Animation[];
  12192. private _positions;
  12193. private _normals;
  12194. private _tangents;
  12195. private _influence;
  12196. onInfluenceChanged: Observable<boolean>;
  12197. influence: number;
  12198. constructor(name: string, influence?: number);
  12199. readonly hasPositions: boolean;
  12200. readonly hasNormals: boolean;
  12201. readonly hasTangents: boolean;
  12202. setPositions(data: Nullable<FloatArray>): void;
  12203. getPositions(): Nullable<FloatArray>;
  12204. setNormals(data: Nullable<FloatArray>): void;
  12205. getNormals(): Nullable<FloatArray>;
  12206. setTangents(data: Nullable<FloatArray>): void;
  12207. getTangents(): Nullable<FloatArray>;
  12208. /**
  12209. * Serializes the current target into a Serialization object.
  12210. * Returns the serialized object.
  12211. */
  12212. serialize(): any;
  12213. static Parse(serializationObject: any): MorphTarget;
  12214. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  12215. }
  12216. }
  12217. declare module BABYLON {
  12218. class MorphTargetManager {
  12219. private _targets;
  12220. private _targetObservable;
  12221. private _activeTargets;
  12222. private _scene;
  12223. private _influences;
  12224. private _supportsNormals;
  12225. private _supportsTangents;
  12226. private _vertexCount;
  12227. private _uniqueId;
  12228. private _tempInfluences;
  12229. constructor(scene?: Nullable<Scene>);
  12230. readonly uniqueId: number;
  12231. readonly vertexCount: number;
  12232. readonly supportsNormals: boolean;
  12233. readonly supportsTangents: boolean;
  12234. readonly numTargets: number;
  12235. readonly numInfluencers: number;
  12236. readonly influences: Float32Array;
  12237. getActiveTarget(index: number): MorphTarget;
  12238. getTarget(index: number): MorphTarget;
  12239. addTarget(target: MorphTarget): void;
  12240. removeTarget(target: MorphTarget): void;
  12241. /**
  12242. * Serializes the current manager into a Serialization object.
  12243. * Returns the serialized object.
  12244. */
  12245. serialize(): any;
  12246. private _syncActiveTargets(needUpdate);
  12247. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  12252. static OCCLUSION_TYPE_NONE: number;
  12253. static OCCLUSION_TYPE_OPTIMISTIC: number;
  12254. static OCCLUSION_TYPE_STRICT: number;
  12255. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  12256. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  12257. static readonly BILLBOARDMODE_NONE: number;
  12258. static readonly BILLBOARDMODE_X: number;
  12259. static readonly BILLBOARDMODE_Y: number;
  12260. static readonly BILLBOARDMODE_Z: number;
  12261. static readonly BILLBOARDMODE_ALL: number;
  12262. private _facetPositions;
  12263. private _facetNormals;
  12264. private _facetPartitioning;
  12265. private _facetNb;
  12266. private _partitioningSubdivisions;
  12267. private _partitioningBBoxRatio;
  12268. private _facetDataEnabled;
  12269. private _facetParameters;
  12270. private _bbSize;
  12271. private _subDiv;
  12272. private _facetDepthSort;
  12273. private _facetDepthSortEnabled;
  12274. private _depthSortedIndices;
  12275. private _depthSortedFacets;
  12276. private _facetDepthSortFunction;
  12277. private _facetDepthSortFrom;
  12278. private _facetDepthSortOrigin;
  12279. private _invertedMatrix;
  12280. /**
  12281. * Read-only : the number of facets in the mesh
  12282. */
  12283. readonly facetNb: number;
  12284. /**
  12285. * The number (integer) of subdivisions per axis in the partioning space
  12286. */
  12287. partitioningSubdivisions: number;
  12288. /**
  12289. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  12290. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  12291. */
  12292. partitioningBBoxRatio: number;
  12293. /**
  12294. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  12295. * Works only for updatable meshes.
  12296. * Doesn't work with multi-materials.
  12297. */
  12298. mustDepthSortFacets: boolean;
  12299. /**
  12300. * The location (Vector3) where the facet depth sort must be computed from.
  12301. * By default, the active camera position.
  12302. * Used only when facet depth sort is enabled.
  12303. */
  12304. facetDepthSortFrom: Vector3;
  12305. /**
  12306. * Read-only boolean : is the feature facetData enabled ?
  12307. */
  12308. readonly isFacetDataEnabled: boolean;
  12309. _updateNonUniformScalingState(value: boolean): boolean;
  12310. /**
  12311. * An event triggered when this mesh collides with another one
  12312. * @type {BABYLON.Observable}
  12313. */
  12314. onCollideObservable: Observable<AbstractMesh>;
  12315. private _onCollideObserver;
  12316. onCollide: () => void;
  12317. /**
  12318. * An event triggered when the collision's position changes
  12319. * @type {BABYLON.Observable}
  12320. */
  12321. onCollisionPositionChangeObservable: Observable<Vector3>;
  12322. private _onCollisionPositionChangeObserver;
  12323. onCollisionPositionChange: () => void;
  12324. /**
  12325. * An event triggered when material is changed
  12326. * @type {BABYLON.Observable}
  12327. */
  12328. onMaterialChangedObservable: Observable<AbstractMesh>;
  12329. definedFacingForward: boolean;
  12330. /**
  12331. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  12332. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  12333. * or
  12334. * 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.
  12335. * for more info check WebGl documentations
  12336. */
  12337. occlusionQueryAlgorithmType: number;
  12338. /**
  12339. * 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:
  12340. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  12341. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  12342. * 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.
  12343. */
  12344. occlusionType: number;
  12345. /**
  12346. * 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.
  12347. * The default value is -1 which means don't break the query and wait till the result.
  12348. */
  12349. occlusionRetryCount: number;
  12350. private _occlusionInternalRetryCounter;
  12351. protected _isOccluded: boolean;
  12352. /**
  12353. * Property isOccluded : Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not.
  12354. */
  12355. isOccluded: boolean;
  12356. private _isOcclusionQueryInProgress;
  12357. /**
  12358. * Flag to check the progress status of the query
  12359. */
  12360. readonly isOcclusionQueryInProgress: boolean;
  12361. private _occlusionQuery;
  12362. private _visibility;
  12363. /**
  12364. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  12365. */
  12366. /**
  12367. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  12368. */
  12369. visibility: number;
  12370. alphaIndex: number;
  12371. isVisible: boolean;
  12372. isPickable: boolean;
  12373. showBoundingBox: boolean;
  12374. showSubMeshesBoundingBox: boolean;
  12375. isBlocker: boolean;
  12376. enablePointerMoveEvents: boolean;
  12377. renderingGroupId: number;
  12378. private _material;
  12379. material: Nullable<Material>;
  12380. private _receiveShadows;
  12381. receiveShadows: boolean;
  12382. renderOutline: boolean;
  12383. outlineColor: Color3;
  12384. outlineWidth: number;
  12385. renderOverlay: boolean;
  12386. overlayColor: Color3;
  12387. overlayAlpha: number;
  12388. private _hasVertexAlpha;
  12389. hasVertexAlpha: boolean;
  12390. private _useVertexColors;
  12391. useVertexColors: boolean;
  12392. private _computeBonesUsingShaders;
  12393. computeBonesUsingShaders: boolean;
  12394. private _numBoneInfluencers;
  12395. numBoneInfluencers: number;
  12396. private _applyFog;
  12397. applyFog: boolean;
  12398. useOctreeForRenderingSelection: boolean;
  12399. useOctreeForPicking: boolean;
  12400. useOctreeForCollisions: boolean;
  12401. private _layerMask;
  12402. layerMask: number;
  12403. /**
  12404. * True if the mesh must be rendered in any case.
  12405. */
  12406. alwaysSelectAsActiveMesh: boolean;
  12407. /**
  12408. * This scene's action manager
  12409. * @type {BABYLON.ActionManager}
  12410. */
  12411. actionManager: Nullable<ActionManager>;
  12412. physicsImpostor: Nullable<PhysicsImpostor>;
  12413. private _checkCollisions;
  12414. private _collisionMask;
  12415. private _collisionGroup;
  12416. ellipsoid: Vector3;
  12417. ellipsoidOffset: Vector3;
  12418. private _collider;
  12419. private _oldPositionForCollisions;
  12420. private _diffPositionForCollisions;
  12421. collisionMask: number;
  12422. collisionGroup: number;
  12423. edgesWidth: number;
  12424. edgesColor: Color4;
  12425. _edgesRenderer: Nullable<EdgesRenderer>;
  12426. private _collisionsTransformMatrix;
  12427. private _collisionsScalingMatrix;
  12428. _masterMesh: Nullable<AbstractMesh>;
  12429. _boundingInfo: Nullable<BoundingInfo>;
  12430. _renderId: number;
  12431. subMeshes: SubMesh[];
  12432. _submeshesOctree: Octree<SubMesh>;
  12433. _intersectionsInProgress: AbstractMesh[];
  12434. _unIndexed: boolean;
  12435. _lightSources: Light[];
  12436. readonly _positions: Nullable<Vector3[]>;
  12437. _waitingActions: any;
  12438. _waitingFreezeWorldMatrix: Nullable<boolean>;
  12439. private _skeleton;
  12440. _bonesTransformMatrices: Nullable<Float32Array>;
  12441. skeleton: Nullable<Skeleton>;
  12442. constructor(name: string, scene?: Nullable<Scene>);
  12443. /**
  12444. * Returns the string "AbstractMesh"
  12445. */
  12446. getClassName(): string;
  12447. /**
  12448. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  12449. */
  12450. toString(fullDetails?: boolean): string;
  12451. _rebuild(): void;
  12452. _resyncLightSources(): void;
  12453. _resyncLighSource(light: Light): void;
  12454. _removeLightSource(light: Light): void;
  12455. private _markSubMeshesAsDirty(func);
  12456. _markSubMeshesAsLightDirty(): void;
  12457. _markSubMeshesAsAttributesDirty(): void;
  12458. _markSubMeshesAsMiscDirty(): void;
  12459. /**
  12460. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  12461. * Default : (1.0, 1.0, 1.0)
  12462. */
  12463. /**
  12464. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  12465. * Default : (1.0, 1.0, 1.0)
  12466. */
  12467. scaling: Vector3;
  12468. /**
  12469. * Disables the mesh edger rendering mode.
  12470. * Returns the AbstractMesh.
  12471. */
  12472. disableEdgesRendering(): AbstractMesh;
  12473. /**
  12474. * Enables the edge rendering mode on the mesh.
  12475. * This mode makes the mesh edges visible.
  12476. * Returns the AbstractMesh.
  12477. */
  12478. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  12479. /**
  12480. * Returns true if the mesh is blocked. Used by the class Mesh.
  12481. * Returns the boolean `false` by default.
  12482. */
  12483. readonly isBlocked: boolean;
  12484. /**
  12485. * Returns the mesh itself by default, used by the class Mesh.
  12486. * Returned type : AbstractMesh
  12487. */
  12488. getLOD(camera: Camera): AbstractMesh;
  12489. /**
  12490. * Returns 0 by default, used by the class Mesh.
  12491. * Returns an integer.
  12492. */
  12493. getTotalVertices(): number;
  12494. /**
  12495. * Returns null by default, used by the class Mesh.
  12496. * Returned type : integer array
  12497. */
  12498. getIndices(): Nullable<IndicesArray>;
  12499. /**
  12500. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  12501. * Returned type : float array or Float32Array
  12502. */
  12503. getVerticesData(kind: string): Nullable<FloatArray>;
  12504. /**
  12505. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12506. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12507. * The `data` are either a numeric array either a Float32Array.
  12508. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12509. * 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).
  12510. * Note that a new underlying VertexBuffer object is created each call.
  12511. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12512. *
  12513. * Possible `kind` values :
  12514. * - BABYLON.VertexBuffer.PositionKind
  12515. * - BABYLON.VertexBuffer.UVKind
  12516. * - BABYLON.VertexBuffer.UV2Kind
  12517. * - BABYLON.VertexBuffer.UV3Kind
  12518. * - BABYLON.VertexBuffer.UV4Kind
  12519. * - BABYLON.VertexBuffer.UV5Kind
  12520. * - BABYLON.VertexBuffer.UV6Kind
  12521. * - BABYLON.VertexBuffer.ColorKind
  12522. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12523. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12524. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12525. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12526. *
  12527. * Returns the Mesh.
  12528. */
  12529. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  12530. /**
  12531. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12532. * If the mesh has no geometry, it is simply returned as it is.
  12533. * The `data` are either a numeric array either a Float32Array.
  12534. * No new underlying VertexBuffer object is created.
  12535. * 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.
  12536. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12537. *
  12538. * Possible `kind` values :
  12539. * - BABYLON.VertexBuffer.PositionKind
  12540. * - BABYLON.VertexBuffer.UVKind
  12541. * - BABYLON.VertexBuffer.UV2Kind
  12542. * - BABYLON.VertexBuffer.UV3Kind
  12543. * - BABYLON.VertexBuffer.UV4Kind
  12544. * - BABYLON.VertexBuffer.UV5Kind
  12545. * - BABYLON.VertexBuffer.UV6Kind
  12546. * - BABYLON.VertexBuffer.ColorKind
  12547. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12548. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12549. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12550. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12551. *
  12552. * Returns the Mesh.
  12553. */
  12554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  12555. /**
  12556. * Sets the mesh indices.
  12557. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12558. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12559. * This method creates a new index buffer each call.
  12560. * Returns the Mesh.
  12561. */
  12562. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  12563. /** Returns false by default, used by the class Mesh.
  12564. * Returns a boolean
  12565. */
  12566. isVerticesDataPresent(kind: string): boolean;
  12567. /**
  12568. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  12569. * Returns a BoundingInfo
  12570. */
  12571. getBoundingInfo(): BoundingInfo;
  12572. /**
  12573. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  12574. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  12575. */
  12576. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  12577. /**
  12578. * Sets a mesh new object BoundingInfo.
  12579. * Returns the AbstractMesh.
  12580. */
  12581. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  12582. readonly useBones: boolean;
  12583. _preActivate(): void;
  12584. _preActivateForIntermediateRendering(renderId: number): void;
  12585. _activate(renderId: number): void;
  12586. /**
  12587. * Returns the latest update of the World matrix
  12588. * Returns a Matrix.
  12589. */
  12590. getWorldMatrix(): Matrix;
  12591. /**
  12592. * Returns the latest update of the World matrix determinant.
  12593. */
  12594. protected _getWorldMatrixDeterminant(): number;
  12595. /**
  12596. * Perform relative position change from the point of view of behind the front of the mesh.
  12597. * This is performed taking into account the meshes current rotation, so you do not have to care.
  12598. * Supports definition of mesh facing forward or backward.
  12599. * @param {number} amountRight
  12600. * @param {number} amountUp
  12601. * @param {number} amountForward
  12602. *
  12603. * Returns the AbstractMesh.
  12604. */
  12605. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  12606. /**
  12607. * Calculate relative position change from the point of view of behind the front of the mesh.
  12608. * This is performed taking into account the meshes current rotation, so you do not have to care.
  12609. * Supports definition of mesh facing forward or backward.
  12610. * @param {number} amountRight
  12611. * @param {number} amountUp
  12612. * @param {number} amountForward
  12613. *
  12614. * Returns a new Vector3.
  12615. */
  12616. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  12617. /**
  12618. * Perform relative rotation change from the point of view of behind the front of the mesh.
  12619. * Supports definition of mesh facing forward or backward.
  12620. * @param {number} flipBack
  12621. * @param {number} twirlClockwise
  12622. * @param {number} tiltRight
  12623. *
  12624. * Returns the AbstractMesh.
  12625. */
  12626. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  12627. /**
  12628. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  12629. * Supports definition of mesh facing forward or backward.
  12630. * @param {number} flipBack
  12631. * @param {number} twirlClockwise
  12632. * @param {number} tiltRight
  12633. *
  12634. * Returns a new Vector3.
  12635. */
  12636. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  12637. /**
  12638. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  12639. * @param includeDescendants Include bounding info from descendants as well (true by default).
  12640. */
  12641. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  12642. min: Vector3;
  12643. max: Vector3;
  12644. };
  12645. /**
  12646. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  12647. * Returns the AbstractMesh.
  12648. */
  12649. _updateBoundingInfo(): AbstractMesh;
  12650. /**
  12651. * Update a mesh's children BoundingInfo objects only.
  12652. * Returns the AbstractMesh.
  12653. */
  12654. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  12655. protected _afterComputeWorldMatrix(): void;
  12656. /**
  12657. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  12658. * A mesh is in the frustum if its bounding box intersects the frustum.
  12659. * Boolean returned.
  12660. */
  12661. isInFrustum(frustumPlanes: Plane[]): boolean;
  12662. /**
  12663. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  12664. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  12665. * Boolean returned.
  12666. */
  12667. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  12668. /**
  12669. * True if the mesh intersects another mesh or a SolidParticle object.
  12670. * 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)
  12671. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  12672. * Returns a boolean.
  12673. */
  12674. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  12675. /**
  12676. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  12677. * Returns a boolean.
  12678. */
  12679. intersectsPoint(point: Vector3): boolean;
  12680. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  12681. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12682. /**
  12683. * Returns the distance from the mesh to the active camera.
  12684. * Returns a float.
  12685. */
  12686. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12687. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  12688. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  12689. /**
  12690. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  12691. * Default `false`.
  12692. */
  12693. checkCollisions: boolean;
  12694. /**
  12695. * Gets Collider object used to compute collisions (not physics)
  12696. */
  12697. readonly collider: Collider;
  12698. moveWithCollisions(displacement: Vector3): AbstractMesh;
  12699. private _onCollisionPositionChange;
  12700. /**
  12701. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  12702. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  12703. * Returns an Octree of submeshes.
  12704. */
  12705. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  12706. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  12707. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  12708. _checkCollision(collider: Collider): AbstractMesh;
  12709. _generatePointsArray(): boolean;
  12710. /**
  12711. * Checks if the passed Ray intersects with the mesh.
  12712. * Returns an object PickingInfo.
  12713. */
  12714. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  12715. /**
  12716. * Clones the mesh, used by the class Mesh.
  12717. * Just returns `null` for an AbstractMesh.
  12718. */
  12719. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  12720. /**
  12721. * Disposes all the mesh submeshes.
  12722. * Returns the AbstractMesh.
  12723. */
  12724. releaseSubMeshes(): AbstractMesh;
  12725. /**
  12726. * Releases resources associated with this abstract mesh.
  12727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12729. */
  12730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12731. /**
  12732. * Adds the passed mesh as a child to the current mesh.
  12733. * Returns the AbstractMesh.
  12734. */
  12735. addChild(mesh: AbstractMesh): AbstractMesh;
  12736. /**
  12737. * Removes the passed mesh from the current mesh children list.
  12738. * Returns the AbstractMesh.
  12739. */
  12740. removeChild(mesh: AbstractMesh): AbstractMesh;
  12741. /**
  12742. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  12743. * Returns the AbstractMesh.
  12744. */
  12745. private _initFacetData();
  12746. /**
  12747. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  12748. * This method can be called within the render loop.
  12749. * 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.
  12750. * Returns the AbstractMesh.
  12751. */
  12752. updateFacetData(): AbstractMesh;
  12753. /**
  12754. * Returns the facetLocalNormals array.
  12755. * The normals are expressed in the mesh local space.
  12756. */
  12757. getFacetLocalNormals(): Vector3[];
  12758. /**
  12759. * Returns the facetLocalPositions array.
  12760. * The facet positions are expressed in the mesh local space.
  12761. */
  12762. getFacetLocalPositions(): Vector3[];
  12763. /**
  12764. * Returns the facetLocalPartioning array.
  12765. */
  12766. getFacetLocalPartitioning(): number[][];
  12767. /**
  12768. * Returns the i-th facet position in the world system.
  12769. * This method allocates a new Vector3 per call.
  12770. */
  12771. getFacetPosition(i: number): Vector3;
  12772. /**
  12773. * Sets the reference Vector3 with the i-th facet position in the world system.
  12774. * Returns the AbstractMesh.
  12775. */
  12776. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  12777. /**
  12778. * Returns the i-th facet normal in the world system.
  12779. * This method allocates a new Vector3 per call.
  12780. */
  12781. getFacetNormal(i: number): Vector3;
  12782. /**
  12783. * Sets the reference Vector3 with the i-th facet normal in the world system.
  12784. * Returns the AbstractMesh.
  12785. */
  12786. getFacetNormalToRef(i: number, ref: Vector3): this;
  12787. /**
  12788. * 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).
  12789. */
  12790. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  12791. /**
  12792. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  12793. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  12794. * If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.
  12795. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  12796. * 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.
  12797. */
  12798. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  12799. /**
  12800. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  12801. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  12802. * If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.
  12803. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  12804. * 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.
  12805. */
  12806. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  12807. /**
  12808. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  12809. */
  12810. getFacetDataParameters(): any;
  12811. /**
  12812. * Disables the feature FacetData and frees the related memory.
  12813. * Returns the AbstractMesh.
  12814. */
  12815. disableFacetData(): AbstractMesh;
  12816. /**
  12817. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  12818. * Returns the mesh.
  12819. */
  12820. updateIndices(indices: IndicesArray): AbstractMesh;
  12821. /**
  12822. * The mesh Geometry. Actually used by the Mesh object.
  12823. * Returns a blank geometry object.
  12824. */
  12825. /**
  12826. * Creates new normals data for the mesh.
  12827. * @param updatable.
  12828. */
  12829. createNormals(updatable: boolean): void;
  12830. /**
  12831. * Align the mesh with a normal.
  12832. * Returns the mesh.
  12833. */
  12834. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  12835. protected checkOcclusionQuery(): void;
  12836. }
  12837. }
  12838. declare module BABYLON {
  12839. class Buffer {
  12840. private _engine;
  12841. private _buffer;
  12842. private _data;
  12843. private _updatable;
  12844. private _strideSize;
  12845. private _instanced;
  12846. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  12847. /**
  12848. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  12849. * @param kind defines the vertex buffer kind (position, normal, etc.)
  12850. * @param offset defines offset in the buffer (0 by default)
  12851. * @param size defines the size in floats of attributes (position is 3 for instance)
  12852. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  12853. * @param instanced defines if the vertex buffer contains indexed data
  12854. * @returns the new vertex buffer
  12855. */
  12856. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  12857. isUpdatable(): boolean;
  12858. getData(): Nullable<FloatArray>;
  12859. getBuffer(): Nullable<WebGLBuffer>;
  12860. getStrideSize(): number;
  12861. create(data?: Nullable<FloatArray>): void;
  12862. _rebuild(): void;
  12863. update(data: FloatArray): void;
  12864. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  12865. dispose(): void;
  12866. }
  12867. }
  12868. declare module BABYLON {
  12869. <<<<<<< HEAD
  12870. class CSG {
  12871. private polygons;
  12872. matrix: Matrix;
  12873. position: Vector3;
  12874. rotation: Vector3;
  12875. rotationQuaternion: Nullable<Quaternion>;
  12876. scaling: Vector3;
  12877. static FromMesh(mesh: Mesh): CSG;
  12878. private static FromPolygons(polygons);
  12879. clone(): CSG;
  12880. union(csg: CSG): CSG;
  12881. unionInPlace(csg: CSG): void;
  12882. subtract(csg: CSG): CSG;
  12883. subtractInPlace(csg: CSG): void;
  12884. intersect(csg: CSG): CSG;
  12885. intersectInPlace(csg: CSG): void;
  12886. inverse(): CSG;
  12887. inverseInPlace(): void;
  12888. copyTransformAttributes(csg: CSG): CSG;
  12889. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  12890. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  12891. =======
  12892. /**
  12893. * Interface to follow in your material defines to integrate easily the
  12894. * Image proccessing functions.
  12895. * @ignore
  12896. */
  12897. interface IImageProcessingConfigurationDefines {
  12898. IMAGEPROCESSING: boolean;
  12899. VIGNETTE: boolean;
  12900. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12901. VIGNETTEBLENDMODEOPAQUE: boolean;
  12902. TONEMAPPING: boolean;
  12903. CONTRAST: boolean;
  12904. EXPOSURE: boolean;
  12905. COLORCURVES: boolean;
  12906. COLORGRADING: boolean;
  12907. COLORGRADING3D: boolean;
  12908. SAMPLER3DGREENDEPTH: boolean;
  12909. SAMPLER3DBGRMAP: boolean;
  12910. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12911. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  12912. }
  12913. }
  12914. declare module BABYLON {
  12915. /**
  12916. * Class used to store geometry data (vertex buffers + index buffer)
  12917. */
  12918. class Geometry implements IGetSetVerticesData {
  12919. /**
  12920. * Gets or sets the unique ID of the geometry
  12921. */
  12922. id: string;
  12923. /**
  12924. * Gets the delay loading state of the geometry (none by default which means not delayed)
  12925. */
  12926. delayLoadState: number;
  12927. /**
  12928. * Gets the file containing the data to load when running in delay load state
  12929. */
  12930. delayLoadingFile: Nullable<string>;
  12931. /**
  12932. * Callback called when the geometry is updated
  12933. */
  12934. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  12935. private _scene;
  12936. private _engine;
  12937. private _meshes;
  12938. private _totalVertices;
  12939. private _indices;
  12940. private _vertexBuffers;
  12941. private _isDisposed;
  12942. private _extend;
  12943. private _boundingBias;
  12944. /** @ignore */
  12945. _delayInfo: Array<string>;
  12946. private _indexBuffer;
  12947. private _indexBufferIsUpdatable;
  12948. /** @ignore */
  12949. _boundingInfo: Nullable<BoundingInfo>;
  12950. /** @ignore */
  12951. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  12952. /** @ignore */
  12953. _softwareSkinningRenderId: number;
  12954. private _vertexArrayObjects;
  12955. private _updatable;
  12956. /** @ignore */
  12957. _positions: Nullable<Vector3[]>;
  12958. /**
  12959. * 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
  12960. */
  12961. /**
  12962. * 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
  12963. */
  12964. boundingBias: Vector2;
  12965. /**
  12966. * Static function used to attach a new empty geometry to a mesh
  12967. * @param mesh defines the mesh to attach the geometry to
  12968. * @returns the new {BABYLON.Geometry}
  12969. */
  12970. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  12971. /**
  12972. * Creates a new geometry
  12973. * @param id defines the unique ID
  12974. * @param scene defines the hosting scene
  12975. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  12976. * @param updatable defines if geometry must be updatable (false by default)
  12977. * @param mesh defines the mesh that will be associated with the geometry
  12978. */
  12979. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  12980. /**
  12981. * Gets the current extend of the geometry
  12982. */
  12983. readonly extend: {
  12984. minimum: Vector3;
  12985. maximum: Vector3;
  12986. };
  12987. /**
  12988. * Gets the hosting scene
  12989. * @returns the hosting {BABYLON.Scene}
  12990. */
  12991. getScene(): Scene;
  12992. /**
  12993. * Gets the hosting engine
  12994. * @returns the hosting {BABYLON.Engine}
  12995. */
  12996. getEngine(): Engine;
  12997. /**
  12998. * Defines if the geometry is ready to use
  12999. * @returns true if the geometry is ready to be used
  13000. */
  13001. isReady(): boolean;
  13002. /**
  13003. * Gets a value indicating that the geometry should not be serialized
  13004. */
  13005. readonly doNotSerialize: boolean;
  13006. /** @ignore */
  13007. _rebuild(): void;
  13008. /**
  13009. * Affects all gemetry data in one call
  13010. * @param vertexData defines the geometry data
  13011. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  13012. */
  13013. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  13014. /**
  13015. * Set specific vertex data
  13016. * @param kind defines the data kind (Position, normal, etc...)
  13017. * @param data defines the vertex data to use
  13018. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  13019. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  13020. */
  13021. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  13022. /**
  13023. * Removes a specific vertex data
  13024. * @param kind defines the data kind (Position, normal, etc...)
  13025. */
  13026. removeVerticesData(kind: string): void;
  13027. /**
  13028. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  13029. * @param buffer defines the vertex buffer to use
  13030. */
  13031. setVerticesBuffer(buffer: VertexBuffer): void;
  13032. /**
  13033. * Update a specific vertex buffer
  13034. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  13035. * It will do nothing if the buffer is not updatable
  13036. * @param kind defines the data kind (Position, normal, etc...)
  13037. * @param data defines the data to use
  13038. * @param offset defines the offset in the target buffer where to store the data
  13039. */
  13040. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  13041. /**
  13042. * Update a specific vertex buffer
  13043. * This function will create a new buffer if the current one is not updatable
  13044. * @param kind defines the data kind (Position, normal, etc...)
  13045. * @param data defines the data to use
  13046. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  13047. */
  13048. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  13049. private updateBoundingInfo(updateExtends, data);
  13050. /** @ignore */
  13051. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  13052. /**
  13053. * Gets total number of vertices
  13054. * @returns the total number of vertices
  13055. */
  13056. getTotalVertices(): number;
  13057. /**
  13058. * Gets a specific vertex data attached to this geometry
  13059. * @param kind defines the data kind (Position, normal, etc...)
  13060. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  13061. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  13062. * @returns a float array containing vertex data
  13063. */
  13064. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  13065. /**
  13066. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  13067. * @param kind defines the data kind (Position, normal, etc...)
  13068. * @returns true if the vertex buffer with the specified kind is updatable
  13069. */
  13070. <<<<<<< HEAD
  13071. isVertexBufferUpdatable(kind: string): boolean;
  13072. /**
  13073. * Gets a specific vertex buffer
  13074. * @param kind defines the data kind (Position, normal, etc...)
  13075. * @returns a {BABYLON.VertexBuffer}
  13076. */
  13077. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  13078. /**
  13079. * Returns all vertex buffers
  13080. * @return an object holding all vertex buffers indexed by kind
  13081. */
  13082. getVertexBuffers(): Nullable<{
  13083. [key: string]: VertexBuffer;
  13084. }>;
  13085. /**
  13086. * Gets a boolean indicating if specific vertex buffer is present
  13087. * @param kind defines the data kind (Position, normal, etc...)
  13088. * @returns true if data is present
  13089. */
  13090. isVerticesDataPresent(kind: string): boolean;
  13091. =======
  13092. vignetteCameraFov: number;
  13093. private _vignetteBlendMode;
  13094. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  13095. /**
  13096. * Gets a list of all attached data kinds (Position, normal, etc...)
  13097. * @returns a list of string containing all kinds
  13098. */
  13099. getVerticesDataKinds(): string[];
  13100. /**
  13101. * Update index buffer
  13102. * @param indices defines the indices to store in the index buffer
  13103. * @param offset defines the offset in the target buffer where to store the data
  13104. */
  13105. updateIndices(indices: IndicesArray, offset?: number): void;
  13106. /**
  13107. * Creates a new index buffer
  13108. * @param indices defines the indices to store in the index buffer
  13109. * @param totalVertices defines the total number of vertices (could be null)
  13110. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  13111. */
  13112. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  13113. /**
  13114. * Return the total number of indices
  13115. * @returns the total number of indices
  13116. */
  13117. getTotalIndices(): number;
  13118. /**
  13119. * Gets the index buffer array
  13120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  13121. * @returns the index buffer array
  13122. */
  13123. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  13124. /**
  13125. * Gets the index buffer
  13126. * @return the index buffer
  13127. */
  13128. getIndexBuffer(): Nullable<WebGLBuffer>;
  13129. /** @ignore */
  13130. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  13131. /**
  13132. * Release the associated resources for a specific mesh
  13133. * @param mesh defines the source mesh
  13134. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  13135. */
  13136. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  13137. /**
  13138. * Apply current geometry to a given mesh
  13139. * @param mesh defines the mesh to apply geometry to
  13140. */
  13141. applyToMesh(mesh: Mesh): void;
  13142. private updateExtend(data?, stride?);
  13143. private _applyToMesh(mesh);
  13144. private notifyUpdate(kind?);
  13145. /**
  13146. * Load the geometry if it was flagged as delay loaded
  13147. * @param scene defines the hosting scene
  13148. * @param onLoaded defines a callback called when the geometry is loaded
  13149. */
  13150. load(scene: Scene, onLoaded?: () => void): void;
  13151. private _queueLoad(scene, onLoaded?);
  13152. /**
  13153. * Invert the geometry to move from a right handed system to a left handed one.
  13154. */
  13155. toLeftHanded(): void;
  13156. /** @ignore */
  13157. _resetPointsArrayCache(): void;
  13158. /** @ignore */
  13159. _generatePointsArray(): boolean;
  13160. /**
  13161. * Gets a value indicating if the geometry is disposed
  13162. * @returns true if the geometry was disposed
  13163. */
  13164. isDisposed(): boolean;
  13165. private _disposeVertexArrayObjects();
  13166. /**
  13167. * Free all associated resources
  13168. */
  13169. dispose(): void;
  13170. /**
  13171. * Clone the current geometry into a new geometry
  13172. * @param id defines the unique ID of the new geometry
  13173. * @returns a new geometry object
  13174. */
  13175. copy(id: string): Geometry;
  13176. /**
  13177. * Serialize the current geometry info (and not the vertices data) into a JSON object
  13178. * @return a JSON representation of the current geometry data (without the vertices data)
  13179. */
  13180. serialize(): any;
  13181. private toNumberArray(origin);
  13182. /**
  13183. * Serialize all vertices data into a JSON oject
  13184. * @returns a JSON representation of the current geometry data
  13185. */
  13186. serializeVerticeData(): any;
  13187. /**
  13188. * Extracts a clone of a mesh geometry
  13189. * @param mesh defines the source mesh
  13190. * @param id defines the unique ID of the new geometry object
  13191. * @returns the new geometry object
  13192. */
  13193. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  13194. /**
  13195. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  13196. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  13197. * Be aware Math.random() could cause collisions, but:
  13198. * "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"
  13199. * @returns a string containing a new GUID
  13200. */
  13201. static RandomId(): string;
  13202. /** @ignore */
  13203. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  13204. private static _CleanMatricesWeights(parsedGeometry, mesh);
  13205. /**
  13206. * Create a new geometry from persisted data (Using .babylon file format)
  13207. * @param parsedVertexData defines the persisted data
  13208. * @param scene defines the hosting scene
  13209. * @param rootUrl defines the root url to use to load assets (like delayed data)
  13210. * @returns the new geometry object
  13211. */
  13212. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  13213. }
  13214. /**
  13215. * Abstract class used to provide common services for all typed geometries
  13216. */
  13217. class _PrimitiveGeometry extends Geometry {
  13218. private _canBeRegenerated;
  13219. private _beingRegenerated;
  13220. /**
  13221. * Creates a new typed geometry
  13222. * @param id defines the unique ID of the geometry
  13223. * @param scene defines the hosting scene
  13224. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13225. * @param mesh defines the hosting mesh (can be null)
  13226. */
  13227. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  13228. /**
  13229. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  13230. * @returns true if the geometry can be regenerated
  13231. */
  13232. canBeRegenerated(): boolean;
  13233. /**
  13234. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  13235. */
  13236. regenerate(): void;
  13237. /**
  13238. * Clone the geometry
  13239. * @param id defines the unique ID of the new geometry
  13240. * @returns the new geometry
  13241. */
  13242. asNewGeometry(id: string): Geometry;
  13243. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  13244. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  13245. /** @ignore */
  13246. _regenerateVertexData(): VertexData;
  13247. copy(id: string): Geometry;
  13248. serialize(): any;
  13249. }
  13250. /**
  13251. * Creates a ribbon geometry
  13252. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  13253. */
  13254. class RibbonGeometry extends _PrimitiveGeometry {
  13255. /**
  13256. * Defines the array of paths to use
  13257. */
  13258. pathArray: Vector3[][];
  13259. /**
  13260. * Defines if the last and first points of each path in your pathArray must be joined
  13261. */
  13262. closeArray: boolean;
  13263. /**
  13264. * Defines if the last and first points of each path in your pathArray must be joined
  13265. */
  13266. closePath: boolean;
  13267. /**
  13268. * Defines the offset between points
  13269. */
  13270. offset: number;
  13271. /**
  13272. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13273. */
  13274. side: number;
  13275. /**
  13276. * Creates a ribbon geometry
  13277. * @param id defines the unique ID of the geometry
  13278. * @param scene defines the hosting scene
  13279. * @param pathArray defines the array of paths to use
  13280. * @param closeArray defines if the last path and the first path must be joined
  13281. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  13282. * @param offset defines the offset between points
  13283. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13284. * @param mesh defines the hosting mesh (can be null)
  13285. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13286. */
  13287. constructor(id: string, scene: Scene,
  13288. /**
  13289. * Defines the array of paths to use
  13290. */
  13291. pathArray: Vector3[][],
  13292. /**
  13293. * Defines if the last and first points of each path in your pathArray must be joined
  13294. */
  13295. closeArray: boolean,
  13296. /**
  13297. * Defines if the last and first points of each path in your pathArray must be joined
  13298. */
  13299. closePath: boolean,
  13300. /**
  13301. * Defines the offset between points
  13302. */
  13303. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  13304. /**
  13305. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13306. */
  13307. side?: number);
  13308. /** @ignore */
  13309. _regenerateVertexData(): VertexData;
  13310. copy(id: string): Geometry;
  13311. }
  13312. /**
  13313. * Creates a box geometry
  13314. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  13315. */
  13316. class BoxGeometry extends _PrimitiveGeometry {
  13317. /**
  13318. * Defines the zise of the box (width, height and depth are the same)
  13319. */
  13320. size: number;
  13321. /**
  13322. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13323. */
  13324. side: number;
  13325. /**
  13326. * Creates a box geometry
  13327. * @param id defines the unique ID of the geometry
  13328. * @param scene defines the hosting scene
  13329. * @param size defines the zise of the box (width, height and depth are the same)
  13330. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13331. * @param mesh defines the hosting mesh (can be null)
  13332. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13333. */
  13334. constructor(id: string, scene: Scene,
  13335. /**
  13336. * Defines the zise of the box (width, height and depth are the same)
  13337. */
  13338. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13339. /**
  13340. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13341. */
  13342. side?: number);
  13343. _regenerateVertexData(): VertexData;
  13344. copy(id: string): Geometry;
  13345. serialize(): any;
  13346. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  13347. }
  13348. /**
  13349. * Creates a sphere geometry
  13350. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  13351. */
  13352. class SphereGeometry extends _PrimitiveGeometry {
  13353. /**
  13354. * Defines the number of segments to use to create the sphere
  13355. */
  13356. segments: number;
  13357. /**
  13358. * Defines the diameter of the sphere
  13359. */
  13360. diameter: number;
  13361. /**
  13362. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13363. */
  13364. side: number;
  13365. /**
  13366. * Create a new sphere geometry
  13367. * @param id defines the unique ID of the geometry
  13368. * @param scene defines the hosting scene
  13369. * @param segments defines the number of segments to use to create the sphere
  13370. * @param diameter defines the diameter of the sphere
  13371. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13372. * @param mesh defines the hosting mesh (can be null)
  13373. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13374. */
  13375. constructor(id: string, scene: Scene,
  13376. /**
  13377. * Defines the number of segments to use to create the sphere
  13378. */
  13379. segments: number,
  13380. /**
  13381. * Defines the diameter of the sphere
  13382. */
  13383. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13384. /**
  13385. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13386. */
  13387. side?: number);
  13388. _regenerateVertexData(): VertexData;
  13389. copy(id: string): Geometry;
  13390. serialize(): any;
  13391. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  13392. }
  13393. /**
  13394. * Creates a disc geometry
  13395. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  13396. */
  13397. class DiscGeometry extends _PrimitiveGeometry {
  13398. /**
  13399. * Defines the radius of the disc
  13400. */
  13401. radius: number;
  13402. /**
  13403. * Defines the tesselation factor to apply to the disc
  13404. */
  13405. tessellation: number;
  13406. /**
  13407. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13408. */
  13409. side: number;
  13410. /**
  13411. * Creates a new disc geometry
  13412. * @param id defines the unique ID of the geometry
  13413. * @param scene defines the hosting scene
  13414. * @param radius defines the radius of the disc
  13415. * @param tessellation defines the tesselation factor to apply to the disc
  13416. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13417. * @param mesh defines the hosting mesh (can be null)
  13418. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13419. */
  13420. constructor(id: string, scene: Scene,
  13421. /**
  13422. * Defines the radius of the disc
  13423. */
  13424. radius: number,
  13425. /**
  13426. * Defines the tesselation factor to apply to the disc
  13427. */
  13428. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13429. /**
  13430. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13431. */
  13432. side?: number);
  13433. _regenerateVertexData(): VertexData;
  13434. copy(id: string): Geometry;
  13435. }
  13436. /**
  13437. * Creates a new cylinder geometry
  13438. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  13439. */
  13440. class CylinderGeometry extends _PrimitiveGeometry {
  13441. /**
  13442. * Defines the height of the cylinder
  13443. */
  13444. height: number;
  13445. /**
  13446. * Defines the diameter of the cylinder's top cap
  13447. */
  13448. diameterTop: number;
  13449. /**
  13450. * Defines the diameter of the cylinder's bottom cap
  13451. */
  13452. diameterBottom: number;
  13453. /**
  13454. * Defines the tessellation factor to apply to the cylinder
  13455. */
  13456. tessellation: number;
  13457. /**
  13458. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  13459. */
  13460. subdivisions: number;
  13461. /**
  13462. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13463. */
  13464. side: number;
  13465. /**
  13466. * Creates a new cylinder geometry
  13467. * @param id defines the unique ID of the geometry
  13468. * @param scene defines the hosting scene
  13469. * @param height defines the height of the cylinder
  13470. * @param diameterTop defines the diameter of the cylinder's top cap
  13471. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  13472. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  13473. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  13474. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13475. * @param mesh defines the hosting mesh (can be null)
  13476. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13477. */
  13478. constructor(id: string, scene: Scene,
  13479. /**
  13480. * Defines the height of the cylinder
  13481. */
  13482. height: number,
  13483. /**
  13484. * Defines the diameter of the cylinder's top cap
  13485. */
  13486. diameterTop: number,
  13487. /**
  13488. * Defines the diameter of the cylinder's bottom cap
  13489. */
  13490. diameterBottom: number,
  13491. /**
  13492. * Defines the tessellation factor to apply to the cylinder
  13493. */
  13494. tessellation: number,
  13495. /**
  13496. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  13497. */
  13498. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13499. /**
  13500. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13501. */
  13502. side?: number);
  13503. _regenerateVertexData(): VertexData;
  13504. copy(id: string): Geometry;
  13505. serialize(): any;
  13506. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  13507. }
  13508. /**
  13509. * Creates a new torus geometry
  13510. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  13511. */
  13512. class TorusGeometry extends _PrimitiveGeometry {
  13513. /**
  13514. * Defines the diameter of the torus
  13515. */
  13516. diameter: number;
  13517. /**
  13518. * Defines the thickness of the torus (ie. internal diameter)
  13519. */
  13520. thickness: number;
  13521. /**
  13522. * Defines the tesselation factor to apply to the torus
  13523. */
  13524. tessellation: number;
  13525. /**
  13526. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13527. */
  13528. side: number;
  13529. /**
  13530. * Creates a new torus geometry
  13531. * @param id defines the unique ID of the geometry
  13532. * @param scene defines the hosting scene
  13533. * @param diameter defines the diameter of the torus
  13534. * @param thickness defines the thickness of the torus (ie. internal diameter)
  13535. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  13536. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13537. * @param mesh defines the hosting mesh (can be null)
  13538. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13539. */
  13540. constructor(id: string, scene: Scene,
  13541. /**
  13542. * Defines the diameter of the torus
  13543. */
  13544. diameter: number,
  13545. /**
  13546. * Defines the thickness of the torus (ie. internal diameter)
  13547. */
  13548. thickness: number,
  13549. /**
  13550. * Defines the tesselation factor to apply to the torus
  13551. */
  13552. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13553. /**
  13554. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13555. */
  13556. side?: number);
  13557. _regenerateVertexData(): VertexData;
  13558. copy(id: string): Geometry;
  13559. serialize(): any;
  13560. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  13561. }
  13562. /**
  13563. * Creates a new ground geometry
  13564. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  13565. */
  13566. class GroundGeometry extends _PrimitiveGeometry {
  13567. /**
  13568. * Defines the width of the ground
  13569. */
  13570. width: number;
  13571. /**
  13572. * Defines the height of the ground
  13573. */
  13574. height: number;
  13575. /**
  13576. * Defines the subdivisions to apply to the ground
  13577. */
  13578. subdivisions: number;
  13579. /**
  13580. * Creates a new ground geometry
  13581. * @param id defines the unique ID of the geometry
  13582. * @param scene defines the hosting scene
  13583. * @param width defines the width of the ground
  13584. * @param height defines the height of the ground
  13585. * @param subdivisions defines the subdivisions to apply to the ground
  13586. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13587. * @param mesh defines the hosting mesh (can be null)
  13588. */
  13589. constructor(id: string, scene: Scene,
  13590. /**
  13591. * Defines the width of the ground
  13592. */
  13593. width: number,
  13594. /**
  13595. * Defines the height of the ground
  13596. */
  13597. height: number,
  13598. /**
  13599. * Defines the subdivisions to apply to the ground
  13600. */
  13601. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  13602. _regenerateVertexData(): VertexData;
  13603. copy(id: string): Geometry;
  13604. serialize(): any;
  13605. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  13606. }
  13607. /**
  13608. * Creates a tiled ground geometry
  13609. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  13610. */
  13611. class TiledGroundGeometry extends _PrimitiveGeometry {
  13612. /**
  13613. * Defines the minimum value on X axis
  13614. */
  13615. xmin: number;
  13616. /**
  13617. * Defines the minimum value on Z axis
  13618. */
  13619. zmin: number;
  13620. /**
  13621. * Defines the maximum value on X axis
  13622. */
  13623. xmax: number;
  13624. /**
  13625. * Defines the maximum value on Z axis
  13626. */
  13627. zmax: number;
  13628. /**
  13629. * Defines the subdivisions to apply to the ground
  13630. */
  13631. subdivisions: {
  13632. w: number;
  13633. h: number;
  13634. };
  13635. /**
  13636. * Defines the precision to use when computing the tiles
  13637. */
  13638. precision: {
  13639. w: number;
  13640. h: number;
  13641. };
  13642. /**
  13643. * Creates a tiled ground geometry
  13644. * @param id defines the unique ID of the geometry
  13645. * @param scene defines the hosting scene
  13646. * @param xmin defines the minimum value on X axis
  13647. * @param zmin defines the minimum value on Z axis
  13648. * @param xmax defines the maximum value on X axis
  13649. * @param zmax defines the maximum value on Z axis
  13650. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  13651. * @param precision defines the precision to use when computing the tiles
  13652. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13653. * @param mesh defines the hosting mesh (can be null)
  13654. */
  13655. constructor(id: string, scene: Scene,
  13656. /**
  13657. * Defines the minimum value on X axis
  13658. */
  13659. xmin: number,
  13660. /**
  13661. * Defines the minimum value on Z axis
  13662. */
  13663. zmin: number,
  13664. /**
  13665. * Defines the maximum value on X axis
  13666. */
  13667. xmax: number,
  13668. /**
  13669. * Defines the maximum value on Z axis
  13670. */
  13671. zmax: number,
  13672. /**
  13673. * Defines the subdivisions to apply to the ground
  13674. */
  13675. subdivisions: {
  13676. w: number;
  13677. h: number;
  13678. },
  13679. /**
  13680. * Defines the precision to use when computing the tiles
  13681. */
  13682. precision: {
  13683. w: number;
  13684. h: number;
  13685. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  13686. _regenerateVertexData(): VertexData;
  13687. copy(id: string): Geometry;
  13688. }
  13689. /**
  13690. * Creates a plane geometry
  13691. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  13692. */
  13693. class PlaneGeometry extends _PrimitiveGeometry {
  13694. /**
  13695. * Defines the size of the plane (width === height)
  13696. */
  13697. size: number;
  13698. /**
  13699. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13700. */
  13701. side: number;
  13702. /**
  13703. * Creates a plane geometry
  13704. * @param id defines the unique ID of the geometry
  13705. * @param scene defines the hosting scene
  13706. * @param size defines the size of the plane (width === height)
  13707. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13708. * @param mesh defines the hosting mesh (can be null)
  13709. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13710. */
  13711. constructor(id: string, scene: Scene,
  13712. /**
  13713. * Defines the size of the plane (width === height)
  13714. */
  13715. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13716. /**
  13717. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13718. */
  13719. side?: number);
  13720. _regenerateVertexData(): VertexData;
  13721. copy(id: string): Geometry;
  13722. serialize(): any;
  13723. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  13724. }
  13725. /**
  13726. * Creates a torus knot geometry
  13727. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  13728. */
  13729. class TorusKnotGeometry extends _PrimitiveGeometry {
  13730. /**
  13731. * Defines the radius of the torus knot
  13732. */
  13733. radius: number;
  13734. /**
  13735. * Defines the thickness of the torus knot tube
  13736. */
  13737. tube: number;
  13738. /**
  13739. * Defines the number of radial segments
  13740. */
  13741. radialSegments: number;
  13742. /**
  13743. * Defines the number of tubular segments
  13744. */
  13745. tubularSegments: number;
  13746. /**
  13747. * Defines the first number of windings
  13748. */
  13749. p: number;
  13750. /**
  13751. * Defines the second number of windings
  13752. */
  13753. q: number;
  13754. /**
  13755. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13756. */
  13757. side: number;
  13758. /**
  13759. * Creates a torus knot geometry
  13760. * @param id defines the unique ID of the geometry
  13761. * @param scene defines the hosting scene
  13762. * @param radius defines the radius of the torus knot
  13763. * @param tube defines the thickness of the torus knot tube
  13764. * @param radialSegments defines the number of radial segments
  13765. * @param tubularSegments defines the number of tubular segments
  13766. * @param p defines the first number of windings
  13767. * @param q defines the second number of windings
  13768. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13769. * @param mesh defines the hosting mesh (can be null)
  13770. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13771. */
  13772. constructor(id: string, scene: Scene,
  13773. /**
  13774. * Defines the radius of the torus knot
  13775. */
  13776. radius: number,
  13777. /**
  13778. * Defines the thickness of the torus knot tube
  13779. */
  13780. tube: number,
  13781. /**
  13782. * Defines the number of radial segments
  13783. */
  13784. radialSegments: number,
  13785. /**
  13786. * Defines the number of tubular segments
  13787. */
  13788. tubularSegments: number,
  13789. /**
  13790. * Defines the first number of windings
  13791. */
  13792. p: number,
  13793. /**
  13794. * Defines the second number of windings
  13795. */
  13796. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  13797. /**
  13798. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13799. */
  13800. side?: number);
  13801. _regenerateVertexData(): VertexData;
  13802. copy(id: string): Geometry;
  13803. serialize(): any;
  13804. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  13805. }
  13806. }
  13807. declare module BABYLON {
  13808. class GroundMesh extends Mesh {
  13809. generateOctree: boolean;
  13810. private _heightQuads;
  13811. _subdivisionsX: number;
  13812. _subdivisionsY: number;
  13813. _width: number;
  13814. _height: number;
  13815. _minX: number;
  13816. _maxX: number;
  13817. _minZ: number;
  13818. _maxZ: number;
  13819. constructor(name: string, scene: Scene);
  13820. getClassName(): string;
  13821. readonly subdivisions: number;
  13822. readonly subdivisionsX: number;
  13823. readonly subdivisionsY: number;
  13824. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  13825. /**
  13826. * Returns a height (y) value in the Worl system :
  13827. * the ground altitude at the coordinates (x, z) expressed in the World system.
  13828. * Returns the ground y position if (x, z) are outside the ground surface.
  13829. */
  13830. getHeightAtCoordinates(x: number, z: number): number;
  13831. /**
  13832. * Returns a normalized vector (Vector3) orthogonal to the ground
  13833. * at the ground coordinates (x, z) expressed in the World system.
  13834. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  13835. */
  13836. getNormalAtCoordinates(x: number, z: number): Vector3;
  13837. /**
  13838. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  13839. * at the ground coordinates (x, z) expressed in the World system.
  13840. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13841. * Returns the GroundMesh.
  13842. */
  13843. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13844. /**
  13845. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13846. * if the ground has been updated.
  13847. * This can be used in the render loop.
  13848. * Returns the GroundMesh.
  13849. */
  13850. updateCoordinateHeights(): GroundMesh;
  13851. private _getFacetAt(x, z);
  13852. private _initHeightQuads();
  13853. private _computeHeightQuads();
  13854. serialize(serializationObject: any): void;
  13855. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13856. }
  13857. }
  13858. declare module BABYLON {
  13859. /**
  13860. * Creates an instance based on a source mesh.
  13861. */
  13862. class InstancedMesh extends AbstractMesh {
  13863. private _sourceMesh;
  13864. private _currentLOD;
  13865. constructor(name: string, source: Mesh);
  13866. /**
  13867. * Returns the string "InstancedMesh".
  13868. */
  13869. getClassName(): string;
  13870. readonly receiveShadows: boolean;
  13871. readonly material: Nullable<Material>;
  13872. readonly visibility: number;
  13873. readonly skeleton: Nullable<Skeleton>;
  13874. renderingGroupId: number;
  13875. /**
  13876. * Returns the total number of vertices (integer).
  13877. */
  13878. getTotalVertices(): number;
  13879. readonly sourceMesh: Mesh;
  13880. /**
  13881. * Is this node ready to be used/rendered
  13882. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  13883. * @return {boolean} is it ready
  13884. */
  13885. isReady(completeCheck?: boolean): boolean;
  13886. /**
  13887. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  13888. */
  13889. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  13890. /**
  13891. * Sets the vertex data of the mesh geometry for the requested `kind`.
  13892. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  13893. * The `data` are either a numeric array either a Float32Array.
  13894. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  13895. * 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).
  13896. * Note that a new underlying VertexBuffer object is created each call.
  13897. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  13898. *
  13899. * Possible `kind` values :
  13900. * - BABYLON.VertexBuffer.PositionKind
  13901. * - BABYLON.VertexBuffer.UVKind
  13902. * - BABYLON.VertexBuffer.UV2Kind
  13903. * - BABYLON.VertexBuffer.UV3Kind
  13904. * - BABYLON.VertexBuffer.UV4Kind
  13905. * - BABYLON.VertexBuffer.UV5Kind
  13906. * - BABYLON.VertexBuffer.UV6Kind
  13907. * - BABYLON.VertexBuffer.ColorKind
  13908. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13909. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13910. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13911. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13912. *
  13913. * Returns the Mesh.
  13914. */
  13915. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  13916. /**
  13917. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  13918. * If the mesh has no geometry, it is simply returned as it is.
  13919. * The `data` are either a numeric array either a Float32Array.
  13920. * No new underlying VertexBuffer object is created.
  13921. * 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.
  13922. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  13923. *
  13924. * Possible `kind` values :
  13925. * - BABYLON.VertexBuffer.PositionKind
  13926. * - BABYLON.VertexBuffer.UVKind
  13927. * - BABYLON.VertexBuffer.UV2Kind
  13928. * - BABYLON.VertexBuffer.UV3Kind
  13929. * - BABYLON.VertexBuffer.UV4Kind
  13930. * - BABYLON.VertexBuffer.UV5Kind
  13931. * - BABYLON.VertexBuffer.UV6Kind
  13932. * - BABYLON.VertexBuffer.ColorKind
  13933. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13934. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13935. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13936. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13937. *
  13938. * Returns the Mesh.
  13939. */
  13940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  13941. /**
  13942. * Sets the mesh indices.
  13943. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  13944. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  13945. * This method creates a new index buffer each call.
  13946. * Returns the Mesh.
  13947. */
  13948. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  13949. /**
  13950. * Boolean : True if the mesh owns the requested kind of data.
  13951. */
  13952. isVerticesDataPresent(kind: string): boolean;
  13953. /**
  13954. * Returns an array of indices (IndicesArray).
  13955. */
  13956. getIndices(): Nullable<IndicesArray>;
  13957. readonly _positions: Nullable<Vector3[]>;
  13958. /**
  13959. * Sets a new updated BoundingInfo to the mesh.
  13960. * Returns the mesh.
  13961. */
  13962. refreshBoundingInfo(): InstancedMesh;
  13963. _preActivate(): InstancedMesh;
  13964. _activate(renderId: number): InstancedMesh;
  13965. /**
  13966. * Returns the current associated LOD AbstractMesh.
  13967. */
  13968. getLOD(camera: Camera): AbstractMesh;
  13969. _syncSubMeshes(): InstancedMesh;
  13970. _generatePointsArray(): boolean;
  13971. /**
  13972. * Creates a new InstancedMesh from the current mesh.
  13973. * - name (string) : the cloned mesh name
  13974. * - newParent (optional Node) : the optional Node to parent the clone to.
  13975. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  13976. *
  13977. * Returns the clone.
  13978. */
  13979. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  13980. /**
  13981. * Disposes the InstancedMesh.
  13982. * Returns nothing.
  13983. */
  13984. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13985. }
  13986. }
  13987. declare module BABYLON {
  13988. class LinesMesh extends Mesh {
  13989. useVertexColor: boolean | undefined;
  13990. useVertexAlpha: boolean | undefined;
  13991. color: Color3;
  13992. alpha: number;
  13993. /**
  13994. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  13995. * This margin is expressed in world space coordinates, so its value may vary.
  13996. * Default value is 0.1
  13997. * @returns the intersection Threshold value.
  13998. */
  13999. /**
  14000. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  14001. * This margin is expressed in world space coordinates, so its value may vary.
  14002. * @param value the new threshold to apply
  14003. */
  14004. intersectionThreshold: number;
  14005. private _intersectionThreshold;
  14006. private _colorShader;
  14007. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  14008. /**
  14009. * Returns the string "LineMesh"
  14010. */
  14011. getClassName(): string;
  14012. material: Material;
  14013. readonly checkCollisions: boolean;
  14014. createInstance(name: string): InstancedMesh;
  14015. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  14016. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  14017. dispose(doNotRecurse?: boolean): void;
  14018. /**
  14019. * Returns a new LineMesh object cloned from the current one.
  14020. */
  14021. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. class _InstancesBatch {
  14026. mustReturn: boolean;
  14027. visibleInstances: Nullable<InstancedMesh[]>[];
  14028. renderSelf: boolean[];
  14029. }
  14030. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14031. static _FRONTSIDE: number;
  14032. static _BACKSIDE: number;
  14033. static _DOUBLESIDE: number;
  14034. static _DEFAULTSIDE: number;
  14035. static _NO_CAP: number;
  14036. static _CAP_START: number;
  14037. static _CAP_END: number;
  14038. static _CAP_ALL: number;
  14039. /**
  14040. * Mesh side orientation : usually the external or front surface
  14041. */
  14042. static readonly FRONTSIDE: number;
  14043. /**
  14044. * Mesh side orientation : usually the internal or back surface
  14045. */
  14046. static readonly BACKSIDE: number;
  14047. /**
  14048. * Mesh side orientation : both internal and external or front and back surfaces
  14049. */
  14050. static readonly DOUBLESIDE: number;
  14051. /**
  14052. * Mesh side orientation : by default, `FRONTSIDE`
  14053. */
  14054. static readonly DEFAULTSIDE: number;
  14055. /**
  14056. * Mesh cap setting : no cap
  14057. */
  14058. static readonly NO_CAP: number;
  14059. /**
  14060. * Mesh cap setting : one cap at the beginning of the mesh
  14061. */
  14062. static readonly CAP_START: number;
  14063. /**
  14064. * Mesh cap setting : one cap at the end of the mesh
  14065. */
  14066. static readonly CAP_END: number;
  14067. /**
  14068. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14069. */
  14070. static readonly CAP_ALL: number;
  14071. /**
  14072. * An event triggered before rendering the mesh
  14073. * @type {BABYLON.Observable}
  14074. */
  14075. onBeforeRenderObservable: Observable<Mesh>;
  14076. /**
  14077. * An event triggered after rendering the mesh
  14078. * @type {BABYLON.Observable}
  14079. */
  14080. onAfterRenderObservable: Observable<Mesh>;
  14081. /**
  14082. * An event triggered before drawing the mesh
  14083. * @type {BABYLON.Observable}
  14084. */
  14085. onBeforeDrawObservable: Observable<Mesh>;
  14086. private _onBeforeDrawObserver;
  14087. onBeforeDraw: () => void;
  14088. delayLoadState: number;
  14089. instances: InstancedMesh[];
  14090. delayLoadingFile: string;
  14091. _binaryInfo: any;
  14092. private _LODLevels;
  14093. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  14094. private _morphTargetManager;
  14095. morphTargetManager: Nullable<MorphTargetManager>;
  14096. _geometry: Nullable<Geometry>;
  14097. _delayInfo: Array<string>;
  14098. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14099. _visibleInstances: any;
  14100. private _renderIdForInstances;
  14101. private _batchCache;
  14102. private _instancesBufferSize;
  14103. private _instancesBuffer;
  14104. private _instancesData;
  14105. private _overridenInstanceCount;
  14106. private _effectiveMaterial;
  14107. _shouldGenerateFlatShading: boolean;
  14108. private _preActivateId;
  14109. _originalBuilderSideOrientation: number;
  14110. overrideMaterialSideOrientation: Nullable<number>;
  14111. private _areNormalsFrozen;
  14112. private _sourcePositions;
  14113. private _sourceNormals;
  14114. private _source;
  14115. readonly source: Nullable<Mesh>;
  14116. isUnIndexed: boolean;
  14117. /**
  14118. * @constructor
  14119. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  14120. * @param {Scene} scene The scene to add this mesh to.
  14121. * @param {Node} parent The parent of this mesh, if it has one
  14122. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  14123. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14124. * When false, achieved by calling a clone(), also passing False.
  14125. * This will make creation of children, recursive.
  14126. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14127. */
  14128. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14129. /**
  14130. * Returns the string "Mesh".
  14131. */
  14132. getClassName(): string;
  14133. /**
  14134. * Returns a string.
  14135. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  14136. */
  14137. toString(fullDetails?: boolean): string;
  14138. /**
  14139. * True if the mesh has some Levels Of Details (LOD).
  14140. * Returns a boolean.
  14141. */
  14142. readonly hasLODLevels: boolean;
  14143. /**
  14144. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  14145. * @returns an array of {BABYLON.MeshLODLevel}
  14146. */
  14147. getLODLevels(): MeshLODLevel[];
  14148. private _sortLODLevels();
  14149. /**
  14150. * Add a mesh as LOD level triggered at the given distance.
  14151. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14152. * @param {number} distance The distance from the center of the object to show this level
  14153. * @param {Mesh} mesh The mesh to be added as LOD level
  14154. * @return {Mesh} This mesh (for chaining)
  14155. */
  14156. addLODLevel(distance: number, mesh: Mesh): Mesh;
  14157. /**
  14158. * Returns the LOD level mesh at the passed distance or null if not found.
  14159. * It is related to the method `addLODLevel(distance, mesh)`.
  14160. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14161. * Returns an object Mesh or `null`.
  14162. */
  14163. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14164. /**
  14165. * Remove a mesh from the LOD array
  14166. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14167. * @param {Mesh} mesh The mesh to be removed.
  14168. * @return {Mesh} This mesh (for chaining)
  14169. */
  14170. removeLODLevel(mesh: Mesh): Mesh;
  14171. /**
  14172. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14173. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14174. */
  14175. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  14176. /**
  14177. * Returns the mesh internal Geometry object.
  14178. */
  14179. readonly geometry: Nullable<Geometry>;
  14180. /**
  14181. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14182. */
  14183. getTotalVertices(): number;
  14184. /**
  14185. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  14186. * 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.
  14187. * You can force the copy with forceCopy === true
  14188. * Returns null if the mesh has no geometry or no vertex buffer.
  14189. * Possible `kind` values :
  14190. * - BABYLON.VertexBuffer.PositionKind
  14191. * - BABYLON.VertexBuffer.UVKind
  14192. * - BABYLON.VertexBuffer.UV2Kind
  14193. * - BABYLON.VertexBuffer.UV3Kind
  14194. * - BABYLON.VertexBuffer.UV4Kind
  14195. * - BABYLON.VertexBuffer.UV5Kind
  14196. * - BABYLON.VertexBuffer.UV6Kind
  14197. * - BABYLON.VertexBuffer.ColorKind
  14198. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14199. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14200. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14201. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14202. */
  14203. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14204. /**
  14205. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  14206. * Returns `null` if the mesh has no geometry.
  14207. * Possible `kind` values :
  14208. * - BABYLON.VertexBuffer.PositionKind
  14209. * - BABYLON.VertexBuffer.UVKind
  14210. * - BABYLON.VertexBuffer.UV2Kind
  14211. * - BABYLON.VertexBuffer.UV3Kind
  14212. * - BABYLON.VertexBuffer.UV4Kind
  14213. * - BABYLON.VertexBuffer.UV5Kind
  14214. * - BABYLON.VertexBuffer.UV6Kind
  14215. * - BABYLON.VertexBuffer.ColorKind
  14216. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14217. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14218. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14219. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14220. */
  14221. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14222. /**
  14223. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  14224. * Possible `kind` values :
  14225. * - BABYLON.VertexBuffer.PositionKind
  14226. * - BABYLON.VertexBuffer.UVKind
  14227. * - BABYLON.VertexBuffer.UV2Kind
  14228. * - BABYLON.VertexBuffer.UV3Kind
  14229. * - BABYLON.VertexBuffer.UV4Kind
  14230. * - BABYLON.VertexBuffer.UV5Kind
  14231. * - BABYLON.VertexBuffer.UV6Kind
  14232. * - BABYLON.VertexBuffer.ColorKind
  14233. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14234. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14235. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14236. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14237. */
  14238. isVerticesDataPresent(kind: string): boolean;
  14239. /**
  14240. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14241. * Possible `kind` values :
  14242. * - BABYLON.VertexBuffer.PositionKind
  14243. * - BABYLON.VertexBuffer.UVKind
  14244. * - BABYLON.VertexBuffer.UV2Kind
  14245. * - BABYLON.VertexBuffer.UV3Kind
  14246. * - BABYLON.VertexBuffer.UV4Kind
  14247. * - BABYLON.VertexBuffer.UV5Kind
  14248. * - BABYLON.VertexBuffer.UV6Kind
  14249. * - BABYLON.VertexBuffer.ColorKind
  14250. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14251. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14252. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14253. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14254. */
  14255. isVertexBufferUpdatable(kind: string): boolean;
  14256. /**
  14257. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  14258. * Possible `kind` values :
  14259. * - BABYLON.VertexBuffer.PositionKind
  14260. * - BABYLON.VertexBuffer.UVKind
  14261. * - BABYLON.VertexBuffer.UV2Kind
  14262. * - BABYLON.VertexBuffer.UV3Kind
  14263. * - BABYLON.VertexBuffer.UV4Kind
  14264. * - BABYLON.VertexBuffer.UV5Kind
  14265. * - BABYLON.VertexBuffer.UV6Kind
  14266. * - BABYLON.VertexBuffer.ColorKind
  14267. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14268. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14269. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14270. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14271. */
  14272. getVerticesDataKinds(): string[];
  14273. /**
  14274. * Returns a positive integer : the total number of indices in this mesh geometry.
  14275. * Returns zero if the mesh has no geometry.
  14276. */
  14277. getTotalIndices(): number;
  14278. /**
  14279. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14280. * 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.
  14281. * Returns an empty array if the mesh has no geometry.
  14282. */
  14283. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  14284. readonly isBlocked: boolean;
  14285. /**
  14286. * Determine if the current mesh is ready to be rendered
  14287. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14288. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14289. * @returns true if all associated assets are ready (material, textures, shaders)
  14290. */
  14291. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14292. /**
  14293. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  14294. * This property is pertinent only for updatable parametric shapes.
  14295. */
  14296. readonly areNormalsFrozen: boolean;
  14297. /**
  14298. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  14299. * It has no effect at all on other shapes.
  14300. * It prevents the mesh normals from being recomputed on next `positions` array update.
  14301. * Returns the Mesh.
  14302. */
  14303. freezeNormals(): Mesh;
  14304. /**
  14305. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  14306. * It has no effect at all on other shapes.
  14307. * It reactivates the mesh normals computation if it was previously frozen.
  14308. * Returns the Mesh.
  14309. */
  14310. unfreezeNormals(): Mesh;
  14311. /**
  14312. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14313. */
  14314. overridenInstanceCount: number;
  14315. _preActivate(): Mesh;
  14316. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14317. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14318. /**
  14319. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14320. * This means the mesh underlying bounding box and sphere are recomputed.
  14321. * Returns the Mesh.
  14322. */
  14323. refreshBoundingInfo(): Mesh;
  14324. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  14325. private _getPositionData(applySkeleton);
  14326. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14327. subdivide(count: number): void;
  14328. /**
  14329. * Sets the vertex data of the mesh geometry for the requested `kind`.
  14330. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  14331. * The `data` are either a numeric array either a Float32Array.
  14332. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  14333. * 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).
  14334. * Note that a new underlying VertexBuffer object is created each call.
  14335. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14336. *
  14337. * Possible `kind` values :
  14338. * - BABYLON.VertexBuffer.PositionKind
  14339. * - BABYLON.VertexBuffer.UVKind
  14340. * - BABYLON.VertexBuffer.UV2Kind
  14341. * - BABYLON.VertexBuffer.UV3Kind
  14342. * - BABYLON.VertexBuffer.UV4Kind
  14343. * - BABYLON.VertexBuffer.UV5Kind
  14344. * - BABYLON.VertexBuffer.UV6Kind
  14345. * - BABYLON.VertexBuffer.ColorKind
  14346. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14347. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14348. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14349. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14350. *
  14351. * Returns the Mesh.
  14352. */
  14353. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14354. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14355. /**
  14356. * Sets the mesh VertexBuffer.
  14357. * Returns the Mesh.
  14358. */
  14359. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14360. /**
  14361. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  14362. * If the mesh has no geometry, it is simply returned as it is.
  14363. * The `data` are either a numeric array either a Float32Array.
  14364. * No new underlying VertexBuffer object is created.
  14365. * 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.
  14366. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  14367. *
  14368. * Possible `kind` values :
  14369. * - BABYLON.VertexBuffer.PositionKind
  14370. * - BABYLON.VertexBuffer.UVKind
  14371. * - BABYLON.VertexBuffer.UV2Kind
  14372. * - BABYLON.VertexBuffer.UV3Kind
  14373. * - BABYLON.VertexBuffer.UV4Kind
  14374. * - BABYLON.VertexBuffer.UV5Kind
  14375. * - BABYLON.VertexBuffer.UV6Kind
  14376. * - BABYLON.VertexBuffer.ColorKind
  14377. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14378. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14379. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14380. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14381. *
  14382. * Returns the Mesh.
  14383. */
  14384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14385. /**
  14386. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14387. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14388. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  14389. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  14390. * Returns the Mesh.
  14391. */
  14392. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14393. /**
  14394. * Creates a un-shared specific occurence of the geometry for the mesh.
  14395. * Returns the Mesh.
  14396. */
  14397. makeGeometryUnique(): Mesh;
  14398. /**
  14399. * Sets the mesh indices.
  14400. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  14401. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  14402. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  14403. * This method creates a new index buffer each call.
  14404. * Returns the Mesh.
  14405. */
  14406. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14407. /**
  14408. * Update the current index buffer
  14409. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  14410. * Returns the Mesh.
  14411. */
  14412. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  14413. /**
  14414. * Invert the geometry to move from a right handed system to a left handed one.
  14415. * Returns the Mesh.
  14416. */
  14417. toLeftHanded(): Mesh;
  14418. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14419. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  14420. /**
  14421. * Registers for this mesh a javascript function called just before the rendering process.
  14422. * This function is passed the current mesh.
  14423. * Return the Mesh.
  14424. */
  14425. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14426. /**
  14427. * Disposes a previously registered javascript function called before the rendering.
  14428. * This function is passed the current mesh.
  14429. * Returns the Mesh.
  14430. */
  14431. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14432. /**
  14433. * Registers for this mesh a javascript function called just after the rendering is complete.
  14434. * This function is passed the current mesh.
  14435. * Returns the Mesh.
  14436. */
  14437. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14438. /**
  14439. * Disposes a previously registered javascript function called after the rendering.
  14440. * This function is passed the current mesh.
  14441. * Return the Mesh.
  14442. */
  14443. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14444. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14445. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14446. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14447. /**
  14448. * Triggers the draw call for the mesh.
  14449. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  14450. * Returns the Mesh.
  14451. */
  14452. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14453. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  14454. /**
  14455. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  14456. */
  14457. getEmittedParticleSystems(): IParticleSystem[];
  14458. /**
  14459. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  14460. */
  14461. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  14462. _checkDelayState(): Mesh;
  14463. private _queueLoad(scene);
  14464. /**
  14465. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  14466. */
  14467. isInFrustum(frustumPlanes: Plane[]): boolean;
  14468. /**
  14469. * Sets the mesh material by the material or multiMaterial `id` property.
  14470. * The material `id` is a string identifying the material or the multiMaterial.
  14471. * This method returns the Mesh.
  14472. */
  14473. setMaterialByID(id: string): Mesh;
  14474. /**
  14475. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14476. */
  14477. getAnimatables(): IAnimatable[];
  14478. /**
  14479. * Modifies the mesh geometry according to the passed transformation matrix.
  14480. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14481. * The mesh normals are modified accordingly the same transformation.
  14482. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  14483. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14484. * Returns the Mesh.
  14485. */
  14486. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14487. /**
  14488. * Modifies the mesh geometry according to its own current World Matrix.
  14489. * The mesh World Matrix is then reset.
  14490. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14491. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  14492. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14493. * Returns the Mesh.
  14494. */
  14495. bakeCurrentTransformIntoVertices(): Mesh;
  14496. readonly _positions: Nullable<Vector3[]>;
  14497. _resetPointsArrayCache(): Mesh;
  14498. _generatePointsArray(): boolean;
  14499. /**
  14500. * Returns a new Mesh object generated from the current mesh properties.
  14501. * This method must not get confused with createInstance().
  14502. * The parameter `name` is a string, the name given to the new mesh.
  14503. * The optional parameter `newParent` can be any Node object (default `null`).
  14504. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  14505. * 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.
  14506. */
  14507. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14508. /**
  14509. * Releases resources associated with this mesh.
  14510. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14511. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14512. */
  14513. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14514. /**
  14515. * Modifies the mesh geometry according to a displacement map.
  14516. * 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.
  14517. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14518. * This method returns nothing.
  14519. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  14520. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  14521. * 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.
  14522. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  14523. * The parameter `uvScale` is an optional vector2 used to scale UV.
  14524. *
  14525. * Returns the Mesh.
  14526. */
  14527. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  14528. /**
  14529. * Modifies the mesh geometry according to a displacementMap buffer.
  14530. * 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.
  14531. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14532. * This method returns nothing.
  14533. * 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.
  14534. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  14535. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  14536. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  14537. * The parameter `uvScale` is an optional vector2 used to scale UV.
  14538. *
  14539. * Returns the Mesh.
  14540. */
  14541. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  14542. /**
  14543. * Modify the mesh to get a flat shading rendering.
  14544. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14545. * This method returns the Mesh.
  14546. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14547. */
  14548. convertToFlatShadedMesh(): Mesh;
  14549. /**
  14550. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14551. * In other words, more vertices, no more indices and a single bigger VBO.
  14552. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14553. * Returns the Mesh.
  14554. */
  14555. convertToUnIndexedMesh(): Mesh;
  14556. /**
  14557. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  14558. * This method returns the Mesh.
  14559. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14560. */
  14561. flipFaces(flipNormals?: boolean): Mesh;
  14562. /**
  14563. * Creates a new InstancedMesh object from the mesh model.
  14564. * An instance shares the same properties and the same material than its model.
  14565. * Only these properties of each instance can then be set individually :
  14566. * - position
  14567. * - rotation
  14568. * - rotationQuaternion
  14569. * - setPivotMatrix
  14570. * - scaling
  14571. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  14572. * Warning : this method is not supported for Line mesh and LineSystem
  14573. */
  14574. createInstance(name: string): InstancedMesh;
  14575. /**
  14576. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14577. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14578. * This method returns the Mesh.
  14579. */
  14580. synchronizeInstances(): Mesh;
  14581. /**
  14582. * Simplify the mesh according to the given array of settings.
  14583. * Function will return immediately and will simplify async. It returns the Mesh.
  14584. * @param settings a collection of simplification settings.
  14585. * @param parallelProcessing should all levels calculate parallel or one after the other.
  14586. * @param type the type of simplification to run.
  14587. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  14588. */
  14589. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  14590. /**
  14591. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14592. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14593. * This should be used together with the simplification to avoid disappearing triangles.
  14594. * Returns the Mesh.
  14595. * @param successCallback an optional success callback to be called after the optimization finished.
  14596. */
  14597. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14598. serialize(serializationObject: any): void;
  14599. _syncGeometryWithMorphTargetManager(): void;
  14600. /**
  14601. <<<<<<< HEAD
  14602. * Returns a new Mesh object parsed from the source provided.
  14603. * The parameter `parsedMesh` is the source.
  14604. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14605. =======
  14606. * Binds the clip plane information from the scene to the effect.
  14607. * @param scene The scene the clip plane information are extracted from
  14608. * @param effect The effect we are binding the data to
  14609. */
  14610. static BindClipPlane(effect: Effect, scene: Scene): void;
  14611. }
  14612. }
  14613. declare module BABYLON {
  14614. class MultiMaterial extends Material {
  14615. private _subMaterials;
  14616. subMaterials: Nullable<Material>[];
  14617. constructor(name: string, scene: Scene);
  14618. private _hookArray(array);
  14619. getSubMaterial(index: number): Nullable<Material>;
  14620. getActiveTextures(): BaseTexture[];
  14621. getClassName(): string;
  14622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14623. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14624. serialize(): any;
  14625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14626. }
  14627. }
  14628. declare module BABYLON {
  14629. class PushMaterial extends Material {
  14630. protected _activeEffect: Effect;
  14631. protected _normalMatrix: Matrix;
  14632. constructor(name: string, scene: Scene);
  14633. getEffect(): Effect;
  14634. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14635. /**
  14636. * Binds the given world matrix to the active effect
  14637. *
  14638. * @param world the matrix to bind
  14639. */
  14640. bindOnlyWorldMatrix(world: Matrix): void;
  14641. /**
  14642. * Binds the given normal matrix to the active effect
  14643. *
  14644. * @param normalMatrix the matrix to bind
  14645. */
  14646. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14647. bind(world: Matrix, mesh?: Mesh): void;
  14648. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14649. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14650. }
  14651. }
  14652. declare module BABYLON {
  14653. class ShaderMaterial extends Material {
  14654. private _shaderPath;
  14655. private _options;
  14656. private _textures;
  14657. private _textureArrays;
  14658. private _floats;
  14659. private _ints;
  14660. private _floatsArrays;
  14661. private _colors3;
  14662. private _colors3Arrays;
  14663. private _colors4;
  14664. private _vectors2;
  14665. private _vectors3;
  14666. private _vectors4;
  14667. private _matrices;
  14668. private _matrices3x3;
  14669. private _matrices2x2;
  14670. private _vectors2Arrays;
  14671. private _vectors3Arrays;
  14672. private _cachedWorldViewMatrix;
  14673. private _renderId;
  14674. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14675. getClassName(): string;
  14676. needAlphaBlending(): boolean;
  14677. needAlphaTesting(): boolean;
  14678. private _checkUniform(uniformName);
  14679. setTexture(name: string, texture: Texture): ShaderMaterial;
  14680. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14681. setFloat(name: string, value: number): ShaderMaterial;
  14682. setInt(name: string, value: number): ShaderMaterial;
  14683. setFloats(name: string, value: number[]): ShaderMaterial;
  14684. setColor3(name: string, value: Color3): ShaderMaterial;
  14685. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14686. setColor4(name: string, value: Color4): ShaderMaterial;
  14687. setVector2(name: string, value: Vector2): ShaderMaterial;
  14688. setVector3(name: string, value: Vector3): ShaderMaterial;
  14689. setVector4(name: string, value: Vector4): ShaderMaterial;
  14690. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14691. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14692. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14693. setArray2(name: string, value: number[]): ShaderMaterial;
  14694. setArray3(name: string, value: number[]): ShaderMaterial;
  14695. private _checkCache(scene, mesh?, useInstances?);
  14696. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14697. bindOnlyWorldMatrix(world: Matrix): void;
  14698. bind(world: Matrix, mesh?: Mesh): void;
  14699. getActiveTextures(): BaseTexture[];
  14700. hasTexture(texture: BaseTexture): boolean;
  14701. clone(name: string): ShaderMaterial;
  14702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14703. serialize(): any;
  14704. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14705. }
  14706. }
  14707. declare module BABYLON {
  14708. /** @ignore */
  14709. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14710. MAINUV1: boolean;
  14711. MAINUV2: boolean;
  14712. DIFFUSE: boolean;
  14713. DIFFUSEDIRECTUV: number;
  14714. AMBIENT: boolean;
  14715. AMBIENTDIRECTUV: number;
  14716. OPACITY: boolean;
  14717. OPACITYDIRECTUV: number;
  14718. OPACITYRGB: boolean;
  14719. REFLECTION: boolean;
  14720. EMISSIVE: boolean;
  14721. EMISSIVEDIRECTUV: number;
  14722. SPECULAR: boolean;
  14723. SPECULARDIRECTUV: number;
  14724. BUMP: boolean;
  14725. BUMPDIRECTUV: number;
  14726. PARALLAX: boolean;
  14727. PARALLAXOCCLUSION: boolean;
  14728. SPECULAROVERALPHA: boolean;
  14729. CLIPPLANE: boolean;
  14730. ALPHATEST: boolean;
  14731. DEPTHPREPASS: boolean;
  14732. ALPHAFROMDIFFUSE: boolean;
  14733. POINTSIZE: boolean;
  14734. FOG: boolean;
  14735. SPECULARTERM: boolean;
  14736. DIFFUSEFRESNEL: boolean;
  14737. OPACITYFRESNEL: boolean;
  14738. REFLECTIONFRESNEL: boolean;
  14739. REFRACTIONFRESNEL: boolean;
  14740. EMISSIVEFRESNEL: boolean;
  14741. FRESNEL: boolean;
  14742. NORMAL: boolean;
  14743. UV1: boolean;
  14744. UV2: boolean;
  14745. VERTEXCOLOR: boolean;
  14746. VERTEXALPHA: boolean;
  14747. NUM_BONE_INFLUENCERS: number;
  14748. BonesPerMesh: number;
  14749. INSTANCES: boolean;
  14750. GLOSSINESS: boolean;
  14751. ROUGHNESS: boolean;
  14752. EMISSIVEASILLUMINATION: boolean;
  14753. LINKEMISSIVEWITHDIFFUSE: boolean;
  14754. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14755. LIGHTMAP: boolean;
  14756. LIGHTMAPDIRECTUV: number;
  14757. OBJECTSPACE_NORMALMAP: boolean;
  14758. USELIGHTMAPASSHADOWMAP: boolean;
  14759. REFLECTIONMAP_3D: boolean;
  14760. REFLECTIONMAP_SPHERICAL: boolean;
  14761. REFLECTIONMAP_PLANAR: boolean;
  14762. REFLECTIONMAP_CUBIC: boolean;
  14763. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14764. REFLECTIONMAP_PROJECTION: boolean;
  14765. REFLECTIONMAP_SKYBOX: boolean;
  14766. REFLECTIONMAP_EXPLICIT: boolean;
  14767. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14768. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14769. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14770. INVERTCUBICMAP: boolean;
  14771. LOGARITHMICDEPTH: boolean;
  14772. REFRACTION: boolean;
  14773. REFRACTIONMAP_3D: boolean;
  14774. REFLECTIONOVERALPHA: boolean;
  14775. TWOSIDEDLIGHTING: boolean;
  14776. SHADOWFLOAT: boolean;
  14777. MORPHTARGETS: boolean;
  14778. MORPHTARGETS_NORMAL: boolean;
  14779. MORPHTARGETS_TANGENT: boolean;
  14780. NUM_MORPH_INFLUENCERS: number;
  14781. NONUNIFORMSCALING: boolean;
  14782. PREMULTIPLYALPHA: boolean;
  14783. IMAGEPROCESSING: boolean;
  14784. VIGNETTE: boolean;
  14785. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14786. VIGNETTEBLENDMODEOPAQUE: boolean;
  14787. TONEMAPPING: boolean;
  14788. CONTRAST: boolean;
  14789. COLORCURVES: boolean;
  14790. COLORGRADING: boolean;
  14791. COLORGRADING3D: boolean;
  14792. SAMPLER3DGREENDEPTH: boolean;
  14793. SAMPLER3DBGRMAP: boolean;
  14794. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14795. EXPOSURE: boolean;
  14796. constructor();
  14797. setReflectionMode(modeToEnable: string): void;
  14798. }
  14799. class StandardMaterial extends PushMaterial {
  14800. private _diffuseTexture;
  14801. diffuseTexture: Nullable<BaseTexture>;
  14802. private _ambientTexture;
  14803. ambientTexture: Nullable<BaseTexture>;
  14804. private _opacityTexture;
  14805. opacityTexture: Nullable<BaseTexture>;
  14806. private _reflectionTexture;
  14807. reflectionTexture: Nullable<BaseTexture>;
  14808. private _emissiveTexture;
  14809. emissiveTexture: Nullable<BaseTexture>;
  14810. private _specularTexture;
  14811. specularTexture: Nullable<BaseTexture>;
  14812. private _bumpTexture;
  14813. bumpTexture: Nullable<BaseTexture>;
  14814. private _lightmapTexture;
  14815. lightmapTexture: Nullable<BaseTexture>;
  14816. private _refractionTexture;
  14817. refractionTexture: Nullable<BaseTexture>;
  14818. ambientColor: Color3;
  14819. diffuseColor: Color3;
  14820. specularColor: Color3;
  14821. emissiveColor: Color3;
  14822. specularPower: number;
  14823. private _useAlphaFromDiffuseTexture;
  14824. useAlphaFromDiffuseTexture: boolean;
  14825. private _useEmissiveAsIllumination;
  14826. useEmissiveAsIllumination: boolean;
  14827. private _linkEmissiveWithDiffuse;
  14828. linkEmissiveWithDiffuse: boolean;
  14829. private _useSpecularOverAlpha;
  14830. useSpecularOverAlpha: boolean;
  14831. private _useReflectionOverAlpha;
  14832. useReflectionOverAlpha: boolean;
  14833. private _disableLighting;
  14834. disableLighting: boolean;
  14835. private _useObjectSpaceNormalMap;
  14836. /**
  14837. * Allows using an object space normal map (instead of tangent space).
  14838. */
  14839. useObjectSpaceNormalMap: boolean;
  14840. private _useParallax;
  14841. useParallax: boolean;
  14842. private _useParallaxOcclusion;
  14843. useParallaxOcclusion: boolean;
  14844. parallaxScaleBias: number;
  14845. private _roughness;
  14846. roughness: number;
  14847. indexOfRefraction: number;
  14848. invertRefractionY: boolean;
  14849. private _useLightmapAsShadowmap;
  14850. useLightmapAsShadowmap: boolean;
  14851. private _diffuseFresnelParameters;
  14852. diffuseFresnelParameters: FresnelParameters;
  14853. private _opacityFresnelParameters;
  14854. opacityFresnelParameters: FresnelParameters;
  14855. private _reflectionFresnelParameters;
  14856. reflectionFresnelParameters: FresnelParameters;
  14857. private _refractionFresnelParameters;
  14858. refractionFresnelParameters: FresnelParameters;
  14859. private _emissiveFresnelParameters;
  14860. emissiveFresnelParameters: FresnelParameters;
  14861. private _useReflectionFresnelFromSpecular;
  14862. useReflectionFresnelFromSpecular: boolean;
  14863. private _useGlossinessFromSpecularMapAlpha;
  14864. useGlossinessFromSpecularMapAlpha: boolean;
  14865. private _maxSimultaneousLights;
  14866. maxSimultaneousLights: number;
  14867. /**
  14868. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14869. */
  14870. private _invertNormalMapX;
  14871. invertNormalMapX: boolean;
  14872. /**
  14873. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14874. */
  14875. private _invertNormalMapY;
  14876. invertNormalMapY: boolean;
  14877. /**
  14878. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14879. */
  14880. private _twoSidedLighting;
  14881. twoSidedLighting: boolean;
  14882. /**
  14883. * Default configuration related to image processing available in the standard Material.
  14884. */
  14885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14886. /**
  14887. * Gets the image processing configuration used either in this material.
  14888. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  14889. */
  14890. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14891. /**
  14892. * Creates a ribbon mesh.
  14893. * Please consider using the same method from the MeshBuilder class instead.
  14894. * 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.
  14895. *
  14896. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  14897. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14898. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  14899. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  14900. * 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.
  14901. * 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.
  14902. * 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
  14903. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14904. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14905. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14906. */
  14907. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14908. /**
  14909. * Creates a plane polygonal mesh. By default, this is a disc.
  14910. * Please consider using the same method from the MeshBuilder class instead.
  14911. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  14912. * 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.
  14913. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14914. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14915. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14916. */
  14917. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14918. /**
  14919. * Creates a box mesh.
  14920. * Please consider using the same method from the MeshBuilder class instead.
  14921. * The parameter `size` sets the size (float) of each box side (default 1).
  14922. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14923. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14924. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14925. */
  14926. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14927. /**
  14928. * Creates a sphere mesh.
  14929. * Please consider using the same method from the MeshBuilder class instead.
  14930. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  14931. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  14932. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14933. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14934. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14935. */
  14936. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14937. /**
  14938. * Creates a cylinder or a cone mesh.
  14939. * Please consider using the same method from the MeshBuilder class instead.
  14940. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  14941. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  14942. * 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.
  14943. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  14944. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  14945. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14946. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14947. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14948. */
  14949. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14950. /**
  14951. * Creates a torus mesh.
  14952. * Please consider using the same method from the MeshBuilder class instead.
  14953. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  14954. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  14955. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  14956. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14957. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14959. */
  14960. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14961. /**
  14962. * Creates a torus knot mesh.
  14963. * Please consider using the same method from the MeshBuilder class instead.
  14964. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  14965. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  14966. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  14967. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  14968. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  14969. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  14970. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14971. */
  14972. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14973. /**
  14974. * Creates a line mesh.
  14975. * Please consider using the same method from the MeshBuilder class instead.
  14976. * 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.
  14977. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  14978. * The parameter `points` is an array successive Vector3.
  14979. * 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
  14980. * When updating an instance, remember that only point positions can change, not the number of points.
  14981. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14982. */
  14983. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14984. /**
  14985. * Creates a dashed line mesh.
  14986. * Please consider using the same method from the MeshBuilder class instead.
  14987. * 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.
  14988. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  14989. * The parameter `points` is an array successive Vector3.
  14990. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  14991. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  14992. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  14993. * 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
  14994. * When updating an instance, remember that only point positions can change, not the number of points.
  14995. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14996. */
  14997. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14998. /**
  14999. * Creates a polygon mesh.
  15000. * Please consider using the same method from the MeshBuilder class instead.
  15001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15002. * 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.
  15003. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15004. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15005. * Remember you can only change the shape positions, not their number when updating a polygon.
  15006. */
  15007. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15008. /**
  15009. * Creates an extruded polygon mesh, with depth in the Y direction.
  15010. * Please consider using the same method from the MeshBuilder class instead.
  15011. */
  15012. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15013. /**
  15014. * Creates an extruded shape mesh.
  15015. * 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.
  15016. * Please consider using the same method from the MeshBuilder class instead.
  15017. *
  15018. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15019. * 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
  15020. * extruded along the Z axis.
  15021. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15022. * 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.
  15023. * The parameter `scale` (float, default 1) is the value to scale the shape.
  15024. * 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
  15025. * 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
  15026. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15027. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15028. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15029. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15030. */
  15031. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15032. /**
  15033. * Creates an custom extruded shape mesh.
  15034. * 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.
  15035. * Please consider using the same method from the MeshBuilder class instead.
  15036. *
  15037. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15038. * 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
  15039. * extruded along the Z axis.
  15040. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15041. * 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
  15042. * and the distance of this point from the begining of the path :
  15043. * ```javascript
  15044. * var rotationFunction = function(i, distance) {
  15045. * // do things
  15046. * return rotationValue; }
  15047. * ```
  15048. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  15049. * 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
  15050. * and the distance of this point from the begining of the path :
  15051. * ```javascript
  15052. * var scaleFunction = function(i, distance) {
  15053. * // do things
  15054. * return scaleValue;}
  15055. * ```
  15056. * It must returns a float value that will be the scale value applied to the shape on each path point.
  15057. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  15058. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  15059. * 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
  15060. * 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
  15061. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15062. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15063. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15064. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15065. */
  15066. 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;
  15067. /**
  15068. * Creates lathe mesh.
  15069. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15070. * Please consider using the same method from the MeshBuilder class instead.
  15071. * 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
  15072. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  15073. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  15074. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  15075. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15076. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15077. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15078. */
  15079. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15080. /**
  15081. * Creates a plane mesh.
  15082. * Please consider using the same method from the MeshBuilder class instead.
  15083. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  15084. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15085. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15086. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15087. */
  15088. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15089. /**
  15090. * Creates a ground mesh.
  15091. * Please consider using the same method from the MeshBuilder class instead.
  15092. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  15093. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  15094. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15095. */
  15096. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15097. /**
  15098. * Creates a tiled ground mesh.
  15099. * Please consider using the same method from the MeshBuilder class instead.
  15100. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  15101. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  15102. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  15103. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  15104. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  15105. * numbers of subdivisions on the ground width and height of each tile.
  15106. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15107. */
  15108. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15109. w: number;
  15110. h: number;
  15111. }, precision: {
  15112. w: number;
  15113. h: number;
  15114. }, scene: Scene, updatable?: boolean): Mesh;
  15115. /**
  15116. * Creates a ground mesh from a height map.
  15117. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  15118. * Please consider using the same method from the MeshBuilder class instead.
  15119. * The parameter `url` sets the URL of the height map image resource.
  15120. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  15121. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  15122. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  15123. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  15124. * 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).
  15125. * This function is passed the newly built mesh :
  15126. * ```javascript
  15127. * function(mesh) { // do things
  15128. * return; }
  15129. * ```
  15130. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15131. */
  15132. 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;
  15133. /**
  15134. * Creates a tube mesh.
  15135. * 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.
  15136. * Please consider using the same method from the MeshBuilder class instead.
  15137. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  15138. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  15139. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  15140. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  15141. * 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.
  15142. * It must return a radius value (positive float) :
  15143. * ```javascript
  15144. * var radiusFunction = function(i, distance) {
  15145. * // do things
  15146. * return radius; }
  15147. * ```
  15148. * 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
  15149. * 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
  15150. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15151. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15152. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15153. */
  15154. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15155. (i: number, distance: number): number;
  15156. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15157. /**
  15158. * Creates a polyhedron mesh.
  15159. * Please consider using the same method from the MeshBuilder class instead.
  15160. * 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
  15161. * to choose the wanted type.
  15162. * The parameter `size` (positive float, default 1) sets the polygon size.
  15163. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  15164. * 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`.
  15165. * 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
  15166. * 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)`).
  15167. * 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
  15168. * 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.
  15169. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15170. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15171. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15172. */
  15173. static CreatePolyhedron(name: string, options: {
  15174. type?: number;
  15175. size?: number;
  15176. sizeX?: number;
  15177. sizeY?: number;
  15178. sizeZ?: number;
  15179. custom?: any;
  15180. faceUV?: Vector4[];
  15181. faceColors?: Color4[];
  15182. updatable?: boolean;
  15183. sideOrientation?: number;
  15184. }, scene: Scene): Mesh;
  15185. /**
  15186. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  15187. * Please consider using the same method from the MeshBuilder class instead.
  15188. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  15189. * 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`).
  15190. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  15191. * 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.
  15192. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15193. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15194. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15195. */
  15196. static CreateIcoSphere(name: string, options: {
  15197. radius?: number;
  15198. flat?: boolean;
  15199. subdivisions?: number;
  15200. sideOrientation?: number;
  15201. updatable?: boolean;
  15202. }, scene: Scene): Mesh;
  15203. /**
  15204. * Creates a decal mesh.
  15205. * Please consider using the same method from the MeshBuilder class instead.
  15206. * 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.
  15207. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  15208. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  15209. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  15210. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  15211. */
  15212. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15213. /**
  15214. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15215. */
  15216. setPositionsForCPUSkinning(): Float32Array;
  15217. /**
  15218. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15219. */
  15220. setNormalsForCPUSkinning(): Float32Array;
  15221. /**
  15222. * Updates the vertex buffer by applying transformation from the bones.
  15223. * Returns the Mesh.
  15224. *
  15225. * @param {skeleton} skeleton to apply
  15226. */
  15227. applySkeleton(skeleton: Skeleton): Mesh;
  15228. /**
  15229. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  15230. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  15231. */
  15232. static MinMax(meshes: AbstractMesh[]): {
  15233. min: Vector3;
  15234. max: Vector3;
  15235. };
  15236. /**
  15237. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  15238. */
  15239. static Center(meshesOrMinMaxVector: {
  15240. min: Vector3;
  15241. max: Vector3;
  15242. } | AbstractMesh[]): Vector3;
  15243. /**
  15244. * Merge the array of meshes into a single mesh for performance reasons.
  15245. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  15246. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  15247. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  15248. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15249. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  15250. */
  15251. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  15252. }
  15253. }
  15254. declare module BABYLON {
  15255. interface IGetSetVerticesData {
  15256. isVerticesDataPresent(kind: string): boolean;
  15257. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15258. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  15259. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  15260. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  15261. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  15262. }
  15263. class VertexData {
  15264. positions: Nullable<FloatArray>;
  15265. normals: Nullable<FloatArray>;
  15266. tangents: Nullable<FloatArray>;
  15267. uvs: Nullable<FloatArray>;
  15268. uvs2: Nullable<FloatArray>;
  15269. uvs3: Nullable<FloatArray>;
  15270. uvs4: Nullable<FloatArray>;
  15271. uvs5: Nullable<FloatArray>;
  15272. uvs6: Nullable<FloatArray>;
  15273. colors: Nullable<FloatArray>;
  15274. matricesIndices: Nullable<FloatArray>;
  15275. matricesWeights: Nullable<FloatArray>;
  15276. matricesIndicesExtra: Nullable<FloatArray>;
  15277. matricesWeightsExtra: Nullable<FloatArray>;
  15278. indices: Nullable<IndicesArray>;
  15279. set(data: FloatArray, kind: string): void;
  15280. /**
  15281. * Associates the vertexData to the passed Mesh.
  15282. * Sets it as updatable or not (default `false`).
  15283. * Returns the VertexData.
  15284. */
  15285. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  15286. /**
  15287. * Associates the vertexData to the passed Geometry.
  15288. * Sets it as updatable or not (default `false`).
  15289. * Returns the VertexData.
  15290. */
  15291. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  15292. /**
  15293. * Updates the associated mesh.
  15294. * Returns the VertexData.
  15295. */
  15296. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  15297. /**
  15298. * Updates the associated geometry.
  15299. * Returns the VertexData.
  15300. */
  15301. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  15302. private _applyTo(meshOrGeometry, updatable?);
  15303. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  15304. /**
  15305. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  15306. * Returns the VertexData.
  15307. */
  15308. transform(matrix: Matrix): VertexData;
  15309. /**
  15310. * Merges the passed VertexData into the current one.
  15311. * Returns the modified VertexData.
  15312. */
  15313. merge(other: VertexData): VertexData;
  15314. private _mergeElement(source, other);
  15315. private _validate();
  15316. /**
  15317. * Serializes the VertexData.
  15318. * Returns a serialized object.
  15319. */
  15320. serialize(): any;
  15321. /**
  15322. * Returns the object VertexData associated to the passed mesh.
  15323. */
  15324. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  15325. /**
  15326. * Returns the object VertexData associated to the passed geometry.
  15327. */
  15328. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  15329. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  15330. /**
  15331. * Creates the vertexData of the Ribbon.
  15332. */
  15333. static CreateRibbon(options: {
  15334. pathArray: Vector3[][];
  15335. closeArray?: boolean;
  15336. closePath?: boolean;
  15337. offset?: number;
  15338. sideOrientation?: number;
  15339. frontUVs?: Vector4;
  15340. backUVs?: Vector4;
  15341. invertUV?: boolean;
  15342. uvs?: Vector2[];
  15343. colors?: Color4[];
  15344. }): VertexData;
  15345. /**
  15346. * Creates the VertexData of the Box.
  15347. */
  15348. static CreateBox(options: {
  15349. size?: number;
  15350. width?: number;
  15351. height?: number;
  15352. depth?: number;
  15353. faceUV?: Vector4[];
  15354. faceColors?: Color4[];
  15355. sideOrientation?: number;
  15356. frontUVs?: Vector4;
  15357. backUVs?: Vector4;
  15358. }): VertexData;
  15359. /**
  15360. * Creates the VertexData of the Sphere.
  15361. */
  15362. static CreateSphere(options: {
  15363. segments?: number;
  15364. diameter?: number;
  15365. diameterX?: number;
  15366. diameterY?: number;
  15367. diameterZ?: number;
  15368. arc?: number;
  15369. slice?: number;
  15370. sideOrientation?: number;
  15371. frontUVs?: Vector4;
  15372. backUVs?: Vector4;
  15373. }): VertexData;
  15374. /**
  15375. * Creates the VertexData of the Cylinder or Cone.
  15376. */
  15377. static CreateCylinder(options: {
  15378. height?: number;
  15379. diameterTop?: number;
  15380. diameterBottom?: number;
  15381. diameter?: number;
  15382. tessellation?: number;
  15383. subdivisions?: number;
  15384. arc?: number;
  15385. faceColors?: Color4[];
  15386. faceUV?: Vector4[];
  15387. hasRings?: boolean;
  15388. enclose?: boolean;
  15389. sideOrientation?: number;
  15390. frontUVs?: Vector4;
  15391. backUVs?: Vector4;
  15392. }): VertexData;
  15393. /**
  15394. * Creates the VertexData of the Torus.
  15395. */
  15396. static CreateTorus(options: {
  15397. diameter?: number;
  15398. thickness?: number;
  15399. tessellation?: number;
  15400. sideOrientation?: number;
  15401. frontUVs?: Vector4;
  15402. backUVs?: Vector4;
  15403. }): VertexData;
  15404. /**
  15405. * Creates the VertexData of the LineSystem.
  15406. */
  15407. static CreateLineSystem(options: {
  15408. lines: Vector3[][];
  15409. colors?: Nullable<Color4[][]>;
  15410. }): VertexData;
  15411. /**
  15412. * Create the VertexData of the DashedLines.
  15413. */
  15414. static CreateDashedLines(options: {
  15415. points: Vector3[];
  15416. dashSize?: number;
  15417. gapSize?: number;
  15418. dashNb?: number;
  15419. }): VertexData;
  15420. /**
  15421. * Creates the VertexData of the Ground.
  15422. */
  15423. static CreateGround(options: {
  15424. width?: number;
  15425. height?: number;
  15426. subdivisions?: number;
  15427. subdivisionsX?: number;
  15428. subdivisionsY?: number;
  15429. }): VertexData;
  15430. /**
  15431. * Creates the VertexData of the TiledGround.
  15432. */
  15433. static CreateTiledGround(options: {
  15434. xmin: number;
  15435. zmin: number;
  15436. xmax: number;
  15437. zmax: number;
  15438. subdivisions?: {
  15439. w: number;
  15440. h: number;
  15441. };
  15442. precision?: {
  15443. w: number;
  15444. h: number;
  15445. };
  15446. }): VertexData;
  15447. /**
  15448. * Creates the VertexData of the Ground designed from a heightmap.
  15449. */
  15450. static CreateGroundFromHeightMap(options: {
  15451. width: number;
  15452. height: number;
  15453. subdivisions: number;
  15454. minHeight: number;
  15455. maxHeight: number;
  15456. colorFilter: Color3;
  15457. buffer: Uint8Array;
  15458. bufferWidth: number;
  15459. bufferHeight: number;
  15460. }): VertexData;
  15461. /**
  15462. * Creates the VertexData of the Plane.
  15463. */
  15464. static CreatePlane(options: {
  15465. size?: number;
  15466. width?: number;
  15467. height?: number;
  15468. sideOrientation?: number;
  15469. frontUVs?: Vector4;
  15470. backUVs?: Vector4;
  15471. }): VertexData;
  15472. /**
  15473. * Creates the VertexData of the Disc or regular Polygon.
  15474. */
  15475. static CreateDisc(options: {
  15476. radius?: number;
  15477. tessellation?: number;
  15478. arc?: number;
  15479. sideOrientation?: number;
  15480. frontUVs?: Vector4;
  15481. backUVs?: Vector4;
  15482. }): VertexData;
  15483. /**
  15484. * Re-creates the VertexData of the Polygon for sideOrientation.
  15485. */
  15486. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  15487. /**
  15488. * Creates the VertexData of the IcoSphere.
  15489. */
  15490. static CreateIcoSphere(options: {
  15491. radius?: number;
  15492. radiusX?: number;
  15493. radiusY?: number;
  15494. radiusZ?: number;
  15495. flat?: boolean;
  15496. subdivisions?: number;
  15497. sideOrientation?: number;
  15498. frontUVs?: Vector4;
  15499. backUVs?: Vector4;
  15500. }): VertexData;
  15501. /**
  15502. * Creates the VertexData of the Polyhedron.
  15503. */
  15504. static CreatePolyhedron(options: {
  15505. type?: number;
  15506. size?: number;
  15507. sizeX?: number;
  15508. sizeY?: number;
  15509. sizeZ?: number;
  15510. custom?: any;
  15511. faceUV?: Vector4[];
  15512. faceColors?: Color4[];
  15513. flat?: boolean;
  15514. sideOrientation?: number;
  15515. frontUVs?: Vector4;
  15516. backUVs?: Vector4;
  15517. }): VertexData;
  15518. /**
  15519. * Creates the VertexData of the Torus Knot.
  15520. */
  15521. static CreateTorusKnot(options: {
  15522. radius?: number;
  15523. tube?: number;
  15524. radialSegments?: number;
  15525. tubularSegments?: number;
  15526. p?: number;
  15527. q?: number;
  15528. sideOrientation?: number;
  15529. frontUVs?: Vector4;
  15530. backUVs?: Vector4;
  15531. }): VertexData;
  15532. /**
  15533. * @param {any} - positions (number[] or Float32Array)
  15534. * @param {any} - indices (number[] or Uint16Array)
  15535. * @param {any} - normals (number[] or Float32Array)
  15536. * options (optional) :
  15537. * facetPositions : optional array of facet positions (vector3)
  15538. * facetNormals : optional array of facet normals (vector3)
  15539. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  15540. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  15541. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  15542. * bbSize : optional bounding box size data, required for facetPartitioning computation
  15543. * bInfo : optional bounding info, required for facetPartitioning computation
  15544. * useRightHandedSystem: optional boolean to for right handed system computation
  15545. * depthSort : optional boolean to enable the facet depth sort computation
  15546. * distanceTo : optional Vector3 to compute the facet depth from this location
  15547. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  15548. */
  15549. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  15550. facetNormals?: any;
  15551. facetPositions?: any;
  15552. facetPartitioning?: any;
  15553. ratio?: number;
  15554. bInfo?: any;
  15555. bbSize?: Vector3;
  15556. subDiv?: any;
  15557. useRightHandedSystem?: boolean;
  15558. depthSort?: boolean;
  15559. distanceTo?: Vector3;
  15560. depthSortedFacets?: any;
  15561. }): void;
  15562. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  15563. /**
  15564. * Creates a new VertexData from the imported parameters.
  15565. */
  15566. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  15567. }
  15568. }
  15569. declare module BABYLON {
  15570. <<<<<<< HEAD
  15571. class MeshBuilder {
  15572. private static updateSideOrientation(orientation?);
  15573. =======
  15574. class MorphTarget {
  15575. name: string;
  15576. animations: Animation[];
  15577. private _positions;
  15578. private _normals;
  15579. private _tangents;
  15580. private _influence;
  15581. onInfluenceChanged: Observable<boolean>;
  15582. influence: number;
  15583. constructor(name: string, influence?: number);
  15584. readonly hasPositions: boolean;
  15585. readonly hasNormals: boolean;
  15586. readonly hasTangents: boolean;
  15587. setPositions(data: Nullable<FloatArray>): void;
  15588. getPositions(): Nullable<FloatArray>;
  15589. setNormals(data: Nullable<FloatArray>): void;
  15590. getNormals(): Nullable<FloatArray>;
  15591. setTangents(data: Nullable<FloatArray>): void;
  15592. getTangents(): Nullable<FloatArray>;
  15593. /**
  15594. * Serializes the current target into a Serialization object.
  15595. * Returns the serialized object.
  15596. */
  15597. serialize(): any;
  15598. static Parse(serializationObject: any): MorphTarget;
  15599. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  15600. }
  15601. }
  15602. declare module BABYLON {
  15603. class MorphTargetManager {
  15604. private _targets;
  15605. private _targetObservable;
  15606. private _activeTargets;
  15607. private _scene;
  15608. private _influences;
  15609. private _supportsNormals;
  15610. private _supportsTangents;
  15611. private _vertexCount;
  15612. private _uniqueId;
  15613. private _tempInfluences;
  15614. constructor(scene?: Nullable<Scene>);
  15615. readonly uniqueId: number;
  15616. readonly vertexCount: number;
  15617. readonly supportsNormals: boolean;
  15618. readonly supportsTangents: boolean;
  15619. readonly numTargets: number;
  15620. readonly numInfluencers: number;
  15621. readonly influences: Float32Array;
  15622. getActiveTarget(index: number): MorphTarget;
  15623. getTarget(index: number): MorphTarget;
  15624. addTarget(target: MorphTarget): void;
  15625. removeTarget(target: MorphTarget): void;
  15626. /**
  15627. * Serializes the current manager into a Serialization object.
  15628. * Returns the serialized object.
  15629. */
  15630. serialize(): any;
  15631. private _syncActiveTargets(needUpdate);
  15632. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  15633. }
  15634. }
  15635. declare module BABYLON {
  15636. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  15637. static OCCLUSION_TYPE_NONE: number;
  15638. static OCCLUSION_TYPE_OPTIMISTIC: number;
  15639. static OCCLUSION_TYPE_STRICT: number;
  15640. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  15641. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  15642. static readonly BILLBOARDMODE_NONE: number;
  15643. static readonly BILLBOARDMODE_X: number;
  15644. static readonly BILLBOARDMODE_Y: number;
  15645. static readonly BILLBOARDMODE_Z: number;
  15646. static readonly BILLBOARDMODE_ALL: number;
  15647. private _facetPositions;
  15648. private _facetNormals;
  15649. private _facetPartitioning;
  15650. private _facetNb;
  15651. private _partitioningSubdivisions;
  15652. private _partitioningBBoxRatio;
  15653. private _facetDataEnabled;
  15654. private _facetParameters;
  15655. private _bbSize;
  15656. private _subDiv;
  15657. private _facetDepthSort;
  15658. private _facetDepthSortEnabled;
  15659. private _depthSortedIndices;
  15660. private _depthSortedFacets;
  15661. private _facetDepthSortFunction;
  15662. private _facetDepthSortFrom;
  15663. private _facetDepthSortOrigin;
  15664. private _invertedMatrix;
  15665. /**
  15666. * Read-only : the number of facets in the mesh
  15667. */
  15668. readonly facetNb: number;
  15669. /**
  15670. * The number (integer) of subdivisions per axis in the partioning space
  15671. */
  15672. partitioningSubdivisions: number;
  15673. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  15674. /**
  15675. * Creates a box mesh.
  15676. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  15677. * The parameter `size` sets the size (float) of each box side (default 1).
  15678. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  15679. * 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).
  15680. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  15681. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15682. * 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).
  15683. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15684. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15685. */
  15686. static CreateBox(name: string, options: {
  15687. size?: number;
  15688. width?: number;
  15689. height?: number;
  15690. depth?: number;
  15691. faceUV?: Vector4[];
  15692. faceColors?: Color4[];
  15693. sideOrientation?: number;
  15694. frontUVs?: Vector4;
  15695. backUVs?: Vector4;
  15696. updatable?: boolean;
  15697. }, scene?: Nullable<Scene>): Mesh;
  15698. /**
  15699. * Creates a sphere mesh.
  15700. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  15701. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  15702. * 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`).
  15703. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  15704. * 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
  15705. * 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).
  15706. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15707. * 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).
  15708. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15709. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15710. */
  15711. static CreateSphere(name: string, options: {
  15712. segments?: number;
  15713. diameter?: number;
  15714. diameterX?: number;
  15715. diameterY?: number;
  15716. diameterZ?: number;
  15717. arc?: number;
  15718. slice?: number;
  15719. sideOrientation?: number;
  15720. frontUVs?: Vector4;
  15721. backUVs?: Vector4;
  15722. updatable?: boolean;
  15723. }, scene: any): Mesh;
  15724. /**
  15725. * Creates a plane polygonal mesh. By default, this is a disc.
  15726. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  15727. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  15728. * 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.
  15729. * 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
  15730. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15731. * 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).
  15732. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15733. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15734. */
  15735. static CreateDisc(name: string, options: {
  15736. radius?: number;
  15737. tessellation?: number;
  15738. arc?: number;
  15739. updatable?: boolean;
  15740. sideOrientation?: number;
  15741. frontUVs?: Vector4;
  15742. backUVs?: Vector4;
  15743. }, scene?: Nullable<Scene>): Mesh;
  15744. /**
  15745. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  15746. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  15747. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  15748. * 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`).
  15749. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  15750. * 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.
  15751. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15752. * 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).
  15753. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15754. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15755. */
  15756. static CreateIcoSphere(name: string, options: {
  15757. radius?: number;
  15758. radiusX?: number;
  15759. radiusY?: number;
  15760. radiusZ?: number;
  15761. flat?: boolean;
  15762. subdivisions?: number;
  15763. sideOrientation?: number;
  15764. frontUVs?: Vector4;
  15765. backUVs?: Vector4;
  15766. updatable?: boolean;
  15767. }, scene: Scene): Mesh;
  15768. /**
  15769. * Creates a ribbon mesh.
  15770. * 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.
  15771. *
  15772. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  15773. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  15774. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  15775. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  15776. * 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.
  15777. * 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.
  15778. * 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
  15779. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15780. * 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).
  15781. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15782. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  15783. * 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.
  15784. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  15785. * 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
  15786. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  15787. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  15788. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15789. */
  15790. static CreateRibbon(name: string, options: {
  15791. pathArray: Vector3[][];
  15792. closeArray?: boolean;
  15793. closePath?: boolean;
  15794. offset?: number;
  15795. updatable?: boolean;
  15796. sideOrientation?: number;
  15797. frontUVs?: Vector4;
  15798. backUVs?: Vector4;
  15799. instance?: Mesh;
  15800. invertUV?: boolean;
  15801. uvs?: Vector2[];
  15802. colors?: Color4[];
  15803. }, scene?: Nullable<Scene>): Mesh;
  15804. /**
  15805. * Creates a cylinder or a cone mesh.
  15806. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  15807. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  15808. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  15809. * 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.
  15810. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  15811. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  15812. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  15813. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  15814. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  15815. * 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).
  15816. * 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
  15817. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  15818. * 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
  15819. * 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.
  15820. * If `enclose` is false, a ring surface is one element.
  15821. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  15822. * 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
  15823. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15824. * 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).
  15825. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15826. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15827. */
  15828. static CreateCylinder(name: string, options: {
  15829. height?: number;
  15830. diameterTop?: number;
  15831. diameterBottom?: number;
  15832. diameter?: number;
  15833. tessellation?: number;
  15834. subdivisions?: number;
  15835. arc?: number;
  15836. faceColors?: Color4[];
  15837. faceUV?: Vector4[];
  15838. updatable?: boolean;
  15839. hasRings?: boolean;
  15840. enclose?: boolean;
  15841. sideOrientation?: number;
  15842. frontUVs?: Vector4;
  15843. backUVs?: Vector4;
  15844. }, scene: any): Mesh;
  15845. /**
  15846. * Creates a torus mesh.
  15847. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  15848. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  15849. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  15850. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  15851. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15852. * 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).
  15853. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15854. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15855. */
  15856. static CreateTorus(name: string, options: {
  15857. diameter?: number;
  15858. thickness?: number;
  15859. tessellation?: number;
  15860. updatable?: boolean;
  15861. sideOrientation?: number;
  15862. frontUVs?: Vector4;
  15863. backUVs?: Vector4;
  15864. }, scene: any): Mesh;
  15865. /**
  15866. * Creates a torus knot mesh.
  15867. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  15868. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  15869. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  15870. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  15871. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  15872. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15873. * 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).
  15874. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15875. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15876. */
  15877. static CreateTorusKnot(name: string, options: {
  15878. radius?: number;
  15879. tube?: number;
  15880. radialSegments?: number;
  15881. tubularSegments?: number;
  15882. p?: number;
  15883. q?: number;
  15884. updatable?: boolean;
  15885. sideOrientation?: number;
  15886. frontUVs?: Vector4;
  15887. backUVs?: Vector4;
  15888. }, scene: any): Mesh;
  15889. /**
  15890. * Creates a line system mesh.
  15891. * A line system is a pool of many lines gathered in a single mesh.
  15892. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  15893. * 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.
  15894. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  15895. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  15896. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  15897. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  15898. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  15899. * 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
  15900. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  15901. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15902. */
  15903. static CreateLineSystem(name: string, options: {
  15904. lines: Vector3[][];
  15905. updatable: boolean;
  15906. instance: Nullable<LinesMesh>;
  15907. colors?: Nullable<Color4[][]>;
  15908. useVertexAlpha?: boolean;
  15909. }, scene: Nullable<Scene>): LinesMesh;
  15910. /**
  15911. * Creates a line mesh.
  15912. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  15913. * 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.
  15914. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15915. * The parameter `points` is an array successive Vector3.
  15916. * 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
  15917. * The optional parameter `colors` is an array of successive Color4, one per line point.
  15918. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  15919. * When updating an instance, remember that only point positions can change, not the number of points.
  15920. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15921. */
  15922. static CreateLines(name: string, options: {
  15923. points: Vector3[];
  15924. updatable: boolean;
  15925. instance: Nullable<LinesMesh>;
  15926. colors?: Color4[];
  15927. useVertexAlpha?: boolean;
  15928. }, scene?: Nullable<Scene>): LinesMesh;
  15929. /**
  15930. * Creates a dashed line mesh.
  15931. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  15932. * 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.
  15933. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15934. * The parameter `points` is an array successive Vector3.
  15935. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  15936. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  15937. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  15938. * 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
  15939. * When updating an instance, remember that only point positions can change, not the number of points.
  15940. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15941. */
  15942. static CreateDashedLines(name: string, options: {
  15943. points: Vector3[];
  15944. dashSize?: number;
  15945. gapSize?: number;
  15946. dashNb?: number;
  15947. updatable?: boolean;
  15948. instance?: LinesMesh;
  15949. }, scene?: Nullable<Scene>): LinesMesh;
  15950. /**
  15951. * Creates an extruded shape mesh.
  15952. * 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.
  15953. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  15954. *
  15955. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15956. * 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
  15957. * extruded along the Z axis.
  15958. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15959. * 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.
  15960. * The parameter `scale` (float, default 1) is the value to scale the shape.
  15961. * 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
  15962. * 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
  15963. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15964. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15965. * 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).
  15966. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15967. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  15968. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15969. */
  15970. static ExtrudeShape(name: string, options: {
  15971. shape: Vector3[];
  15972. path: Vector3[];
  15973. scale?: number;
  15974. rotation?: number;
  15975. cap?: number;
  15976. updatable?: boolean;
  15977. sideOrientation?: number;
  15978. frontUVs?: Vector4;
  15979. backUVs?: Vector4;
  15980. instance?: Mesh;
  15981. invertUV?: boolean;
  15982. }, scene?: Nullable<Scene>): Mesh;
  15983. /**
  15984. * Creates an custom extruded shape mesh.
  15985. * 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.
  15986. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  15987. *
  15988. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15989. * 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
  15990. * extruded along the Z axis.
  15991. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15992. * 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
  15993. * and the distance of this point from the begining of the path :
  15994. * ```javascript
  15995. * var rotationFunction = function(i, distance) {
  15996. * // do things
  15997. * return rotationValue; }
  15998. * ```
  15999. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  16000. * 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
  16001. * and the distance of this point from the begining of the path :
  16002. * ```javascript
  16003. * var scaleFunction = function(i, distance) {
  16004. * // do things
  16005. * return scaleValue;}
  16006. * ```
  16007. * It must returns a float value that will be the scale value applied to the shape on each path point.
  16008. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  16009. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  16010. * 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
  16011. * 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
  16012. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16013. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16014. * 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).
  16015. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16016. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16017. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16018. */
  16019. static ExtrudeShapeCustom(name: string, options: {
  16020. shape: Vector3[];
  16021. path: Vector3[];
  16022. scaleFunction?: any;
  16023. rotationFunction?: any;
  16024. ribbonCloseArray?: boolean;
  16025. ribbonClosePath?: boolean;
  16026. cap?: number;
  16027. updatable?: boolean;
  16028. sideOrientation?: number;
  16029. frontUVs?: Vector4;
  16030. backUVs?: Vector4;
  16031. instance?: Mesh;
  16032. invertUV?: boolean;
  16033. }, scene: Scene): Mesh;
  16034. /**
  16035. * Creates lathe mesh.
  16036. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  16037. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  16038. *
  16039. * 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
  16040. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  16041. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  16042. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  16043. * 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.
  16044. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  16045. * 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
  16046. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16047. * 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).
  16048. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16049. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16050. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16051. */
  16052. static CreateLathe(name: string, options: {
  16053. shape: Vector3[];
  16054. radius?: number;
  16055. tessellation?: number;
  16056. arc?: number;
  16057. closed?: boolean;
  16058. updatable?: boolean;
  16059. sideOrientation?: number;
  16060. frontUVs?: Vector4;
  16061. backUVs?: Vector4;
  16062. cap?: number;
  16063. invertUV?: boolean;
  16064. }, scene: Scene): Mesh;
  16065. /**
  16066. * Creates a plane mesh.
  16067. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16068. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  16069. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  16070. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  16071. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16072. * 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).
  16073. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16074. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16075. */
  16076. static CreatePlane(name: string, options: {
  16077. size?: number;
  16078. width?: number;
  16079. height?: number;
  16080. sideOrientation?: number;
  16081. frontUVs?: Vector4;
  16082. backUVs?: Vector4;
  16083. updatable?: boolean;
  16084. sourcePlane?: Plane;
  16085. }, scene: Scene): Mesh;
  16086. /**
  16087. * Creates a ground mesh.
  16088. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16089. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  16090. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  16091. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16092. */
  16093. static CreateGround(name: string, options: {
  16094. width?: number;
  16095. height?: number;
  16096. subdivisions?: number;
  16097. subdivisionsX?: number;
  16098. subdivisionsY?: number;
  16099. updatable?: boolean;
  16100. }, scene: any): Mesh;
  16101. /**
  16102. * Creates a tiled ground mesh.
  16103. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  16104. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  16105. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  16106. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  16107. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  16108. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  16109. * numbers of subdivisions on the ground width and height of each tile.
  16110. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16111. */
  16112. static CreateTiledGround(name: string, options: {
  16113. xmin: number;
  16114. zmin: number;
  16115. xmax: number;
  16116. zmax: number;
  16117. subdivisions?: {
  16118. w: number;
  16119. h: number;
  16120. };
  16121. precision?: {
  16122. w: number;
  16123. h: number;
  16124. };
  16125. updatable?: boolean;
  16126. }, scene: Scene): Mesh;
  16127. /**
  16128. * Creates a ground mesh from a height map.
  16129. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  16130. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  16131. * The parameter `url` sets the URL of the height map image resource.
  16132. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  16133. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  16134. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  16135. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  16136. * 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.
  16137. * 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).
  16138. * This function is passed the newly built mesh :
  16139. * ```javascript
  16140. * function(mesh) { // do things
  16141. * return; }
  16142. * ```
  16143. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16144. */
  16145. static CreateGroundFromHeightMap(name: string, url: string, options: {
  16146. width?: number;
  16147. height?: number;
  16148. subdivisions?: number;
  16149. minHeight?: number;
  16150. maxHeight?: number;
  16151. colorFilter?: Color3;
  16152. updatable?: boolean;
  16153. onReady?: (mesh: GroundMesh) => void;
  16154. }, scene: Scene): GroundMesh;
  16155. /**
  16156. * Creates a polygon mesh.
  16157. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  16158. * 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.
  16159. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16160. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16161. * 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).
  16162. * Remember you can only change the shape positions, not their number when updating a polygon.
  16163. */
  16164. static CreatePolygon(name: string, options: {
  16165. shape: Vector3[];
  16166. holes?: Vector3[][];
  16167. depth?: number;
  16168. faceUV?: Vector4[];
  16169. faceColors?: Color4[];
  16170. updatable?: boolean;
  16171. sideOrientation?: number;
  16172. frontUVs?: Vector4;
  16173. backUVs?: Vector4;
  16174. }, scene: Scene): Mesh;
  16175. /**
  16176. * Creates an extruded polygon mesh, with depth in the Y direction.
  16177. * 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).
  16178. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16179. */
  16180. static ExtrudePolygon(name: string, options: {
  16181. shape: Vector3[];
  16182. holes?: Vector3[][];
  16183. depth?: number;
  16184. faceUV?: Vector4[];
  16185. faceColors?: Color4[];
  16186. updatable?: boolean;
  16187. sideOrientation?: number;
  16188. frontUVs?: Vector4;
  16189. backUVs?: Vector4;
  16190. }, scene: Scene): Mesh;
  16191. /**
  16192. * Creates a tube mesh.
  16193. * 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.
  16194. *
  16195. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  16196. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  16197. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  16198. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  16199. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  16200. * 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.
  16201. * It must return a radius value (positive float) :
  16202. * ```javascript
  16203. * var radiusFunction = function(i, distance) {
  16204. * // do things
  16205. * return radius; }
  16206. * ```
  16207. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  16208. * 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
  16209. * 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
  16210. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16211. * 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).
  16212. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16213. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16214. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16215. */
  16216. static CreateTube(name: string, options: {
  16217. path: Vector3[];
  16218. radius?: number;
  16219. tessellation?: number;
  16220. radiusFunction?: {
  16221. (i: number, distance: number): number;
  16222. };
  16223. cap?: number;
  16224. arc?: number;
  16225. updatable?: boolean;
  16226. sideOrientation?: number;
  16227. frontUVs?: Vector4;
  16228. backUVs?: Vector4;
  16229. instance?: Mesh;
  16230. invertUV?: boolean;
  16231. }, scene: Scene): Mesh;
  16232. /**
  16233. * Creates a polyhedron mesh.
  16234. *
  16235. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  16236. * 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
  16237. * to choose the wanted type.
  16238. * The parameter `size` (positive float, default 1) sets the polygon size.
  16239. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  16240. * 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`.
  16241. * 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
  16242. * 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)`).
  16243. * 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
  16244. * 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.
  16245. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16246. * 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).
  16247. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16248. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16249. */
  16250. static CreatePolyhedron(name: string, options: {
  16251. type?: number;
  16252. size?: number;
  16253. sizeX?: number;
  16254. sizeY?: number;
  16255. sizeZ?: number;
  16256. custom?: any;
  16257. faceUV?: Vector4[];
  16258. faceColors?: Color4[];
  16259. flat?: boolean;
  16260. updatable?: boolean;
  16261. sideOrientation?: number;
  16262. frontUVs?: Vector4;
  16263. backUVs?: Vector4;
  16264. }, scene: Scene): Mesh;
  16265. /**
  16266. * Creates a decal mesh.
  16267. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  16268. * 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.
  16269. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  16270. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  16271. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  16272. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  16273. */
  16274. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  16275. position?: Vector3;
  16276. normal?: Vector3;
  16277. size?: Vector3;
  16278. angle?: number;
  16279. }): Mesh;
  16280. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  16281. }
  16282. }
  16283. declare module BABYLON {
  16284. class MeshLODLevel {
  16285. distance: number;
  16286. mesh: Mesh;
  16287. constructor(distance: number, mesh: Mesh);
  16288. }
  16289. }
  16290. declare module BABYLON {
  16291. /**
  16292. * A simplifier interface for future simplification implementations.
  16293. */
  16294. interface ISimplifier {
  16295. /**
  16296. * Simplification of a given mesh according to the given settings.
  16297. * Since this requires computation, it is assumed that the function runs async.
  16298. * @param settings The settings of the simplification, including quality and distance
  16299. * @param successCallback A callback that will be called after the mesh was simplified.
  16300. * @param errorCallback in case of an error, this callback will be called. optional.
  16301. */
  16302. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  16303. }
  16304. /**
  16305. * Expected simplification settings.
  16306. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  16307. */
  16308. interface ISimplificationSettings {
  16309. quality: number;
  16310. distance: number;
  16311. optimizeMesh?: boolean;
  16312. }
  16313. class SimplificationSettings implements ISimplificationSettings {
  16314. quality: number;
  16315. distance: number;
  16316. optimizeMesh: boolean | undefined;
  16317. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  16318. }
  16319. interface ISimplificationTask {
  16320. settings: Array<ISimplificationSettings>;
  16321. simplificationType: SimplificationType;
  16322. mesh: Mesh;
  16323. successCallback?: () => void;
  16324. parallelProcessing: boolean;
  16325. }
  16326. class SimplificationQueue {
  16327. private _simplificationArray;
  16328. running: boolean;
  16329. constructor();
  16330. addTask(task: ISimplificationTask): void;
  16331. executeNext(): void;
  16332. runSimplification(task: ISimplificationTask): void;
  16333. private getSimplifier(task);
  16334. }
  16335. /**
  16336. * The implemented types of simplification.
  16337. * At the moment only Quadratic Error Decimation is implemented.
  16338. */
  16339. enum SimplificationType {
  16340. QUADRATIC = 0,
  16341. }
  16342. class DecimationTriangle {
  16343. vertices: Array<DecimationVertex>;
  16344. normal: Vector3;
  16345. error: Array<number>;
  16346. deleted: boolean;
  16347. isDirty: boolean;
  16348. borderFactor: number;
  16349. deletePending: boolean;
  16350. originalOffset: number;
  16351. constructor(vertices: Array<DecimationVertex>);
  16352. }
  16353. class DecimationVertex {
  16354. position: Vector3;
  16355. id: number;
  16356. q: QuadraticMatrix;
  16357. isBorder: boolean;
  16358. triangleStart: number;
  16359. triangleCount: number;
  16360. originalOffsets: Array<number>;
  16361. constructor(position: Vector3, id: number);
  16362. updatePosition(newPosition: Vector3): void;
  16363. }
  16364. class QuadraticMatrix {
  16365. data: Array<number>;
  16366. constructor(data?: Array<number>);
  16367. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  16368. addInPlace(matrix: QuadraticMatrix): void;
  16369. addArrayInPlace(data: Array<number>): void;
  16370. add(matrix: QuadraticMatrix): QuadraticMatrix;
  16371. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  16372. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  16373. }
  16374. class Reference {
  16375. vertexId: number;
  16376. triangleId: number;
  16377. constructor(vertexId: number, triangleId: number);
  16378. }
  16379. /**
  16380. * An implementation of the Quadratic Error simplification algorithm.
  16381. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  16382. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  16383. * @author RaananW
  16384. */
  16385. class QuadraticErrorSimplification implements ISimplifier {
  16386. private _mesh;
  16387. private triangles;
  16388. private vertices;
  16389. private references;
  16390. private _reconstructedMesh;
  16391. syncIterations: number;
  16392. aggressiveness: number;
  16393. decimationIterations: number;
  16394. boundingBoxEpsilon: number;
  16395. constructor(_mesh: Mesh);
  16396. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  16397. private runDecimation(settings, submeshIndex, successCallback);
  16398. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  16399. private init(callback);
  16400. private reconstructMesh(submeshIndex);
  16401. private initDecimatedMesh();
  16402. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  16403. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  16404. private identifyBorder();
  16405. private updateMesh(identifyBorders?);
  16406. private vertexError(q, point);
  16407. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  16408. }
  16409. }
  16410. declare module BABYLON {
  16411. class Polygon {
  16412. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  16413. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  16414. static Parse(input: string): Vector2[];
  16415. static StartingAt(x: number, y: number): Path2;
  16416. }
  16417. class PolygonMeshBuilder {
  16418. private _points;
  16419. private _outlinepoints;
  16420. private _holes;
  16421. private _name;
  16422. private _scene;
  16423. private _epoints;
  16424. private _eholes;
  16425. private _addToepoint(points);
  16426. constructor(name: string, contours: Path2, scene: Scene);
  16427. constructor(name: string, contours: Vector2[], scene: Scene);
  16428. addHole(hole: Vector2[]): PolygonMeshBuilder;
  16429. build(updatable?: boolean, depth?: number): Mesh;
  16430. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  16431. }
  16432. }
  16433. declare module BABYLON {
  16434. class BaseSubMesh {
  16435. _materialDefines: Nullable<MaterialDefines>;
  16436. _materialEffect: Nullable<Effect>;
  16437. readonly effect: Nullable<Effect>;
  16438. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  16439. }
  16440. class SubMesh extends BaseSubMesh implements ICullable {
  16441. materialIndex: number;
  16442. verticesStart: number;
  16443. verticesCount: number;
  16444. indexStart: number;
  16445. indexCount: number;
  16446. linesIndexCount: number;
  16447. private _mesh;
  16448. private _renderingMesh;
  16449. private _boundingInfo;
  16450. private _linesIndexBuffer;
  16451. _lastColliderWorldVertices: Nullable<Vector3[]>;
  16452. _trianglePlanes: Plane[];
  16453. _lastColliderTransformMatrix: Matrix;
  16454. _renderId: number;
  16455. _alphaIndex: number;
  16456. _distanceToCamera: number;
  16457. _id: number;
  16458. private _currentMaterial;
  16459. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  16460. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  16461. readonly IsGlobal: boolean;
  16462. /**
  16463. * Returns the submesh BoudingInfo object.
  16464. */
  16465. getBoundingInfo(): BoundingInfo;
  16466. /**
  16467. * Sets the submesh BoundingInfo.
  16468. * Return the SubMesh.
  16469. */
  16470. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  16471. /**
  16472. * Returns the mesh of the current submesh.
  16473. */
  16474. getMesh(): AbstractMesh;
  16475. /**
  16476. * Returns the rendering mesh of the submesh.
  16477. */
  16478. getRenderingMesh(): Mesh;
  16479. /**
  16480. * Returns the submesh material.
  16481. */
  16482. getMaterial(): Nullable<Material>;
  16483. /**
  16484. * Sets a new updated BoundingInfo object to the submesh.
  16485. * Returns the SubMesh.
  16486. */
  16487. refreshBoundingInfo(): SubMesh;
  16488. _checkCollision(collider: Collider): boolean;
  16489. /**
  16490. * Updates the submesh BoundingInfo.
  16491. * Returns the Submesh.
  16492. */
  16493. updateBoundingInfo(world: Matrix): SubMesh;
  16494. /**
  16495. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  16496. * Boolean returned.
  16497. */
  16498. isInFrustum(frustumPlanes: Plane[]): boolean;
  16499. /**
  16500. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  16501. * Boolean returned.
  16502. */
  16503. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  16504. /**
  16505. * Renders the submesh.
  16506. * Returns it.
  16507. */
  16508. render(enableAlphaMode: boolean): SubMesh;
  16509. /**
  16510. * Returns a new Index Buffer.
  16511. * Type returned : WebGLBuffer.
  16512. */
  16513. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  16514. /**
  16515. * True is the passed Ray intersects the submesh bounding box.
  16516. * Boolean returned.
  16517. */
  16518. canIntersects(ray: Ray): boolean;
  16519. /**
  16520. * Returns an object IntersectionInfo.
  16521. */
  16522. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  16523. _rebuild(): void;
  16524. /**
  16525. * Creates a new Submesh from the passed Mesh.
  16526. */
  16527. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  16528. /**
  16529. * Disposes the Submesh.
  16530. * Returns nothing.
  16531. */
  16532. dispose(): void;
  16533. /**
  16534. * Creates a new Submesh from the passed parameters :
  16535. * - materialIndex (integer) : the index of the main mesh material.
  16536. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  16537. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  16538. * - mesh (Mesh) : the main mesh to create the submesh from.
  16539. * - renderingMesh (optional Mesh) : rendering mesh.
  16540. */
  16541. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  16542. }
  16543. }
  16544. declare module BABYLON {
  16545. class TransformNode extends Node {
  16546. static BILLBOARDMODE_NONE: number;
  16547. static BILLBOARDMODE_X: number;
  16548. static BILLBOARDMODE_Y: number;
  16549. static BILLBOARDMODE_Z: number;
  16550. static BILLBOARDMODE_ALL: number;
  16551. private _forward;
  16552. private _forwardInverted;
  16553. private _up;
  16554. private _right;
  16555. private _rightInverted;
  16556. private _rotation;
  16557. private _rotationQuaternion;
  16558. protected _scaling: Vector3;
  16559. protected _isDirty: boolean;
  16560. private _transformToBoneReferal;
  16561. billboardMode: number;
  16562. scalingDeterminant: number;
  16563. infiniteDistance: boolean;
  16564. position: Vector3;
  16565. _poseMatrix: Matrix;
  16566. private _localWorld;
  16567. _worldMatrix: Matrix;
  16568. _worldMatrixDeterminant: number;
  16569. private _absolutePosition;
  16570. private _pivotMatrix;
  16571. private _pivotMatrixInverse;
  16572. private _postMultiplyPivotMatrix;
  16573. protected _isWorldMatrixFrozen: boolean;
  16574. /**
  16575. * An event triggered after the world matrix is updated
  16576. * @type {BABYLON.Observable}
  16577. */
  16578. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  16579. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  16580. /**
  16581. * Gets a string idenfifying the name of the class
  16582. * @returns "TransformNode" string
  16583. */
  16584. getClassName(): string;
  16585. /**
  16586. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  16587. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  16588. * Default : (0.0, 0.0, 0.0)
  16589. */
  16590. rotation: Vector3;
  16591. /**
  16592. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  16593. * Default : (1.0, 1.0, 1.0)
  16594. */
  16595. /**
  16596. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  16597. * Default : (1.0, 1.0, 1.0)
  16598. */
  16599. scaling: Vector3;
  16600. /**
  16601. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  16602. * It's null by default.
  16603. * 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)
  16604. */
  16605. rotationQuaternion: Nullable<Quaternion>;
  16606. /**
  16607. * The forward direction of that transform in world space.
  16608. */
  16609. readonly forward: Vector3;
  16610. /**
  16611. * The up direction of that transform in world space.
  16612. */
  16613. readonly up: Vector3;
  16614. /**
  16615. * The right direction of that transform in world space.
  16616. */
  16617. readonly right: Vector3;
  16618. /**
  16619. * Returns the latest update of the World matrix
  16620. * Returns a Matrix.
  16621. */
  16622. getWorldMatrix(): Matrix;
  16623. /**
  16624. * Returns the latest update of the World matrix determinant.
  16625. */
  16626. protected _getWorldMatrixDeterminant(): number;
  16627. /**
  16628. * Returns directly the latest state of the mesh World matrix.
  16629. * A Matrix is returned.
  16630. */
  16631. readonly worldMatrixFromCache: Matrix;
  16632. /**
  16633. * Copies the paramater passed Matrix into the mesh Pose matrix.
  16634. * Returns the TransformNode.
  16635. */
  16636. updatePoseMatrix(matrix: Matrix): TransformNode;
  16637. /**
  16638. * Returns the mesh Pose matrix.
  16639. * Returned object : Matrix
  16640. */
  16641. getPoseMatrix(): Matrix;
  16642. _isSynchronized(): boolean;
  16643. _initCache(): void;
  16644. markAsDirty(property: string): TransformNode;
  16645. /**
  16646. * Returns the current mesh absolute position.
  16647. * Retuns a Vector3.
  16648. */
  16649. readonly absolutePosition: Vector3;
  16650. /**
  16651. * Sets a new matrix to apply before all other transformation
  16652. * @param matrix defines the transform matrix
  16653. * @returns the current TransformNode
  16654. */
  16655. setPreTransformMatrix(matrix: Matrix): TransformNode;
  16656. /**
  16657. * Sets a new pivot matrix to the current node
  16658. * @param matrix defines the new pivot matrix to use
  16659. * @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
  16660. * @returns the current TransformNode
  16661. */
  16662. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  16663. /**
  16664. * Returns the mesh pivot matrix.
  16665. * Default : Identity.
  16666. * A Matrix is returned.
  16667. */
  16668. getPivotMatrix(): Matrix;
  16669. /**
  16670. * Prevents the World matrix to be computed any longer.
  16671. * Returns the TransformNode.
  16672. */
  16673. freezeWorldMatrix(): TransformNode;
  16674. /**
  16675. * Allows back the World matrix computation.
  16676. * Returns the TransformNode.
  16677. */
  16678. unfreezeWorldMatrix(): this;
  16679. /**
  16680. * True if the World matrix has been frozen.
  16681. * Returns a boolean.
  16682. */
  16683. readonly isWorldMatrixFrozen: boolean;
  16684. /**
  16685. * Retuns the mesh absolute position in the World.
  16686. * Returns a Vector3.
  16687. */
  16688. getAbsolutePosition(): Vector3;
  16689. /**
  16690. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  16691. * Returns the TransformNode.
  16692. */
  16693. <<<<<<< HEAD
  16694. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  16695. /**
  16696. * Sets the mesh position in its local space.
  16697. * Returns the TransformNode.
  16698. */
  16699. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  16700. /**
  16701. * Returns the mesh position in the local space from the current World matrix values.
  16702. * Returns a new Vector3.
  16703. */
  16704. getPositionExpressedInLocalSpace(): Vector3;
  16705. /**
  16706. * Translates the mesh along the passed Vector3 in its local space.
  16707. * Returns the TransformNode.
  16708. */
  16709. locallyTranslate(vector3: Vector3): TransformNode;
  16710. private static _lookAtVectorCache;
  16711. /**
  16712. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  16713. * @param targetPoint the position (must be in same space as current mesh) to look at
  16714. * @param yawCor optional yaw (y-axis) correction in radians
  16715. * @param pitchCor optional pitch (x-axis) correction in radians
  16716. * @param rollCor optional roll (z-axis) correction in radians
  16717. * @param space the choosen space of the target
  16718. * @returns the TransformNode.
  16719. */
  16720. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  16721. /**
  16722. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  16723. * This Vector3 is expressed in the World space.
  16724. */
  16725. getDirection(localAxis: Vector3): Vector3;
  16726. /**
  16727. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  16728. * localAxis is expressed in the mesh local space.
  16729. * result is computed in the Wordl space from the mesh World matrix.
  16730. * Returns the TransformNode.
  16731. */
  16732. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  16733. /**
  16734. * Sets a new pivot point to the current node
  16735. * @param point defines the new pivot point to use
  16736. * @param space defines if the point is in world or local space (local by default)
  16737. * @returns the current TransformNode
  16738. */
  16739. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  16740. /**
  16741. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  16742. */
  16743. getPivotPoint(): Vector3;
  16744. /**
  16745. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  16746. * Returns the TransformNode.
  16747. */
  16748. getPivotPointToRef(result: Vector3): TransformNode;
  16749. /**
  16750. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  16751. */
  16752. getAbsolutePivotPoint(): Vector3;
  16753. /**
  16754. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  16755. * Returns the TransformNode.
  16756. */
  16757. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  16758. /**
  16759. * Defines the passed node as the parent of the current node.
  16760. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  16761. * Returns the TransformNode.
  16762. */
  16763. setParent(node: Nullable<Node>): TransformNode;
  16764. private _nonUniformScaling;
  16765. readonly nonUniformScaling: boolean;
  16766. _updateNonUniformScalingState(value: boolean): boolean;
  16767. /**
  16768. * Attach the current TransformNode to another TransformNode associated with a bone
  16769. * @param bone Bone affecting the TransformNode
  16770. * @param affectedTransformNode TransformNode associated with the bone
  16771. */
  16772. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  16773. detachFromBone(): TransformNode;
  16774. private static _rotationAxisCache;
  16775. /**
  16776. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  16777. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  16778. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  16779. * The passed axis is also normalized.
  16780. * Returns the TransformNode.
  16781. */
  16782. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  16783. /**
  16784. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  16785. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  16786. * The passed axis is also normalized.
  16787. * Returns the TransformNode.
  16788. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  16789. */
  16790. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  16791. /**
  16792. * Translates the mesh along the axis vector for the passed distance in the given space.
  16793. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  16794. * Returns the TransformNode.
  16795. */
  16796. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  16797. /**
  16798. * Adds a rotation step to the mesh current rotation.
  16799. * x, y, z are Euler angles expressed in radians.
  16800. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  16801. * This means this rotation is made in the mesh local space only.
  16802. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  16803. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  16804. * ```javascript
  16805. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  16806. * ```
  16807. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  16808. * 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.
  16809. * Returns the TransformNode.
  16810. */
  16811. addRotation(x: number, y: number, z: number): TransformNode;
  16812. /**
  16813. * Computes the mesh World matrix and returns it.
  16814. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  16815. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  16816. * If the parameter `force`is set to `true`, the actual computation is done.
  16817. * Returns the mesh World Matrix.
  16818. */
  16819. computeWorldMatrix(force?: boolean): Matrix;
  16820. protected _afterComputeWorldMatrix(): void;
  16821. /**
  16822. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  16823. * @param func: callback function to add
  16824. *
  16825. * Returns the TransformNode.
  16826. */
  16827. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  16828. /**
  16829. * Removes a registered callback function.
  16830. * Returns the TransformNode.
  16831. */
  16832. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  16833. /**
  16834. * Clone the current transform node
  16835. * Returns the new transform node
  16836. * @param name Name of the new clone
  16837. * @param newParent New parent for the clone
  16838. * @param doNotCloneChildren Do not clone children hierarchy
  16839. */
  16840. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  16841. serialize(currentSerializationObject?: any): any;
  16842. /**
  16843. * Returns a new TransformNode object parsed from the source provided.
  16844. * The parameter `parsedMesh` is the source.
  16845. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  16846. */
  16847. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  16848. /**
  16849. * Releases resources associated with this transform node.
  16850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16852. */
  16853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16854. }
  16855. }
  16856. declare module BABYLON {
  16857. class VertexBuffer {
  16858. private _buffer;
  16859. private _kind;
  16860. private _offset;
  16861. private _size;
  16862. private _stride;
  16863. private _ownsBuffer;
  16864. private _instanced;
  16865. private _instanceDivisor;
  16866. /**
  16867. * Gets or sets the instance divisor when in instanced mode
  16868. */
  16869. instanceDivisor: number;
  16870. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  16871. _rebuild(): void;
  16872. /**
  16873. * Returns the kind of the VertexBuffer (string).
  16874. */
  16875. getKind(): string;
  16876. /**
  16877. * Boolean : is the VertexBuffer updatable ?
  16878. */
  16879. isUpdatable(): boolean;
  16880. /**
  16881. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  16882. */
  16883. getData(): Nullable<FloatArray>;
  16884. /**
  16885. * Returns the WebGLBuffer associated to the VertexBuffer.
  16886. */
  16887. getBuffer(): Nullable<WebGLBuffer>;
  16888. /**
  16889. * Returns the stride of the VertexBuffer (integer).
  16890. */
  16891. getStrideSize(): number;
  16892. /**
  16893. * Returns the offset (integer).
  16894. */
  16895. getOffset(): number;
  16896. /**
  16897. * Returns the VertexBuffer total size (integer).
  16898. */
  16899. getSize(): number;
  16900. /**
  16901. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  16902. */
  16903. getIsInstanced(): boolean;
  16904. /**
  16905. * Returns the instancing divisor, zero for non-instanced (integer).
  16906. */
  16907. getInstanceDivisor(): number;
  16908. /**
  16909. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  16910. * Returns the created WebGLBuffer.
  16911. */
  16912. create(data?: FloatArray): void;
  16913. /**
  16914. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  16915. * This function will create a new buffer if the current one is not updatable
  16916. * Returns the updated WebGLBuffer.
  16917. */
  16918. update(data: FloatArray): void;
  16919. /**
  16920. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  16921. * Returns the directly updated WebGLBuffer.
  16922. */
  16923. updateDirectly(data: Float32Array, offset: number): void;
  16924. /**
  16925. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  16926. */
  16927. dispose(): void;
  16928. private static _PositionKind;
  16929. private static _NormalKind;
  16930. private static _TangentKind;
  16931. private static _UVKind;
  16932. private static _UV2Kind;
  16933. private static _UV3Kind;
  16934. private static _UV4Kind;
  16935. private static _UV5Kind;
  16936. private static _UV6Kind;
  16937. private static _ColorKind;
  16938. private static _MatricesIndicesKind;
  16939. private static _MatricesWeightsKind;
  16940. private static _MatricesIndicesExtraKind;
  16941. private static _MatricesWeightsExtraKind;
  16942. static readonly PositionKind: string;
  16943. static readonly NormalKind: string;
  16944. static readonly TangentKind: string;
  16945. static readonly UVKind: string;
  16946. static readonly UV2Kind: string;
  16947. static readonly UV3Kind: string;
  16948. static readonly UV4Kind: string;
  16949. static readonly UV5Kind: string;
  16950. static readonly UV6Kind: string;
  16951. static readonly ColorKind: string;
  16952. static readonly MatricesIndicesKind: string;
  16953. static readonly MatricesWeightsKind: string;
  16954. static readonly MatricesIndicesExtraKind: string;
  16955. static readonly MatricesWeightsExtraKind: string;
  16956. /**
  16957. * Deduces the stride given a kind.
  16958. * @param kind The kind string to deduce
  16959. * @returns The deduced stride
  16960. */
  16961. static DeduceStride(kind: string): number;
  16962. }
  16963. }
  16964. declare module BABYLON {
  16965. /**
  16966. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16967. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16968. * 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;
  16969. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16970. */
  16971. class ColorCurves {
  16972. private _dirty;
  16973. private _tempColor;
  16974. private _globalCurve;
  16975. private _highlightsCurve;
  16976. private _midtonesCurve;
  16977. private _shadowsCurve;
  16978. private _positiveCurve;
  16979. private _negativeCurve;
  16980. private _globalHue;
  16981. private _globalDensity;
  16982. private _globalSaturation;
  16983. private _globalExposure;
  16984. /**
  16985. * Gets the global Hue value.
  16986. * 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).
  16987. */
  16988. /**
  16989. * Sets the global Hue value.
  16990. * 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).
  16991. */
  16992. globalHue: number;
  16993. /**
  16994. * Gets the global Density value.
  16995. * 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.
  16996. * Values less than zero provide a filter of opposite hue.
  16997. */
  16998. /**
  16999. * Sets the global Density value.
  17000. * 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.
  17001. * Values less than zero provide a filter of opposite hue.
  17002. */
  17003. globalDensity: number;
  17004. /**
  17005. * Gets the global Saturation value.
  17006. * 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.
  17007. */
  17008. /**
  17009. * Sets the global Saturation value.
  17010. * 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.
  17011. */
  17012. globalSaturation: number;
  17013. private _highlightsHue;
  17014. private _highlightsDensity;
  17015. private _highlightsSaturation;
  17016. private _highlightsExposure;
  17017. /**
  17018. * Gets the highlights Hue value.
  17019. * 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).
  17020. */
  17021. /**
  17022. * Sets the highlights Hue value.
  17023. * 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).
  17024. */
  17025. highlightsHue: number;
  17026. /**
  17027. * Gets the highlights Density value.
  17028. * 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.
  17029. * Values less than zero provide a filter of opposite hue.
  17030. */
  17031. /**
  17032. * Sets the highlights Density value.
  17033. * 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.
  17034. * Values less than zero provide a filter of opposite hue.
  17035. */
  17036. highlightsDensity: number;
  17037. /**
  17038. * Gets the highlights Saturation value.
  17039. * 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.
  17040. */
  17041. /**
  17042. * Sets the highlights Saturation value.
  17043. * 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.
  17044. */
  17045. highlightsSaturation: number;
  17046. /**
  17047. * Gets the highlights Exposure value.
  17048. * 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.
  17049. */
  17050. /**
  17051. * Sets the highlights Exposure value.
  17052. * 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.
  17053. */
  17054. highlightsExposure: number;
  17055. private _midtonesHue;
  17056. private _midtonesDensity;
  17057. private _midtonesSaturation;
  17058. private _midtonesExposure;
  17059. /**
  17060. * Gets the midtones Hue value.
  17061. * 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).
  17062. */
  17063. /**
  17064. * Sets the midtones Hue value.
  17065. * 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).
  17066. */
  17067. midtonesHue: number;
  17068. /**
  17069. * Gets the midtones Density value.
  17070. * 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.
  17071. * Values less than zero provide a filter of opposite hue.
  17072. */
  17073. /**
  17074. * Sets the midtones Density value.
  17075. * 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.
  17076. * Values less than zero provide a filter of opposite hue.
  17077. */
  17078. midtonesDensity: number;
  17079. /**
  17080. * Gets the midtones Saturation value.
  17081. * 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.
  17082. */
  17083. /**
  17084. * Sets the midtones Saturation value.
  17085. * 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.
  17086. */
  17087. midtonesSaturation: number;
  17088. /**
  17089. * Gets the midtones Exposure value.
  17090. * 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.
  17091. */
  17092. /**
  17093. * Sets the midtones Exposure value.
  17094. * 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.
  17095. */
  17096. midtonesExposure: number;
  17097. private _shadowsHue;
  17098. private _shadowsDensity;
  17099. private _shadowsSaturation;
  17100. private _shadowsExposure;
  17101. /**
  17102. * Gets the shadows Hue value.
  17103. * 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).
  17104. */
  17105. /**
  17106. * Sets the shadows Hue value.
  17107. * 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).
  17108. */
  17109. shadowsHue: number;
  17110. /**
  17111. * Gets the shadows Density value.
  17112. * 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.
  17113. * Values less than zero provide a filter of opposite hue.
  17114. */
  17115. /**
  17116. * Sets the shadows Density value.
  17117. * 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.
  17118. * Values less than zero provide a filter of opposite hue.
  17119. */
  17120. shadowsDensity: number;
  17121. /**
  17122. * Gets the shadows Saturation value.
  17123. * 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.
  17124. */
  17125. /**
  17126. * Sets the shadows Saturation value.
  17127. * 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.
  17128. */
  17129. shadowsSaturation: number;
  17130. /**
  17131. * Gets the shadows Exposure value.
  17132. * 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.
  17133. */
  17134. /**
  17135. * Sets the shadows Exposure value.
  17136. * 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.
  17137. */
  17138. shadowsExposure: number;
  17139. getClassName(): string;
  17140. /**
  17141. * Binds the color curves to the shader.
  17142. * @param colorCurves The color curve to bind
  17143. * @param effect The effect to bind to
  17144. */
  17145. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17146. /**
  17147. * Prepare the list of uniforms associated with the ColorCurves effects.
  17148. * @param uniformsList The list of uniforms used in the effect
  17149. */
  17150. static PrepareUniforms(uniformsList: string[]): void;
  17151. /**
  17152. * Returns color grading data based on a hue, density, saturation and exposure value.
  17153. * @param filterHue The hue of the color filter.
  17154. * @param filterDensity The density of the color filter.
  17155. * @param saturation The saturation.
  17156. * @param exposure The exposure.
  17157. * @param result The result data container.
  17158. */
  17159. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  17160. /**
  17161. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17162. * @param value The input slider value in range [-100,100].
  17163. * @returns Adjusted value.
  17164. */
  17165. private static applyColorGradingSliderNonlinear(value);
  17166. /**
  17167. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17168. * @param hue The hue (H) input.
  17169. * @param saturation The saturation (S) input.
  17170. * @param brightness The brightness (B) input.
  17171. * @result An RGBA color represented as Vector4.
  17172. */
  17173. private static fromHSBToRef(hue, saturation, brightness, result);
  17174. /**
  17175. * Returns a value clamped between min and max
  17176. * @param value The value to clamp
  17177. * @param min The minimum of value
  17178. * @param max The maximum of value
  17179. * @returns The clamped value.
  17180. */
  17181. private static clamp(value, min, max);
  17182. /**
  17183. * Clones the current color curve instance.
  17184. * @return The cloned curves
  17185. */
  17186. clone(): ColorCurves;
  17187. /**
  17188. * Serializes the current color curve instance to a json representation.
  17189. * @return a JSON representation
  17190. */
  17191. serialize(): any;
  17192. /**
  17193. * Parses the color curve from a json representation.
  17194. * @param source the JSON source to parse
  17195. * @return The parsed curves
  17196. */
  17197. static Parse(source: any): ColorCurves;
  17198. }
  17199. }
  17200. declare module BABYLON {
  17201. /**
  17202. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17203. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17204. */
  17205. class EffectFallbacks {
  17206. private _defines;
  17207. private _currentRank;
  17208. private _maxRank;
  17209. private _mesh;
  17210. /**
  17211. * Removes the fallback from the bound mesh.
  17212. */
  17213. unBindMesh(): void;
  17214. /**
  17215. * Adds a fallback on the specified property.
  17216. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17217. * @param define The name of the define in the shader
  17218. */
  17219. addFallback(rank: number, define: string): void;
  17220. /**
  17221. * Sets the mesh to use CPU skinning when needing to fallback.
  17222. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17223. * @param mesh The mesh to use the fallbacks.
  17224. */
  17225. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17226. /**
  17227. * Checks to see if more fallbacks are still availible.
  17228. */
  17229. readonly isMoreFallbacks: boolean;
  17230. /**
  17231. * Removes the defines that shoould be removed when falling back.
  17232. * @param currentDefines defines the current define statements for the shader.
  17233. * @param effect defines the current effect we try to compile
  17234. * @returns The resulting defines with defines of the current rank removed.
  17235. */
  17236. reduce(currentDefines: string, effect: Effect): string;
  17237. }
  17238. /**
  17239. * Options to be used when creating an effect.
  17240. */
  17241. class EffectCreationOptions {
  17242. /**
  17243. * Atrributes that will be used in the shader.
  17244. */
  17245. attributes: string[];
  17246. /**
  17247. * Uniform varible names that will be set in the shader.
  17248. */
  17249. uniformsNames: string[];
  17250. /**
  17251. * Uniform buffer varible names that will be set in the shader.
  17252. */
  17253. uniformBuffersNames: string[];
  17254. /**
  17255. * Sampler texture variable names that will be set in the shader.
  17256. */
  17257. samplers: string[];
  17258. /**
  17259. * Define statements that will be set in the shader.
  17260. */
  17261. defines: any;
  17262. /**
  17263. * Possible fallbacks for this effect to improve performance when needed.
  17264. */
  17265. fallbacks: Nullable<EffectFallbacks>;
  17266. /**
  17267. * Callback that will be called when the shader is compiled.
  17268. */
  17269. onCompiled: Nullable<(effect: Effect) => void>;
  17270. /**
  17271. * Callback that will be called if an error occurs during shader compilation.
  17272. */
  17273. onError: Nullable<(effect: Effect, errors: string) => void>;
  17274. /**
  17275. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17276. */
  17277. indexParameters: any;
  17278. /**
  17279. * Max number of lights that can be used in the shader.
  17280. */
  17281. maxSimultaneousLights: number;
  17282. /**
  17283. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17284. */
  17285. transformFeedbackVaryings: Nullable<string[]>;
  17286. }
  17287. /**
  17288. * Effect containing vertex and fragment shader that can be executed on an object.
  17289. */
  17290. class Effect {
  17291. /**
  17292. * Name of the effect.
  17293. */
  17294. name: any;
  17295. /**
  17296. * String container all the define statements that should be set on the shader.
  17297. */
  17298. defines: string;
  17299. /**
  17300. * Callback that will be called when the shader is compiled.
  17301. */
  17302. onCompiled: Nullable<(effect: Effect) => void>;
  17303. /**
  17304. * Callback that will be called if an error occurs during shader compilation.
  17305. */
  17306. onError: Nullable<(effect: Effect, errors: string) => void>;
  17307. /**
  17308. * Callback that will be called when effect is bound.
  17309. */
  17310. onBind: Nullable<(effect: Effect) => void>;
  17311. /**
  17312. * Unique ID of the effect.
  17313. */
  17314. uniqueId: number;
  17315. /**
  17316. * Observable that will be called when the shader is compiled.
  17317. */
  17318. onCompileObservable: Observable<Effect>;
  17319. /**
  17320. * Observable that will be called if an error occurs during shader compilation.
  17321. */
  17322. onErrorObservable: Observable<Effect>;
  17323. /**
  17324. * Observable that will be called when effect is bound.
  17325. */
  17326. onBindObservable: Observable<Effect>;
  17327. private static _uniqueIdSeed;
  17328. private _engine;
  17329. private _uniformBuffersNames;
  17330. private _uniformsNames;
  17331. private _samplers;
  17332. private _isReady;
  17333. private _compilationError;
  17334. private _attributesNames;
  17335. private _attributes;
  17336. private _uniforms;
  17337. /**
  17338. * Key for the effect.
  17339. */
  17340. _key: string;
  17341. private _indexParameters;
  17342. private _fallbacks;
  17343. private _vertexSourceCode;
  17344. private _fragmentSourceCode;
  17345. private _vertexSourceCodeOverride;
  17346. private _fragmentSourceCodeOverride;
  17347. private _transformFeedbackVaryings;
  17348. /**
  17349. * Compiled shader to webGL program.
  17350. */
  17351. _program: WebGLProgram;
  17352. private _valueCache;
  17353. private static _baseCache;
  17354. /**
  17355. * Instantiates an effect.
  17356. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17357. * @param baseName Name of the effect.
  17358. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17359. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17360. * @param samplers List of sampler variables that will be passed to the shader.
  17361. * @param engine Engine to be used to render the effect
  17362. * @param defines Define statements to be added to the shader.
  17363. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17364. * @param onCompiled Callback that will be called when the shader is compiled.
  17365. * @param onError Callback that will be called if an error occurs during shader compilation.
  17366. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17367. */
  17368. 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);
  17369. /**
  17370. * Unique key for this effect
  17371. */
  17372. readonly key: string;
  17373. /**
  17374. * If the effect has been compiled and prepared.
  17375. * @returns if the effect is compiled and prepared.
  17376. =======
  17377. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  17378. isUpdatable(): boolean;
  17379. getData(): Nullable<FloatArray>;
  17380. getBuffer(): Nullable<WebGLBuffer>;
  17381. getStrideSize(): number;
  17382. create(data?: Nullable<FloatArray>): void;
  17383. _rebuild(): void;
  17384. update(data: FloatArray): void;
  17385. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  17386. dispose(): void;
  17387. }
  17388. }
  17389. declare module BABYLON {
  17390. class CSG {
  17391. private polygons;
  17392. matrix: Matrix;
  17393. position: Vector3;
  17394. rotation: Vector3;
  17395. rotationQuaternion: Nullable<Quaternion>;
  17396. scaling: Vector3;
  17397. static FromMesh(mesh: Mesh): CSG;
  17398. private static FromPolygons(polygons);
  17399. clone(): CSG;
  17400. union(csg: CSG): CSG;
  17401. unionInPlace(csg: CSG): void;
  17402. subtract(csg: CSG): CSG;
  17403. subtractInPlace(csg: CSG): void;
  17404. intersect(csg: CSG): CSG;
  17405. intersectInPlace(csg: CSG): void;
  17406. inverse(): CSG;
  17407. inverseInPlace(): void;
  17408. copyTransformAttributes(csg: CSG): CSG;
  17409. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  17410. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  17411. }
  17412. }
  17413. declare module BABYLON {
  17414. /**
  17415. * Class used to store geometry data (vertex buffers + index buffer)
  17416. */
  17417. class Geometry implements IGetSetVerticesData {
  17418. /**
  17419. * Gets or sets the unique ID of the geometry
  17420. */
  17421. id: string;
  17422. /**
  17423. * Gets the delay loading state of the geometry (none by default which means not delayed)
  17424. */
  17425. delayLoadState: number;
  17426. /**
  17427. * Gets the file containing the data to load when running in delay load state
  17428. */
  17429. delayLoadingFile: Nullable<string>;
  17430. /**
  17431. * Callback called when the geometry is updated
  17432. */
  17433. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  17434. private _scene;
  17435. private _engine;
  17436. private _meshes;
  17437. private _totalVertices;
  17438. private _indices;
  17439. private _vertexBuffers;
  17440. private _isDisposed;
  17441. private _extend;
  17442. private _boundingBias;
  17443. /** @ignore */
  17444. _delayInfo: Array<string>;
  17445. private _indexBuffer;
  17446. private _indexBufferIsUpdatable;
  17447. /** @ignore */
  17448. _boundingInfo: Nullable<BoundingInfo>;
  17449. /** @ignore */
  17450. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  17451. /** @ignore */
  17452. _softwareSkinningRenderId: number;
  17453. private _vertexArrayObjects;
  17454. private _updatable;
  17455. /** @ignore */
  17456. _positions: Nullable<Vector3[]>;
  17457. /**
  17458. * 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
  17459. */
  17460. /**
  17461. * 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
  17462. */
  17463. boundingBias: Vector2;
  17464. /**
  17465. * Static function used to attach a new empty geometry to a mesh
  17466. * @param mesh defines the mesh to attach the geometry to
  17467. * @returns the new {BABYLON.Geometry}
  17468. */
  17469. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  17470. /**
  17471. * Creates a new geometry
  17472. * @param id defines the unique ID
  17473. * @param scene defines the hosting scene
  17474. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  17475. * @param updatable defines if geometry must be updatable (false by default)
  17476. * @param mesh defines the mesh that will be associated with the geometry
  17477. */
  17478. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  17479. /**
  17480. * Gets the current extend of the geometry
  17481. */
  17482. readonly extend: {
  17483. minimum: Vector3;
  17484. maximum: Vector3;
  17485. };
  17486. /**
  17487. * Gets the hosting scene
  17488. * @returns the hosting {BABYLON.Scene}
  17489. */
  17490. getScene(): Scene;
  17491. /**
  17492. * Gets the hosting engine
  17493. * @returns the hosting {BABYLON.Engine}
  17494. */
  17495. getEngine(): Engine;
  17496. /**
  17497. * Defines if the geometry is ready to use
  17498. * @returns true if the geometry is ready to be used
  17499. */
  17500. isReady(): boolean;
  17501. /**
  17502. * Gets a value indicating that the geometry should not be serialized
  17503. */
  17504. readonly doNotSerialize: boolean;
  17505. /** @ignore */
  17506. _rebuild(): void;
  17507. /**
  17508. * Affects all gemetry data in one call
  17509. * @param vertexData defines the geometry data
  17510. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  17511. */
  17512. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  17513. /**
  17514. * Set specific vertex data
  17515. * @param kind defines the data kind (Position, normal, etc...)
  17516. * @param data defines the vertex data to use
  17517. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  17518. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  17519. */
  17520. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  17521. /**
  17522. * Removes a specific vertex data
  17523. * @param kind defines the data kind (Position, normal, etc...)
  17524. */
  17525. removeVerticesData(kind: string): void;
  17526. /**
  17527. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  17528. * @param buffer defines the vertex buffer to use
  17529. */
  17530. setVerticesBuffer(buffer: VertexBuffer): void;
  17531. /**
  17532. * Update a specific vertex buffer
  17533. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  17534. * It will do nothing if the buffer is not updatable
  17535. * @param kind defines the data kind (Position, normal, etc...)
  17536. * @param data defines the data to use
  17537. * @param offset defines the offset in the target buffer where to store the data
  17538. */
  17539. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  17540. /**
  17541. * Update a specific vertex buffer
  17542. * This function will create a new buffer if the current one is not updatable
  17543. * @param kind defines the data kind (Position, normal, etc...)
  17544. * @param data defines the data to use
  17545. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  17546. */
  17547. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  17548. private updateBoundingInfo(updateExtends, data);
  17549. /** @ignore */
  17550. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  17551. /**
  17552. * Gets total number of vertices
  17553. * @returns the total number of vertices
  17554. */
  17555. getTotalVertices(): number;
  17556. /**
  17557. * Gets a specific vertex data attached to this geometry
  17558. * @param kind defines the data kind (Position, normal, etc...)
  17559. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  17560. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  17561. * @returns a float array containing vertex data
  17562. */
  17563. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17564. /**
  17565. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  17566. * @param kind defines the data kind (Position, normal, etc...)
  17567. * @returns true if the vertex buffer with the specified kind is updatable
  17568. */
  17569. isVertexBufferUpdatable(kind: string): boolean;
  17570. /**
  17571. * Gets a specific vertex buffer
  17572. * @param kind defines the data kind (Position, normal, etc...)
  17573. * @returns a {BABYLON.VertexBuffer}
  17574. */
  17575. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  17576. /**
  17577. * Returns all vertex buffers
  17578. * @return an object holding all vertex buffers indexed by kind
  17579. */
  17580. getVertexBuffers(): Nullable<{
  17581. [key: string]: VertexBuffer;
  17582. }>;
  17583. /**
  17584. * Gets a boolean indicating if specific vertex buffer is present
  17585. * @param kind defines the data kind (Position, normal, etc...)
  17586. * @returns true if data is present
  17587. */
  17588. isVerticesDataPresent(kind: string): boolean;
  17589. /**
  17590. * Gets a list of all attached data kinds (Position, normal, etc...)
  17591. * @returns a list of string containing all kinds
  17592. */
  17593. getVerticesDataKinds(): string[];
  17594. /**
  17595. * Update index buffer
  17596. * @param indices defines the indices to store in the index buffer
  17597. * @param offset defines the offset in the target buffer where to store the data
  17598. */
  17599. updateIndices(indices: IndicesArray, offset?: number): void;
  17600. /**
  17601. * Creates a new index buffer
  17602. * @param indices defines the indices to store in the index buffer
  17603. * @param totalVertices defines the total number of vertices (could be null)
  17604. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  17605. */
  17606. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  17607. /**
  17608. * Return the total number of indices
  17609. * @returns the total number of indices
  17610. */
  17611. getTotalIndices(): number;
  17612. /**
  17613. * Gets the index buffer array
  17614. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  17615. * @returns the index buffer array
  17616. */
  17617. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17618. /**
  17619. * Gets the index buffer
  17620. * @return the index buffer
  17621. */
  17622. getIndexBuffer(): Nullable<WebGLBuffer>;
  17623. /** @ignore */
  17624. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  17625. /**
  17626. * Release the associated resources for a specific mesh
  17627. * @param mesh defines the source mesh
  17628. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  17629. */
  17630. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  17631. /**
  17632. * Apply current geometry to a given mesh
  17633. * @param mesh defines the mesh to apply geometry to
  17634. */
  17635. applyToMesh(mesh: Mesh): void;
  17636. private updateExtend(data?, stride?);
  17637. private _applyToMesh(mesh);
  17638. private notifyUpdate(kind?);
  17639. /**
  17640. * Load the geometry if it was flagged as delay loaded
  17641. * @param scene defines the hosting scene
  17642. * @param onLoaded defines a callback called when the geometry is loaded
  17643. */
  17644. load(scene: Scene, onLoaded?: () => void): void;
  17645. private _queueLoad(scene, onLoaded?);
  17646. /**
  17647. * Invert the geometry to move from a right handed system to a left handed one.
  17648. */
  17649. toLeftHanded(): void;
  17650. /** @ignore */
  17651. _resetPointsArrayCache(): void;
  17652. /** @ignore */
  17653. _generatePointsArray(): boolean;
  17654. /**
  17655. * Gets a value indicating if the geometry is disposed
  17656. * @returns true if the geometry was disposed
  17657. */
  17658. isDisposed(): boolean;
  17659. private _disposeVertexArrayObjects();
  17660. /**
  17661. * Free all associated resources
  17662. */
  17663. dispose(): void;
  17664. /**
  17665. * Clone the current geometry into a new geometry
  17666. * @param id defines the unique ID of the new geometry
  17667. * @returns a new geometry object
  17668. */
  17669. copy(id: string): Geometry;
  17670. /**
  17671. * Serialize the current geometry info (and not the vertices data) into a JSON object
  17672. * @return a JSON representation of the current geometry data (without the vertices data)
  17673. */
  17674. serialize(): any;
  17675. private toNumberArray(origin);
  17676. /**
  17677. * Serialize all vertices data into a JSON oject
  17678. * @returns a JSON representation of the current geometry data
  17679. */
  17680. serializeVerticeData(): any;
  17681. /**
  17682. * Extracts a clone of a mesh geometry
  17683. * @param mesh defines the source mesh
  17684. * @param id defines the unique ID of the new geometry object
  17685. * @returns the new geometry object
  17686. */
  17687. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  17688. /**
  17689. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  17690. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  17691. * Be aware Math.random() could cause collisions, but:
  17692. * "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"
  17693. * @returns a string containing a new GUID
  17694. */
  17695. static RandomId(): string;
  17696. /** @ignore */
  17697. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  17698. private static _CleanMatricesWeights(parsedGeometry, mesh);
  17699. /**
  17700. * Create a new geometry from persisted data (Using .babylon file format)
  17701. * @param parsedVertexData defines the persisted data
  17702. * @param scene defines the hosting scene
  17703. * @param rootUrl defines the root url to use to load assets (like delayed data)
  17704. * @returns the new geometry object
  17705. */
  17706. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  17707. }
  17708. /**
  17709. * Abstract class used to provide common services for all typed geometries
  17710. */
  17711. class _PrimitiveGeometry extends Geometry {
  17712. private _canBeRegenerated;
  17713. private _beingRegenerated;
  17714. /**
  17715. * Creates a new typed geometry
  17716. * @param id defines the unique ID of the geometry
  17717. * @param scene defines the hosting scene
  17718. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17719. * @param mesh defines the hosting mesh (can be null)
  17720. */
  17721. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  17722. /**
  17723. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  17724. * @returns true if the geometry can be regenerated
  17725. */
  17726. canBeRegenerated(): boolean;
  17727. /**
  17728. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  17729. */
  17730. regenerate(): void;
  17731. /**
  17732. * Clone the geometry
  17733. * @param id defines the unique ID of the new geometry
  17734. * @returns the new geometry
  17735. */
  17736. asNewGeometry(id: string): Geometry;
  17737. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  17738. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  17739. /** @ignore */
  17740. _regenerateVertexData(): VertexData;
  17741. copy(id: string): Geometry;
  17742. serialize(): any;
  17743. }
  17744. /**
  17745. * Creates a ribbon geometry
  17746. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  17747. */
  17748. class RibbonGeometry extends _PrimitiveGeometry {
  17749. /**
  17750. * Defines the array of paths to use
  17751. */
  17752. pathArray: Vector3[][];
  17753. /**
  17754. * Defines if the last and first points of each path in your pathArray must be joined
  17755. */
  17756. closeArray: boolean;
  17757. /**
  17758. * Defines if the last and first points of each path in your pathArray must be joined
  17759. */
  17760. closePath: boolean;
  17761. /**
  17762. * Defines the offset between points
  17763. */
  17764. offset: number;
  17765. /**
  17766. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17767. */
  17768. side: number;
  17769. /**
  17770. * Creates a ribbon geometry
  17771. * @param id defines the unique ID of the geometry
  17772. * @param scene defines the hosting scene
  17773. * @param pathArray defines the array of paths to use
  17774. * @param closeArray defines if the last path and the first path must be joined
  17775. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  17776. * @param offset defines the offset between points
  17777. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17778. * @param mesh defines the hosting mesh (can be null)
  17779. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17780. */
  17781. constructor(id: string, scene: Scene,
  17782. /**
  17783. * Defines the array of paths to use
  17784. */
  17785. pathArray: Vector3[][],
  17786. /**
  17787. * Defines if the last and first points of each path in your pathArray must be joined
  17788. */
  17789. closeArray: boolean,
  17790. /**
  17791. * Defines if the last and first points of each path in your pathArray must be joined
  17792. */
  17793. closePath: boolean,
  17794. /**
  17795. * Defines the offset between points
  17796. */
  17797. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  17798. /**
  17799. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17800. */
  17801. side?: number);
  17802. /** @ignore */
  17803. _regenerateVertexData(): VertexData;
  17804. copy(id: string): Geometry;
  17805. }
  17806. /**
  17807. * Creates a box geometry
  17808. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  17809. */
  17810. class BoxGeometry extends _PrimitiveGeometry {
  17811. /**
  17812. * Defines the zise of the box (width, height and depth are the same)
  17813. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  17814. */
  17815. isReady(): boolean;
  17816. /**
  17817. * The engine the effect was initialized with.
  17818. * @returns the engine.
  17819. */
  17820. getEngine(): Engine;
  17821. /**
  17822. <<<<<<< HEAD
  17823. * The compiled webGL program for the effect
  17824. * @returns the webGL program.
  17825. */
  17826. getProgram(): WebGLProgram;
  17827. /**
  17828. * The set of names of attribute variables for the shader.
  17829. * @returns An array of attribute names.
  17830. */
  17831. getAttributesNames(): string[];
  17832. /**
  17833. * Returns the attribute at the given index.
  17834. * @param index The index of the attribute.
  17835. * @returns The location of the attribute.
  17836. */
  17837. getAttributeLocation(index: number): number;
  17838. /**
  17839. * Returns the attribute based on the name of the variable.
  17840. * @param name of the attribute to look up.
  17841. * @returns the attribute location.
  17842. */
  17843. getAttributeLocationByName(name: string): number;
  17844. /**
  17845. * The number of attributes.
  17846. * @returns the numnber of attributes.
  17847. */
  17848. getAttributesCount(): number;
  17849. /**
  17850. * Gets the index of a uniform variable.
  17851. * @param uniformName of the uniform to look up.
  17852. * @returns the index.
  17853. */
  17854. getUniformIndex(uniformName: string): number;
  17855. /**
  17856. * Returns the attribute based on the name of the variable.
  17857. * @param uniformName of the uniform to look up.
  17858. * @returns the location of the uniform.
  17859. */
  17860. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17861. =======
  17862. * Creates a box geometry
  17863. * @param id defines the unique ID of the geometry
  17864. * @param scene defines the hosting scene
  17865. * @param size defines the zise of the box (width, height and depth are the same)
  17866. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17867. * @param mesh defines the hosting mesh (can be null)
  17868. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17869. */
  17870. constructor(id: string, scene: Scene,
  17871. /**
  17872. * Defines the zise of the box (width, height and depth are the same)
  17873. */
  17874. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17875. /**
  17876. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17877. */
  17878. side?: number);
  17879. _regenerateVertexData(): VertexData;
  17880. copy(id: string): Geometry;
  17881. serialize(): any;
  17882. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  17883. }
  17884. /**
  17885. * Creates a sphere geometry
  17886. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  17887. */
  17888. class SphereGeometry extends _PrimitiveGeometry {
  17889. /**
  17890. * Defines the number of segments to use to create the sphere
  17891. */
  17892. segments: number;
  17893. /**
  17894. * Defines the diameter of the sphere
  17895. */
  17896. diameter: number;
  17897. /**
  17898. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17899. */
  17900. side: number;
  17901. /**
  17902. * Create a new sphere geometry
  17903. * @param id defines the unique ID of the geometry
  17904. * @param scene defines the hosting scene
  17905. * @param segments defines the number of segments to use to create the sphere
  17906. * @param diameter defines the diameter of the sphere
  17907. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17908. * @param mesh defines the hosting mesh (can be null)
  17909. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17910. */
  17911. constructor(id: string, scene: Scene,
  17912. /**
  17913. * Defines the number of segments to use to create the sphere
  17914. */
  17915. segments: number,
  17916. /**
  17917. * Defines the diameter of the sphere
  17918. */
  17919. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17920. /**
  17921. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17922. */
  17923. side?: number);
  17924. _regenerateVertexData(): VertexData;
  17925. copy(id: string): Geometry;
  17926. serialize(): any;
  17927. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  17928. }
  17929. /**
  17930. * Creates a disc geometry
  17931. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  17932. */
  17933. class DiscGeometry extends _PrimitiveGeometry {
  17934. /**
  17935. * Defines the radius of the disc
  17936. */
  17937. radius: number;
  17938. /**
  17939. * Defines the tesselation factor to apply to the disc
  17940. */
  17941. tessellation: number;
  17942. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  17943. /**
  17944. * Returns an array of sampler variable names
  17945. * @returns The array of sampler variable neames.
  17946. */
  17947. getSamplers(): string[];
  17948. /**
  17949. <<<<<<< HEAD
  17950. * The error from the last compilation.
  17951. * @returns the error string.
  17952. */
  17953. getCompilationError(): string;
  17954. /**
  17955. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17956. * @param func The callback to be used.
  17957. */
  17958. executeWhenCompiled(func: (effect: Effect) => void): void;
  17959. /** @ignore */
  17960. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17961. /** @ignore */
  17962. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17963. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  17964. private _processShaderConversion(sourceCode, isFragment, callback);
  17965. private _processIncludes(sourceCode, callback);
  17966. private _processPrecision(source);
  17967. /**
  17968. * Recompiles the webGL program
  17969. * @param vertexSourceCode The source code for the vertex shader.
  17970. * @param fragmentSourceCode The source code for the fragment shader.
  17971. * @param onCompiled Callback called when completed.
  17972. * @param onError Callback called on error.
  17973. */
  17974. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17975. /**
  17976. * Gets the uniform locations of the the specified variable names
  17977. * @param names THe names of the variables to lookup.
  17978. * @returns Array of locations in the same order as variable names.
  17979. */
  17980. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17981. /**
  17982. * Prepares the effect
  17983. */
  17984. _prepareEffect(): void;
  17985. /**
  17986. * Checks if the effect is supported. (Must be called after compilation)
  17987. */
  17988. readonly isSupported: boolean;
  17989. /**
  17990. * Binds a texture to the engine to be used as output of the shader.
  17991. * @param channel Name of the output variable.
  17992. * @param texture Texture to bind.
  17993. */
  17994. _bindTexture(channel: string, texture: InternalTexture): void;
  17995. /**
  17996. * Sets a texture on the engine to be used in the shader.
  17997. * @param channel Name of the sampler variable.
  17998. * @param texture Texture to set.
  17999. */
  18000. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  18001. /**
  18002. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  18003. * @param channel Name of the sampler variable.
  18004. * @param texture Texture to set.
  18005. */
  18006. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  18007. /**
  18008. * Sets an array of textures on the engine to be used in the shader.
  18009. * @param channel Name of the variable.
  18010. * @param textures Textures to set.
  18011. */
  18012. setTextureArray(channel: string, textures: BaseTexture[]): void;
  18013. /**
  18014. * 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)
  18015. * @param channel Name of the sampler variable.
  18016. * @param postProcess Post process to get the input texture from.
  18017. */
  18018. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  18019. /**
  18020. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  18021. * 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)
  18022. * @param channel Name of the sampler variable.
  18023. * @param postProcess Post process to get the output texture from.
  18024. */
  18025. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  18026. /** @ignore */
  18027. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  18028. /** @ignore */
  18029. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  18030. /** @ignore */
  18031. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  18032. /** @ignore */
  18033. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  18034. /**
  18035. * Binds a buffer to a uniform.
  18036. * @param buffer Buffer to bind.
  18037. * @param name Name of the uniform variable to bind to.
  18038. */
  18039. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  18040. /**
  18041. * Binds block to a uniform.
  18042. * @param blockName Name of the block to bind.
  18043. * @param index Index to bind.
  18044. */
  18045. bindUniformBlock(blockName: string, index: number): void;
  18046. /**
  18047. * Sets an interger value on a uniform variable.
  18048. * @param uniformName Name of the variable.
  18049. * @param value Value to be set.
  18050. * @returns this effect.
  18051. */
  18052. setInt(uniformName: string, value: number): Effect;
  18053. /**
  18054. * Sets an int array on a uniform variable.
  18055. * @param uniformName Name of the variable.
  18056. * @param array array to be set.
  18057. * @returns this effect.
  18058. */
  18059. setIntArray(uniformName: string, array: Int32Array): Effect;
  18060. /**
  18061. * 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)
  18062. * @param uniformName Name of the variable.
  18063. * @param array array to be set.
  18064. * @returns this effect.
  18065. */
  18066. setIntArray2(uniformName: string, array: Int32Array): Effect;
  18067. /**
  18068. * 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)
  18069. * @param uniformName Name of the variable.
  18070. * @param array array to be set.
  18071. * @returns this effect.
  18072. */
  18073. setIntArray3(uniformName: string, array: Int32Array): Effect;
  18074. /**
  18075. * 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)
  18076. * @param uniformName Name of the variable.
  18077. * @param array array to be set.
  18078. * @returns this effect.
  18079. */
  18080. setIntArray4(uniformName: string, array: Int32Array): Effect;
  18081. /**
  18082. * Sets an float array on a uniform variable.
  18083. * @param uniformName Name of the variable.
  18084. * @param array array to be set.
  18085. * @returns this effect.
  18086. */
  18087. setFloatArray(uniformName: string, array: Float32Array): Effect;
  18088. /**
  18089. * 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)
  18090. * @param uniformName Name of the variable.
  18091. * @param array array to be set.
  18092. * @returns this effect.
  18093. */
  18094. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  18095. /**
  18096. * 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)
  18097. * @param uniformName Name of the variable.
  18098. * @param array array to be set.
  18099. * @returns this effect.
  18100. */
  18101. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  18102. /**
  18103. * 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)
  18104. * @param uniformName Name of the variable.
  18105. * @param array array to be set.
  18106. * @returns this effect.
  18107. */
  18108. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  18109. /**
  18110. * Sets an array on a uniform variable.
  18111. * @param uniformName Name of the variable.
  18112. * @param array array to be set.
  18113. * @returns this effect.
  18114. */
  18115. setArray(uniformName: string, array: number[]): Effect;
  18116. /**
  18117. * 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)
  18118. * @param uniformName Name of the variable.
  18119. * @param array array to be set.
  18120. * @returns this effect.
  18121. */
  18122. setArray2(uniformName: string, array: number[]): Effect;
  18123. /**
  18124. * 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)
  18125. * @param uniformName Name of the variable.
  18126. * @param array array to be set.
  18127. * @returns this effect.
  18128. */
  18129. setArray3(uniformName: string, array: number[]): Effect;
  18130. /**
  18131. * 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)
  18132. * @param uniformName Name of the variable.
  18133. * @param array array to be set.
  18134. * @returns this effect.
  18135. */
  18136. setArray4(uniformName: string, array: number[]): Effect;
  18137. /**
  18138. * Sets matrices on a uniform variable.
  18139. * @param uniformName Name of the variable.
  18140. * @param matrices matrices to be set.
  18141. * @returns this effect.
  18142. */
  18143. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  18144. /**
  18145. * Sets matrix on a uniform variable.
  18146. * @param uniformName Name of the variable.
  18147. * @param matrix matrix to be set.
  18148. * @returns this effect.
  18149. */
  18150. setMatrix(uniformName: string, matrix: Matrix): Effect;
  18151. /**
  18152. * 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)
  18153. * @param uniformName Name of the variable.
  18154. * @param matrix matrix to be set.
  18155. * @returns this effect.
  18156. */
  18157. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  18158. /**
  18159. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  18160. * @param uniformName Name of the variable.
  18161. * @param matrix matrix to be set.
  18162. * @returns this effect.
  18163. */
  18164. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  18165. /**
  18166. * Sets a float on a uniform variable.
  18167. * @param uniformName Name of the variable.
  18168. * @param value value to be set.
  18169. * @returns this effect.
  18170. */
  18171. setFloat(uniformName: string, value: number): Effect;
  18172. /**
  18173. * Sets a boolean on a uniform variable.
  18174. * @param uniformName Name of the variable.
  18175. * @param bool value to be set.
  18176. * @returns this effect.
  18177. */
  18178. setBool(uniformName: string, bool: boolean): Effect;
  18179. /**
  18180. * Sets a Vector2 on a uniform variable.
  18181. * @param uniformName Name of the variable.
  18182. * @param vector2 vector2 to be set.
  18183. * @returns this effect.
  18184. */
  18185. setVector2(uniformName: string, vector2: Vector2): Effect;
  18186. /**
  18187. * Sets a float2 on a uniform variable.
  18188. * @param uniformName Name of the variable.
  18189. * @param x First float in float2.
  18190. * @param y Second float in float2.
  18191. * @returns this effect.
  18192. */
  18193. setFloat2(uniformName: string, x: number, y: number): Effect;
  18194. /**
  18195. * Sets a Vector3 on a uniform variable.
  18196. * @param uniformName Name of the variable.
  18197. * @param vector3 Value to be set.
  18198. * @returns this effect.
  18199. */
  18200. setVector3(uniformName: string, vector3: Vector3): Effect;
  18201. /**
  18202. * Sets a float3 on a uniform variable.
  18203. * @param uniformName Name of the variable.
  18204. * @param x First float in float3.
  18205. * @param y Second float in float3.
  18206. * @param z Third float in float3.
  18207. * @returns this effect.
  18208. */
  18209. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  18210. /**
  18211. * Sets a Vector4 on a uniform variable.
  18212. * @param uniformName Name of the variable.
  18213. * @param vector4 Value to be set.
  18214. * @returns this effect.
  18215. */
  18216. setVector4(uniformName: string, vector4: Vector4): Effect;
  18217. /**
  18218. * Sets a float4 on a uniform variable.
  18219. * @param uniformName Name of the variable.
  18220. * @param x First float in float4.
  18221. * @param y Second float in float4.
  18222. * @param z Third float in float4.
  18223. * @param w Fourth float in float4.
  18224. * @returns this effect.
  18225. */
  18226. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  18227. /**
  18228. * Sets a Color3 on a uniform variable.
  18229. * @param uniformName Name of the variable.
  18230. * @param color3 Value to be set.
  18231. * @returns this effect.
  18232. */
  18233. setColor3(uniformName: string, color3: Color3): Effect;
  18234. /**
  18235. * Sets a Color4 on a uniform variable.
  18236. * @param uniformName Name of the variable.
  18237. * @param color3 Value to be set.
  18238. * @param alpha Alpha value to be set.
  18239. * @returns this effect.
  18240. */
  18241. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  18242. /**
  18243. * Sets a Color4 on a uniform variable
  18244. * @param uniformName defines the name of the variable
  18245. * @param color4 defines the value to be set
  18246. * @returns this effect.
  18247. */
  18248. setDirectColor4(uniformName: string, color4: Color4): Effect;
  18249. /**
  18250. * Store of each shader (The can be looked up using effect.key)
  18251. */
  18252. static ShadersStore: {
  18253. [key: string]: string;
  18254. };
  18255. /**
  18256. * Store of each included file for a shader (The can be looked up using effect.key)
  18257. */
  18258. static IncludesShadersStore: {
  18259. [key: string]: string;
  18260. };
  18261. /**
  18262. * Resets the cache of effects.
  18263. */
  18264. static ResetCache(): void;
  18265. }
  18266. }
  18267. declare module BABYLON {
  18268. class FresnelParameters {
  18269. private _isEnabled;
  18270. isEnabled: boolean;
  18271. leftColor: Color3;
  18272. rightColor: Color3;
  18273. bias: number;
  18274. power: number;
  18275. clone(): FresnelParameters;
  18276. serialize(): any;
  18277. static Parse(parsedFresnelParameters: any): FresnelParameters;
  18278. }
  18279. }
  18280. declare module BABYLON {
  18281. /**
  18282. * Interface to follow in your material defines to integrate easily the
  18283. * Image proccessing functions.
  18284. * @ignore
  18285. */
  18286. interface IImageProcessingConfigurationDefines {
  18287. IMAGEPROCESSING: boolean;
  18288. VIGNETTE: boolean;
  18289. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18290. VIGNETTEBLENDMODEOPAQUE: boolean;
  18291. TONEMAPPING: boolean;
  18292. CONTRAST: boolean;
  18293. EXPOSURE: boolean;
  18294. COLORCURVES: boolean;
  18295. COLORGRADING: boolean;
  18296. COLORGRADING3D: boolean;
  18297. SAMPLER3DGREENDEPTH: boolean;
  18298. SAMPLER3DBGRMAP: boolean;
  18299. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18300. /**
  18301. * If the grain should be performed in the image processing shader.
  18302. */
  18303. GRAIN: boolean;
  18304. }
  18305. /**
  18306. * This groups together the common properties used for image processing either in direct forward pass
  18307. * or through post processing effect depending on the use of the image processing pipeline in your scene
  18308. * or not.
  18309. */
  18310. class ImageProcessingConfiguration {
  18311. /**
  18312. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  18313. */
  18314. colorCurves: Nullable<ColorCurves>;
  18315. private _colorCurvesEnabled;
  18316. /**
  18317. * Gets wether the color curves effect is enabled.
  18318. */
  18319. /**
  18320. * Sets wether the color curves effect is enabled.
  18321. */
  18322. colorCurvesEnabled: boolean;
  18323. /**
  18324. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  18325. */
  18326. colorGradingTexture: Nullable<BaseTexture>;
  18327. private _colorGradingEnabled;
  18328. /**
  18329. * Gets wether the color grading effect is enabled.
  18330. */
  18331. /**
  18332. * Sets wether the color grading effect is enabled.
  18333. */
  18334. colorGradingEnabled: boolean;
  18335. private _colorGradingWithGreenDepth;
  18336. /**
  18337. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  18338. */
  18339. /**
  18340. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  18341. */
  18342. colorGradingWithGreenDepth: boolean;
  18343. private _colorGradingBGR;
  18344. /**
  18345. * Gets wether the color grading texture contains BGR values.
  18346. */
  18347. /**
  18348. * Sets wether the color grading texture contains BGR values.
  18349. */
  18350. colorGradingBGR: boolean;
  18351. _exposure: number;
  18352. /**
  18353. * Gets the Exposure used in the effect.
  18354. */
  18355. /**
  18356. * Sets the Exposure used in the effect.
  18357. */
  18358. exposure: number;
  18359. private _toneMappingEnabled;
  18360. /**
  18361. * Gets wether the tone mapping effect is enabled.
  18362. */
  18363. /**
  18364. * Sets wether the tone mapping effect is enabled.
  18365. */
  18366. toneMappingEnabled: boolean;
  18367. protected _contrast: number;
  18368. /**
  18369. * Gets the contrast used in the effect.
  18370. */
  18371. /**
  18372. * Sets the contrast used in the effect.
  18373. */
  18374. contrast: number;
  18375. /**
  18376. * Vignette stretch size.
  18377. */
  18378. vignetteStretch: number;
  18379. /**
  18380. * Vignette centre X Offset.
  18381. */
  18382. vignetteCentreX: number;
  18383. /**
  18384. * Vignette centre Y Offset.
  18385. */
  18386. vignetteCentreY: number;
  18387. =======
  18388. * Creates a new disc geometry
  18389. * @param id defines the unique ID of the geometry
  18390. * @param scene defines the hosting scene
  18391. * @param radius defines the radius of the disc
  18392. * @param tessellation defines the tesselation factor to apply to the disc
  18393. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18394. * @param mesh defines the hosting mesh (can be null)
  18395. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18396. */
  18397. constructor(id: string, scene: Scene,
  18398. /**
  18399. * Defines the radius of the disc
  18400. */
  18401. radius: number,
  18402. /**
  18403. * Defines the tesselation factor to apply to the disc
  18404. */
  18405. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  18406. /**
  18407. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18408. */
  18409. side?: number);
  18410. _regenerateVertexData(): VertexData;
  18411. copy(id: string): Geometry;
  18412. }
  18413. /**
  18414. * Creates a new cylinder geometry
  18415. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  18416. */
  18417. class CylinderGeometry extends _PrimitiveGeometry {
  18418. /**
  18419. * Defines the height of the cylinder
  18420. */
  18421. height: number;
  18422. /**
  18423. * Defines the diameter of the cylinder's top cap
  18424. */
  18425. diameterTop: number;
  18426. /**
  18427. * Defines the diameter of the cylinder's bottom cap
  18428. */
  18429. diameterBottom: number;
  18430. /**
  18431. * Defines the tessellation factor to apply to the cylinder
  18432. */
  18433. tessellation: number;
  18434. /**
  18435. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  18436. */
  18437. subdivisions: number;
  18438. /**
  18439. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18440. */
  18441. side: number;
  18442. /**
  18443. * Creates a new cylinder geometry
  18444. * @param id defines the unique ID of the geometry
  18445. * @param scene defines the hosting scene
  18446. * @param height defines the height of the cylinder
  18447. * @param diameterTop defines the diameter of the cylinder's top cap
  18448. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  18449. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  18450. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  18451. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18452. * @param mesh defines the hosting mesh (can be null)
  18453. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18454. */
  18455. constructor(id: string, scene: Scene,
  18456. /**
  18457. * Defines the height of the cylinder
  18458. */
  18459. height: number,
  18460. /**
  18461. * Defines the diameter of the cylinder's top cap
  18462. */
  18463. diameterTop: number,
  18464. /**
  18465. * Defines the diameter of the cylinder's bottom cap
  18466. */
  18467. diameterBottom: number,
  18468. /**
  18469. * Defines the tessellation factor to apply to the cylinder
  18470. */
  18471. tessellation: number,
  18472. /**
  18473. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  18474. */
  18475. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  18476. /**
  18477. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18478. */
  18479. side?: number);
  18480. _regenerateVertexData(): VertexData;
  18481. copy(id: string): Geometry;
  18482. serialize(): any;
  18483. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  18484. }
  18485. /**
  18486. * Creates a new torus geometry
  18487. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  18488. */
  18489. class TorusGeometry extends _PrimitiveGeometry {
  18490. /**
  18491. * Defines the diameter of the torus
  18492. */
  18493. diameter: number;
  18494. /**
  18495. * Defines the thickness of the torus (ie. internal diameter)
  18496. */
  18497. thickness: number;
  18498. /**
  18499. * Defines the tesselation factor to apply to the torus
  18500. */
  18501. tessellation: number;
  18502. /**
  18503. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18504. */
  18505. side: number;
  18506. /**
  18507. * Creates a new torus geometry
  18508. * @param id defines the unique ID of the geometry
  18509. * @param scene defines the hosting scene
  18510. * @param diameter defines the diameter of the torus
  18511. * @param thickness defines the thickness of the torus (ie. internal diameter)
  18512. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  18513. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18514. * @param mesh defines the hosting mesh (can be null)
  18515. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18516. */
  18517. constructor(id: string, scene: Scene,
  18518. /**
  18519. * Defines the diameter of the torus
  18520. */
  18521. diameter: number,
  18522. /**
  18523. * Defines the thickness of the torus (ie. internal diameter)
  18524. */
  18525. thickness: number,
  18526. /**
  18527. * Defines the tesselation factor to apply to the torus
  18528. */
  18529. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  18530. /**
  18531. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18532. */
  18533. side?: number);
  18534. _regenerateVertexData(): VertexData;
  18535. copy(id: string): Geometry;
  18536. serialize(): any;
  18537. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  18538. }
  18539. /**
  18540. * Creates a new ground geometry
  18541. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  18542. */
  18543. class GroundGeometry extends _PrimitiveGeometry {
  18544. /**
  18545. * Defines the width of the ground
  18546. */
  18547. width: number;
  18548. /**
  18549. * Defines the height of the ground
  18550. */
  18551. height: number;
  18552. /**
  18553. * Defines the subdivisions to apply to the ground
  18554. */
  18555. subdivisions: number;
  18556. /**
  18557. * Creates a new ground geometry
  18558. * @param id defines the unique ID of the geometry
  18559. * @param scene defines the hosting scene
  18560. * @param width defines the width of the ground
  18561. * @param height defines the height of the ground
  18562. * @param subdivisions defines the subdivisions to apply to the ground
  18563. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18564. * @param mesh defines the hosting mesh (can be null)
  18565. */
  18566. constructor(id: string, scene: Scene,
  18567. /**
  18568. * Defines the width of the ground
  18569. */
  18570. width: number,
  18571. /**
  18572. * Defines the height of the ground
  18573. */
  18574. height: number,
  18575. /**
  18576. * Defines the subdivisions to apply to the ground
  18577. */
  18578. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  18579. _regenerateVertexData(): VertexData;
  18580. copy(id: string): Geometry;
  18581. serialize(): any;
  18582. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  18583. }
  18584. /**
  18585. * Creates a tiled ground geometry
  18586. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  18587. */
  18588. class TiledGroundGeometry extends _PrimitiveGeometry {
  18589. /**
  18590. * Defines the minimum value on X axis
  18591. */
  18592. xmin: number;
  18593. /**
  18594. * Defines the minimum value on Z axis
  18595. */
  18596. zmin: number;
  18597. /**
  18598. * Defines the maximum value on X axis
  18599. */
  18600. xmax: number;
  18601. /**
  18602. * Defines the maximum value on Z axis
  18603. */
  18604. zmax: number;
  18605. /**
  18606. * Defines the subdivisions to apply to the ground
  18607. */
  18608. subdivisions: {
  18609. w: number;
  18610. h: number;
  18611. };
  18612. /**
  18613. * Defines the precision to use when computing the tiles
  18614. */
  18615. precision: {
  18616. w: number;
  18617. h: number;
  18618. };
  18619. /**
  18620. * Creates a tiled ground geometry
  18621. * @param id defines the unique ID of the geometry
  18622. * @param scene defines the hosting scene
  18623. * @param xmin defines the minimum value on X axis
  18624. * @param zmin defines the minimum value on Z axis
  18625. * @param xmax defines the maximum value on X axis
  18626. * @param zmax defines the maximum value on Z axis
  18627. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  18628. * @param precision defines the precision to use when computing the tiles
  18629. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18630. * @param mesh defines the hosting mesh (can be null)
  18631. */
  18632. constructor(id: string, scene: Scene,
  18633. /**
  18634. * Defines the minimum value on X axis
  18635. */
  18636. xmin: number,
  18637. /**
  18638. * Defines the minimum value on Z axis
  18639. */
  18640. zmin: number,
  18641. /**
  18642. * Defines the maximum value on X axis
  18643. */
  18644. xmax: number,
  18645. /**
  18646. * Defines the maximum value on Z axis
  18647. */
  18648. zmax: number,
  18649. /**
  18650. * Defines the subdivisions to apply to the ground
  18651. */
  18652. subdivisions: {
  18653. w: number;
  18654. h: number;
  18655. },
  18656. /**
  18657. * Defines the precision to use when computing the tiles
  18658. */
  18659. precision: {
  18660. w: number;
  18661. h: number;
  18662. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  18663. _regenerateVertexData(): VertexData;
  18664. copy(id: string): Geometry;
  18665. }
  18666. /**
  18667. * Creates a plane geometry
  18668. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  18669. */
  18670. class PlaneGeometry extends _PrimitiveGeometry {
  18671. /**
  18672. * Defines the size of the plane (width === height)
  18673. */
  18674. size: number;
  18675. /**
  18676. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18677. */
  18678. side: number;
  18679. /**
  18680. * Creates a plane geometry
  18681. * @param id defines the unique ID of the geometry
  18682. * @param scene defines the hosting scene
  18683. * @param size defines the size of the plane (width === height)
  18684. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18685. * @param mesh defines the hosting mesh (can be null)
  18686. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18687. */
  18688. constructor(id: string, scene: Scene,
  18689. /**
  18690. * Defines the size of the plane (width === height)
  18691. */
  18692. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  18693. /**
  18694. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18695. */
  18696. side?: number);
  18697. _regenerateVertexData(): VertexData;
  18698. copy(id: string): Geometry;
  18699. serialize(): any;
  18700. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  18701. }
  18702. /**
  18703. * Creates a torus knot geometry
  18704. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  18705. */
  18706. class TorusKnotGeometry extends _PrimitiveGeometry {
  18707. /**
  18708. * Defines the radius of the torus knot
  18709. */
  18710. radius: number;
  18711. /**
  18712. * Defines the thickness of the torus knot tube
  18713. */
  18714. tube: number;
  18715. /**
  18716. * Defines the number of radial segments
  18717. */
  18718. radialSegments: number;
  18719. /**
  18720. * Defines the number of tubular segments
  18721. */
  18722. tubularSegments: number;
  18723. /**
  18724. * Defines the first number of windings
  18725. */
  18726. p: number;
  18727. /**
  18728. * Defines the second number of windings
  18729. */
  18730. q: number;
  18731. /**
  18732. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18733. */
  18734. side: number;
  18735. /**
  18736. * Creates a torus knot geometry
  18737. * @param id defines the unique ID of the geometry
  18738. * @param scene defines the hosting scene
  18739. * @param radius defines the radius of the torus knot
  18740. * @param tube defines the thickness of the torus knot tube
  18741. * @param radialSegments defines the number of radial segments
  18742. * @param tubularSegments defines the number of tubular segments
  18743. * @param p defines the first number of windings
  18744. * @param q defines the second number of windings
  18745. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18746. * @param mesh defines the hosting mesh (can be null)
  18747. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18748. */
  18749. constructor(id: string, scene: Scene,
  18750. /**
  18751. * Defines the radius of the torus knot
  18752. */
  18753. radius: number,
  18754. /**
  18755. * Defines the thickness of the torus knot tube
  18756. */
  18757. tube: number,
  18758. /**
  18759. * Defines the number of radial segments
  18760. */
  18761. radialSegments: number,
  18762. /**
  18763. * Defines the number of tubular segments
  18764. */
  18765. tubularSegments: number,
  18766. /**
  18767. * Defines the first number of windings
  18768. */
  18769. p: number,
  18770. /**
  18771. * Defines the second number of windings
  18772. */
  18773. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  18774. /**
  18775. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18776. */
  18777. side?: number);
  18778. _regenerateVertexData(): VertexData;
  18779. copy(id: string): Geometry;
  18780. serialize(): any;
  18781. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  18782. }
  18783. }
  18784. declare module BABYLON {
  18785. class GroundMesh extends Mesh {
  18786. generateOctree: boolean;
  18787. private _heightQuads;
  18788. _subdivisionsX: number;
  18789. _subdivisionsY: number;
  18790. _width: number;
  18791. _height: number;
  18792. _minX: number;
  18793. _maxX: number;
  18794. _minZ: number;
  18795. _maxZ: number;
  18796. constructor(name: string, scene: Scene);
  18797. getClassName(): string;
  18798. readonly subdivisions: number;
  18799. readonly subdivisionsX: number;
  18800. readonly subdivisionsY: number;
  18801. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18802. /**
  18803. * Returns a height (y) value in the Worl system :
  18804. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18805. * Returns the ground y position if (x, z) are outside the ground surface.
  18806. */
  18807. getHeightAtCoordinates(x: number, z: number): number;
  18808. /**
  18809. * Returns a normalized vector (Vector3) orthogonal to the ground
  18810. * at the ground coordinates (x, z) expressed in the World system.
  18811. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18812. */
  18813. getNormalAtCoordinates(x: number, z: number): Vector3;
  18814. /**
  18815. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18816. * at the ground coordinates (x, z) expressed in the World system.
  18817. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18818. * Returns the GroundMesh.
  18819. */
  18820. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18821. /**
  18822. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18823. * if the ground has been updated.
  18824. * This can be used in the render loop.
  18825. * Returns the GroundMesh.
  18826. */
  18827. updateCoordinateHeights(): GroundMesh;
  18828. private _getFacetAt(x, z);
  18829. private _initHeightQuads();
  18830. private _computeHeightQuads();
  18831. serialize(serializationObject: any): void;
  18832. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18833. }
  18834. }
  18835. declare module BABYLON {
  18836. /**
  18837. * Creates an instance based on a source mesh.
  18838. */
  18839. class InstancedMesh extends AbstractMesh {
  18840. private _sourceMesh;
  18841. private _currentLOD;
  18842. constructor(name: string, source: Mesh);
  18843. /**
  18844. * Returns the string "InstancedMesh".
  18845. */
  18846. getClassName(): string;
  18847. readonly receiveShadows: boolean;
  18848. readonly material: Nullable<Material>;
  18849. readonly visibility: number;
  18850. readonly skeleton: Nullable<Skeleton>;
  18851. renderingGroupId: number;
  18852. /**
  18853. * Returns the total number of vertices (integer).
  18854. */
  18855. getTotalVertices(): number;
  18856. readonly sourceMesh: Mesh;
  18857. /**
  18858. * Is this node ready to be used/rendered
  18859. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18860. * @return {boolean} is it ready
  18861. */
  18862. isReady(completeCheck?: boolean): boolean;
  18863. /**
  18864. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18865. */
  18866. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18867. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  18868. /**
  18869. * Vignette weight or intensity of the vignette effect.
  18870. */
  18871. <<<<<<< HEAD
  18872. vignetteWeight: number;
  18873. /**
  18874. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18875. * if vignetteEnabled is set to true.
  18876. */
  18877. vignetteColor: Color4;
  18878. =======
  18879. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18880. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  18881. /**
  18882. * Camera field of view used by the Vignette effect.
  18883. */
  18884. vignetteCameraFov: number;
  18885. private _grainEnabled;
  18886. /**
  18887. <<<<<<< HEAD
  18888. * If the grain effect should be enabled.
  18889. */
  18890. grainEnabled: boolean;
  18891. private _grainIntensity;
  18892. /**
  18893. * Amount of grain to be applied by the grain effect.
  18894. */
  18895. grainIntensity: number;
  18896. private _grainAnimated;
  18897. /**
  18898. * If the grain effect should be animated.
  18899. */
  18900. grainAnimated: boolean;
  18901. private _vignetteBlendMode;
  18902. /**
  18903. * Gets the vignette blend mode allowing different kind of effect.
  18904. */
  18905. /**
  18906. * Sets the vignette blend mode allowing different kind of effect.
  18907. */
  18908. vignetteBlendMode: number;
  18909. private _vignetteEnabled;
  18910. /**
  18911. * Gets wether the vignette effect is enabled.
  18912. */
  18913. /**
  18914. * Sets wether the vignette effect is enabled.
  18915. */
  18916. vignetteEnabled: boolean;
  18917. private _applyByPostProcess;
  18918. /**
  18919. * Gets wether the image processing is applied through a post process or not.
  18920. */
  18921. /**
  18922. * Sets wether the image processing is applied through a post process or not.
  18923. */
  18924. applyByPostProcess: boolean;
  18925. private _isEnabled;
  18926. /**
  18927. * Gets wether the image processing is enabled or not.
  18928. */
  18929. /**
  18930. * Sets wether the image processing is enabled or not.
  18931. */
  18932. isEnabled: boolean;
  18933. /**
  18934. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  18935. * @type {BABYLON.Observable}
  18936. */
  18937. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  18938. /**
  18939. * Method called each time the image processing information changes requires to recompile the effect.
  18940. */
  18941. protected _updateParameters(): void;
  18942. getClassName(): string;
  18943. /**
  18944. * Prepare the list of uniforms associated with the Image Processing effects.
  18945. * @param uniformsList The list of uniforms used in the effect
  18946. * @param defines the list of defines currently in use
  18947. */
  18948. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  18949. /**
  18950. * Prepare the list of samplers associated with the Image Processing effects.
  18951. * @param uniformsList The list of uniforms used in the effect
  18952. * @param defines the list of defines currently in use
  18953. */
  18954. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  18955. /**
  18956. * Prepare the list of defines associated to the shader.
  18957. * @param defines the list of defines to complete
  18958. */
  18959. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  18960. /**
  18961. * Returns true if all the image processing information are ready.
  18962. */
  18963. isReady(): boolean;
  18964. /**
  18965. * Binds the image processing to the shader.
  18966. * @param effect The effect to bind to
  18967. */
  18968. bind(effect: Effect, aspectRatio?: number): void;
  18969. /**
  18970. * Clones the current image processing instance.
  18971. * @return The cloned image processing
  18972. */
  18973. clone(): ImageProcessingConfiguration;
  18974. /**
  18975. * Serializes the current image processing instance to a json representation.
  18976. * @return a JSON representation
  18977. */
  18978. serialize(): any;
  18979. /**
  18980. * Parses the image processing from a json representation.
  18981. * @param source the JSON source to parse
  18982. * @return The parsed image processing
  18983. */
  18984. static Parse(source: any): ImageProcessingConfiguration;
  18985. private static _VIGNETTEMODE_MULTIPLY;
  18986. private static _VIGNETTEMODE_OPAQUE;
  18987. /**
  18988. * Used to apply the vignette as a mix with the pixel color.
  18989. */
  18990. static readonly VIGNETTEMODE_MULTIPLY: number;
  18991. /**
  18992. * Used to apply the vignette as a replacement of the pixel color.
  18993. */
  18994. static readonly VIGNETTEMODE_OPAQUE: number;
  18995. }
  18996. }
  18997. declare module BABYLON {
  18998. /**
  18999. * Manages the defines for the Material.
  19000. */
  19001. class MaterialDefines {
  19002. private _keys;
  19003. private _isDirty;
  19004. _renderId: number;
  19005. _areLightsDirty: boolean;
  19006. _areAttributesDirty: boolean;
  19007. _areTexturesDirty: boolean;
  19008. _areFresnelDirty: boolean;
  19009. _areMiscDirty: boolean;
  19010. _areImageProcessingDirty: boolean;
  19011. _normals: boolean;
  19012. _uvs: boolean;
  19013. _needNormals: boolean;
  19014. _needUVs: boolean;
  19015. /**
  19016. * Specifies if the material needs to be re-calculated.
  19017. */
  19018. readonly isDirty: boolean;
  19019. /**
  19020. * Marks the material to indicate that it has been re-calculated.
  19021. */
  19022. markAsProcessed(): void;
  19023. /**
  19024. * Marks the material to indicate that it needs to be re-calculated.
  19025. */
  19026. markAsUnprocessed(): void;
  19027. /**
  19028. * Marks the material to indicate all of its defines need to be re-calculated.
  19029. */
  19030. markAllAsDirty(): void;
  19031. /**
  19032. * Marks the material to indicate that image processing needs to be re-calculated.
  19033. */
  19034. markAsImageProcessingDirty(): void;
  19035. /**
  19036. * Marks the material to indicate the lights need to be re-calculated.
  19037. */
  19038. markAsLightDirty(): void;
  19039. /**
  19040. * Marks the attribute state as changed.
  19041. */
  19042. markAsAttributesDirty(): void;
  19043. /**
  19044. * Marks the texture state as changed.
  19045. */
  19046. markAsTexturesDirty(): void;
  19047. /**
  19048. * Marks the fresnel state as changed.
  19049. */
  19050. markAsFresnelDirty(): void;
  19051. /**
  19052. * Marks the misc state as changed.
  19053. */
  19054. markAsMiscDirty(): void;
  19055. /**
  19056. * Rebuilds the material defines.
  19057. */
  19058. rebuild(): void;
  19059. /**
  19060. * Specifies if two material defines are equal.
  19061. * @param other - A material define instance to compare to.
  19062. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  19063. */
  19064. isEqual(other: MaterialDefines): boolean;
  19065. /**
  19066. * Clones this instance's defines to another instance.
  19067. * @param other - material defines to clone values to.
  19068. */
  19069. cloneTo(other: MaterialDefines): void;
  19070. /**
  19071. * Resets the material define values.
  19072. */
  19073. reset(): void;
  19074. /**
  19075. * Converts the material define values to a string.
  19076. * @returns - String of material define information.
  19077. */
  19078. toString(): string;
  19079. }
  19080. /**
  19081. * This offers the main features of a material in BJS.
  19082. */
  19083. class Material implements IAnimatable {
  19084. private static _TriangleFillMode;
  19085. private static _WireFrameFillMode;
  19086. private static _PointFillMode;
  19087. private static _PointListDrawMode;
  19088. private static _LineListDrawMode;
  19089. private static _LineLoopDrawMode;
  19090. private static _LineStripDrawMode;
  19091. private static _TriangleStripDrawMode;
  19092. private static _TriangleFanDrawMode;
  19093. /**
  19094. * Returns the triangle fill mode.
  19095. */
  19096. static readonly TriangleFillMode: number;
  19097. /**
  19098. * Returns the wireframe mode.
  19099. */
  19100. static readonly WireFrameFillMode: number;
  19101. /**
  19102. * Returns the point fill mode.
  19103. */
  19104. static readonly PointFillMode: number;
  19105. /**
  19106. * Returns the point list draw mode.
  19107. */
  19108. static readonly PointListDrawMode: number;
  19109. /**
  19110. * Returns the line list draw mode.
  19111. */
  19112. static readonly LineListDrawMode: number;
  19113. /**
  19114. * Returns the line loop draw mode.
  19115. */
  19116. static readonly LineLoopDrawMode: number;
  19117. /**
  19118. * Returns the line strip draw mode.
  19119. */
  19120. static readonly LineStripDrawMode: number;
  19121. /**
  19122. * Returns the triangle strip draw mode.
  19123. */
  19124. static readonly TriangleStripDrawMode: number;
  19125. /**
  19126. * Returns the triangle fan draw mode.
  19127. */
  19128. static readonly TriangleFanDrawMode: number;
  19129. /**
  19130. * Stores the clock-wise side orientation.
  19131. */
  19132. private static _ClockWiseSideOrientation;
  19133. /**
  19134. * Stores the counter clock-wise side orientation.
  19135. */
  19136. private static _CounterClockWiseSideOrientation;
  19137. /**
  19138. * Returns the clock-wise side orientation.
  19139. */
  19140. static readonly ClockWiseSideOrientation: number;
  19141. /**
  19142. * Returns the counter clock-wise side orientation.
  19143. */
  19144. static readonly CounterClockWiseSideOrientation: number;
  19145. /**
  19146. * The dirty texture flag value.
  19147. */
  19148. private static _TextureDirtyFlag;
  19149. /**
  19150. * The dirty light flag value.
  19151. */
  19152. private static _LightDirtyFlag;
  19153. /**
  19154. * The dirty fresnel flag value.
  19155. */
  19156. private static _FresnelDirtyFlag;
  19157. /**
  19158. * The dirty attribute flag value.
  19159. */
  19160. private static _AttributesDirtyFlag;
  19161. /**
  19162. * The dirty misc flag value.
  19163. */
  19164. private static _MiscDirtyFlag;
  19165. /**
  19166. * Returns the dirty texture flag value.
  19167. */
  19168. static readonly TextureDirtyFlag: number;
  19169. /**
  19170. * Returns the dirty light flag value.
  19171. */
  19172. static readonly LightDirtyFlag: number;
  19173. /**
  19174. * Returns the dirty fresnel flag value.
  19175. */
  19176. static readonly FresnelDirtyFlag: number;
  19177. /**
  19178. * Returns the dirty attributes flag value.
  19179. */
  19180. static readonly AttributesDirtyFlag: number;
  19181. /**
  19182. * Returns the dirty misc flag value.
  19183. */
  19184. static readonly MiscDirtyFlag: number;
  19185. /**
  19186. * The ID of the material.
  19187. */
  19188. id: string;
  19189. /**
  19190. * The name of the material.
  19191. */
  19192. name: string;
  19193. /**
  19194. * Specifies if the ready state should be checked on each call.
  19195. */
  19196. checkReadyOnEveryCall: boolean;
  19197. /**
  19198. * Specifies if the ready state should be checked once.
  19199. */
  19200. checkReadyOnlyOnce: boolean;
  19201. /**
  19202. * The state of the material.
  19203. */
  19204. state: string;
  19205. /**
  19206. * The alpha value of the material.
  19207. */
  19208. protected _alpha: number;
  19209. /**
  19210. * Gets the alpha value of the material.
  19211. */
  19212. /**
  19213. * Sets the alpha value of the material.
  19214. */
  19215. alpha: number;
  19216. /**
  19217. * Specifies if back face culling is enabled.
  19218. */
  19219. protected _backFaceCulling: boolean;
  19220. /**
  19221. * Gets the back-face culling state.
  19222. */
  19223. /**
  19224. * Sets the back-face culling state.
  19225. */
  19226. backFaceCulling: boolean;
  19227. /**
  19228. * Stores the value for side orientation.
  19229. */
  19230. sideOrientation: number;
  19231. /**
  19232. * Callback triggered when the material is compiled.
  19233. */
  19234. onCompiled: (effect: Effect) => void;
  19235. /**
  19236. * Callback triggered when an error occurs.
  19237. */
  19238. onError: (effect: Effect, errors: string) => void;
  19239. /**
  19240. * Callback triggered to get the render target textures.
  19241. */
  19242. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  19243. /**
  19244. * Specifies if the material should be serialized.
  19245. */
  19246. doNotSerialize: boolean;
  19247. /**
  19248. * Specifies if the effect should be stored on sub meshes.
  19249. */
  19250. storeEffectOnSubMeshes: boolean;
  19251. /**
  19252. * Stores the animations for the material.
  19253. */
  19254. animations: Array<Animation>;
  19255. /**
  19256. * An event triggered when the material is disposed.
  19257. * @type {BABYLON.Observable}
  19258. */
  19259. onDisposeObservable: Observable<Material>;
  19260. /**
  19261. * An observer which watches for dispose events.
  19262. * @type {BABYLON.Observer}
  19263. */
  19264. private _onDisposeObserver;
  19265. /**
  19266. * Called during a dispose event.
  19267. */
  19268. onDispose: () => void;
  19269. /**
  19270. * An event triggered when the material is bound.
  19271. * @type {BABYLON.Observable}
  19272. */
  19273. onBindObservable: Observable<AbstractMesh>;
  19274. /**
  19275. * An observer which watches for bind events.
  19276. * @type {BABYLON.Observer}
  19277. */
  19278. private _onBindObserver;
  19279. /**
  19280. * Called during a bind event.
  19281. */
  19282. onBind: (Mesh: AbstractMesh) => void;
  19283. /**
  19284. * An event triggered when the material is unbound.
  19285. * @type {BABYLON.Observable}
  19286. */
  19287. onUnBindObservable: Observable<Material>;
  19288. /**
  19289. * Stores the value of the alpha mode.
  19290. */
  19291. private _alphaMode;
  19292. /**
  19293. * Gets the value of the alpha mode.
  19294. */
  19295. /**
  19296. * Sets the value of the alpha mode.
  19297. *
  19298. * | Value | Type | Description |
  19299. * | --- | --- | --- |
  19300. * | 0 | ALPHA_DISABLE | |
  19301. * | 1 | ALPHA_ADD | |
  19302. * | 2 | ALPHA_COMBINE | |
  19303. * | 3 | ALPHA_SUBTRACT | |
  19304. * | 4 | ALPHA_MULTIPLY | |
  19305. * | 5 | ALPHA_MAXIMIZED | |
  19306. * | 6 | ALPHA_ONEONE | |
  19307. * | 7 | ALPHA_PREMULTIPLIED | |
  19308. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19309. * | 9 | ALPHA_INTERPOLATE | |
  19310. * | 10 | ALPHA_SCREENMODE | |
  19311. *
  19312. */
  19313. alphaMode: number;
  19314. /**
  19315. * Stores the state of the need depth pre-pass value.
  19316. */
  19317. private _needDepthPrePass;
  19318. /**
  19319. * Gets the depth pre-pass value.
  19320. */
  19321. /**
  19322. * Sets the need depth pre-pass value.
  19323. */
  19324. needDepthPrePass: boolean;
  19325. /**
  19326. * Specifies if depth writing should be disabled.
  19327. */
  19328. disableDepthWrite: boolean;
  19329. /**
  19330. * Specifies if depth writing should be forced.
  19331. */
  19332. forceDepthWrite: boolean;
  19333. /**
  19334. * Specifies if there should be a separate pass for culling.
  19335. */
  19336. separateCullingPass: boolean;
  19337. /**
  19338. * Stores the state specifing if fog should be enabled.
  19339. */
  19340. private _fogEnabled;
  19341. /**
  19342. * Gets the value of the fog enabled state.
  19343. */
  19344. /**
  19345. * Sets the state for enabling fog.
  19346. */
  19347. fogEnabled: boolean;
  19348. /**
  19349. * Stores the size of points.
  19350. */
  19351. pointSize: number;
  19352. /**
  19353. * Stores the z offset value.
  19354. */
  19355. zOffset: number;
  19356. /**
  19357. * Gets a value specifying if wireframe mode is enabled.
  19358. */
  19359. /**
  19360. * Sets the state of wireframe mode.
  19361. */
  19362. wireframe: boolean;
  19363. /**
  19364. * Gets the value specifying if point clouds are enabled.
  19365. */
  19366. /**
  19367. * Sets the state of point cloud mode.
  19368. */
  19369. pointsCloud: boolean;
  19370. /**
  19371. * Gets the material fill mode.
  19372. */
  19373. /**
  19374. * Sets the material fill mode.
  19375. */
  19376. fillMode: number;
  19377. /**
  19378. * Stores the effects for the material.
  19379. */
  19380. _effect: Nullable<Effect>;
  19381. /**
  19382. * Specifies if the material was previously ready.
  19383. */
  19384. _wasPreviouslyReady: boolean;
  19385. /**
  19386. * Specifies if uniform buffers should be used.
  19387. */
  19388. private _useUBO;
  19389. /**
  19390. * Stores a reference to the scene.
  19391. */
  19392. private _scene;
  19393. /**
  19394. * Stores the fill mode state.
  19395. */
  19396. private _fillMode;
  19397. /**
  19398. * Specifies if the depth write state should be cached.
  19399. */
  19400. private _cachedDepthWriteState;
  19401. /**
  19402. * Stores the uniform buffer.
  19403. */
  19404. protected _uniformBuffer: UniformBuffer;
  19405. /**
  19406. * Creates a material instance.
  19407. * @param name - The name of the material.
  19408. * @param scene - The BJS scene to reference.
  19409. * @param doNotAdd - Specifies if the material should be added to the scene.
  19410. */
  19411. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  19412. /**
  19413. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  19414. * subclasses should override adding information pertainent to themselves.
  19415. * @returns - String with material information.
  19416. */
  19417. toString(fullDetails?: boolean): string;
  19418. /**
  19419. * Gets the class name of the material.
  19420. * @returns - String with the class name of the material.
  19421. */
  19422. getClassName(): string;
  19423. /**
  19424. * Specifies if updates for the material been locked.
  19425. */
  19426. readonly isFrozen: boolean;
  19427. /**
  19428. * Locks updates for the material.
  19429. */
  19430. freeze(): void;
  19431. /**
  19432. * Unlocks updates for the material.
  19433. */
  19434. unfreeze(): void;
  19435. /**
  19436. * Specifies if the material is ready to be used.
  19437. * @param mesh - BJS mesh.
  19438. * @param useInstances - Specifies if instances should be used.
  19439. * @returns - Boolean indicating if the material is ready to be used.
  19440. */
  19441. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19442. /**
  19443. * Specifies that the submesh is ready to be used.
  19444. * @param mesh - BJS mesh.
  19445. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  19446. * @param useInstances - Specifies that instances should be used.
  19447. * @returns - boolean indicating that the submesh is ready or not.
  19448. */
  19449. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19450. /**
  19451. * Returns the material effect.
  19452. * @returns - Nullable material effect.
  19453. */
  19454. getEffect(): Nullable<Effect>;
  19455. /**
  19456. * Returns the BJS scene.
  19457. * @returns - BJS Scene.
  19458. */
  19459. getScene(): Scene;
  19460. /**
  19461. * Specifies if the material will require alpha blending
  19462. * @returns - Boolean specifying if alpha blending is needed.
  19463. */
  19464. needAlphaBlending(): boolean;
  19465. /**
  19466. * Specifies if the mesh will require alpha blending.
  19467. * @param mesh - BJS mesh.
  19468. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  19469. */
  19470. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  19471. /**
  19472. * Specifies if this material should be rendered in alpha test mode.
  19473. * @returns - Boolean specifying if an alpha test is needed.
  19474. */
  19475. needAlphaTesting(): boolean;
  19476. /**
  19477. * Gets the texture used for the alpha test.
  19478. * @returns - Nullable alpha test texture.
  19479. */
  19480. getAlphaTestTexture(): Nullable<BaseTexture>;
  19481. /**
  19482. * Marks the material to indicate that it needs to be re-calculated.
  19483. */
  19484. markDirty(): void;
  19485. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  19486. /**
  19487. * Binds the material to the mesh.
  19488. * @param world - World transformation matrix.
  19489. * @param mesh - Mesh to bind the material to.
  19490. */
  19491. bind(world: Matrix, mesh?: Mesh): void;
  19492. /**
  19493. * Binds the submesh to the material.
  19494. * @param world - World transformation matrix.
  19495. * @param mesh - Mesh containing the submesh.
  19496. * @param subMesh - Submesh to bind the material to.
  19497. */
  19498. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19499. /**
  19500. * Binds the world matrix to the material.
  19501. * @param world - World transformation matrix.
  19502. */
  19503. bindOnlyWorldMatrix(world: Matrix): void;
  19504. /**
  19505. * Binds the scene's uniform buffer to the effect.
  19506. * @param effect - Effect to bind to the scene uniform buffer.
  19507. * @param sceneUbo - Scene uniform buffer.
  19508. */
  19509. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  19510. /**
  19511. * Binds the view matrix to the effect.
  19512. * @param effect - Effect to bind the view matrix to.
  19513. */
  19514. bindView(effect: Effect): void;
  19515. /**
  19516. * Binds the view projection matrix to the effect.
  19517. * @param effect - Effect to bind the view projection matrix to.
  19518. */
  19519. bindViewProjection(effect: Effect): void;
  19520. /**
  19521. * Specifies if material alpha testing should be turned on for the mesh.
  19522. * @param mesh - BJS mesh.
  19523. */
  19524. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  19525. /**
  19526. * Processes to execute after binding the material to a mesh.
  19527. * @param mesh - BJS mesh.
  19528. */
  19529. protected _afterBind(mesh?: Mesh): void;
  19530. /**
  19531. * Unbinds the material from the mesh.
  19532. */
  19533. unbind(): void;
  19534. /**
  19535. * Gets the active textures from the material.
  19536. * @returns - Array of textures.
  19537. */
  19538. getActiveTextures(): BaseTexture[];
  19539. /**
  19540. * Specifies if the material uses a texture.
  19541. * @param texture - Texture to check against the material.
  19542. * @returns - Boolean specifying if the material uses the texture.
  19543. */
  19544. hasTexture(texture: BaseTexture): boolean;
  19545. /**
  19546. * Makes a duplicate of the material, and gives it a new name.
  19547. * @param name - Name to call the duplicated material.
  19548. * @returns - Nullable cloned material
  19549. */
  19550. clone(name: string): Nullable<Material>;
  19551. /**
  19552. * Gets the meshes bound to the material.
  19553. * @returns - Array of meshes bound to the material.
  19554. */
  19555. getBindedMeshes(): AbstractMesh[];
  19556. /**
  19557. * Force shader compilation
  19558. * @param mesh - BJS mesh.
  19559. * @param onCompiled - function to execute once the material is compiled.
  19560. * @param options - options to pass to this function.
  19561. */
  19562. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  19563. clipPlane: boolean;
  19564. }>): void;
  19565. /**
  19566. * Force shader compilation.
  19567. * @param mesh The mesh that will use this material
  19568. * @param options Additional options for compiling the shaders
  19569. * @returns A promise that resolves when the compilation completes
  19570. */
  19571. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  19572. clipPlane: boolean;
  19573. }>): Promise<void>;
  19574. /**
  19575. * Marks a define in the material to indicate that it needs to be re-computed.
  19576. * @param flag - Material define flag.
  19577. */
  19578. markAsDirty(flag: number): void;
  19579. /**
  19580. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  19581. * @param func - function which checks material defines against the submeshes.
  19582. */
  19583. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  19584. /**
  19585. * Indicates that image processing needs to be re-calculated for all submeshes.
  19586. */
  19587. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  19588. /**
  19589. * Indicates that textures need to be re-calculated for all submeshes.
  19590. */
  19591. protected _markAllSubMeshesAsTexturesDirty(): void;
  19592. /**
  19593. * Indicates that fresnel needs to be re-calculated for all submeshes.
  19594. */
  19595. protected _markAllSubMeshesAsFresnelDirty(): void;
  19596. /**
  19597. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  19598. */
  19599. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  19600. /**
  19601. * Indicates that lights need to be re-calculated for all submeshes.
  19602. */
  19603. protected _markAllSubMeshesAsLightsDirty(): void;
  19604. /**
  19605. * Indicates that attributes need to be re-calculated for all submeshes.
  19606. */
  19607. protected _markAllSubMeshesAsAttributesDirty(): void;
  19608. /**
  19609. * Indicates that misc needs to be re-calculated for all submeshes.
  19610. */
  19611. protected _markAllSubMeshesAsMiscDirty(): void;
  19612. /**
  19613. * Indicates that textures and misc need to be re-calculated for all submeshes.
  19614. */
  19615. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  19616. /**
  19617. * Disposes the material.
  19618. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  19619. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  19620. */
  19621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19622. /**
  19623. * Serializes this material.
  19624. * @returns - serialized material object.
  19625. */
  19626. serialize(): any;
  19627. /**
  19628. * Creates a MultiMaterial from parse MultiMaterial data.
  19629. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  19630. * @param scene - BJS scene.
  19631. * @returns - MultiMaterial.
  19632. */
  19633. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  19634. /**
  19635. * Creates a material from parsed material data.
  19636. * @param parsedMaterial - Parsed material data.
  19637. * @param scene - BJS scene.
  19638. * @param rootUrl - Root URL containing the material information.
  19639. * @returns - Parsed material.
  19640. */
  19641. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  19642. }
  19643. }
  19644. declare module BABYLON {
  19645. /**
  19646. * "Static Class" containing the most commonly used helper while dealing with material for
  19647. * rendering purpose.
  19648. *
  19649. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19650. *
  19651. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19652. */
  19653. class MaterialHelper {
  19654. /**
  19655. * Bind the current view position to an effect.
  19656. * @param effect The effect to be bound
  19657. * @param scene The scene the eyes position is used from
  19658. */
  19659. static BindEyePosition(effect: Effect, scene: Scene): void;
  19660. /**
  19661. * Helps preparing the defines values about the UVs in used in the effect.
  19662. * UVs are shared as much as we can accross chanels in the shaders.
  19663. * @param texture The texture we are preparing the UVs for
  19664. * @param defines The defines to update
  19665. * @param key The chanel key "diffuse", "specular"... used in the shader
  19666. */
  19667. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19668. /**
  19669. * Binds a texture matrix value to its corrsponding uniform
  19670. * @param texture The texture to bind the matrix for
  19671. * @param uniformBuffer The uniform buffer receivin the data
  19672. * @param key The chanel key "diffuse", "specular"... used in the shader
  19673. */
  19674. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19675. /**
  19676. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19677. * @param mesh defines the current mesh
  19678. * @param scene defines the current scene
  19679. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19680. * @param pointsCloud defines if point cloud rendering has to be turned on
  19681. * @param fogEnabled defines if fog has to be turned on
  19682. * @param alphaTest defines if alpha testing has to be turned on
  19683. * @param defines defines the current list of defines
  19684. */
  19685. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19686. /**
  19687. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19688. * @param scene defines the current scene
  19689. * @param engine defines the current engine
  19690. * @param defines specifies the list of active defines
  19691. * @param useInstances defines if instances have to be turned on
  19692. * @param useClipPlane defines if clip plane have to be turned on
  19693. */
  19694. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  19695. /**
  19696. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19697. * @param mesh The mesh containing the geometry data we will draw
  19698. * @param defines The defines to update
  19699. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19700. * @param useBones Precise whether bones should be used or not (override mesh info)
  19701. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19702. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19703. * @returns false if defines are considered not dirty and have not been checked
  19704. */
  19705. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19706. /**
  19707. * Prepares the defines related to the light information passed in parameter
  19708. * @param scene The scene we are intending to draw
  19709. * @param mesh The mesh the effect is compiling for
  19710. * @param defines The defines to update
  19711. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19712. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  19713. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  19714. * @returns true if normals will be required for the rest of the effect
  19715. */
  19716. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  19717. /**
  19718. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  19719. * that won t be acctive due to defines being turned off.
  19720. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  19721. * @param samplersList The samplers list
  19722. * @param defines The defines helping in the list generation
  19723. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  19724. */
  19725. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  19726. /**
  19727. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  19728. * @param defines The defines to update while falling back
  19729. * @param fallbacks The authorized effect fallbacks
  19730. * @param maxSimultaneousLights The maximum number of lights allowed
  19731. * @param rank the current rank of the Effect
  19732. * @returns The newly affected rank
  19733. */
  19734. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  19735. /**
  19736. * Prepares the list of attributes required for morph targets according to the effect defines.
  19737. * @param attribs The current list of supported attribs
  19738. * @param mesh The mesh to prepare the morph targets attributes for
  19739. * @param defines The current Defines of the effect
  19740. */
  19741. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  19742. /**
  19743. * Prepares the list of attributes required for bones according to the effect defines.
  19744. * @param attribs The current list of supported attribs
  19745. * @param mesh The mesh to prepare the bones attributes for
  19746. * @param defines The current Defines of the effect
  19747. * @param fallbacks The current efffect fallback strategy
  19748. */
  19749. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  19750. /**
  19751. * Prepares the list of attributes required for instances according to the effect defines.
  19752. * @param attribs The current list of supported attribs
  19753. * @param defines The current Defines of the effect
  19754. */
  19755. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  19756. /**
  19757. * Binds the light shadow information to the effect for the given mesh.
  19758. * @param light The light containing the generator
  19759. * @param scene The scene the lights belongs to
  19760. * @param mesh The mesh we are binding the information to render
  19761. * @param lightIndex The light index in the effect used to render the mesh
  19762. * @param effect The effect we are binding the data to
  19763. */
  19764. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  19765. /**
  19766. * Binds the light information to the effect.
  19767. * @param light The light containing the generator
  19768. * @param effect The effect we are binding the data to
  19769. * @param lightIndex The light index in the effect used to render
  19770. */
  19771. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  19772. /**
  19773. * Binds the lights information from the scene to the effect for the given mesh.
  19774. * @param scene The scene the lights belongs to
  19775. * @param mesh The mesh we are binding the information to render
  19776. * @param effect The effect we are binding the data to
  19777. * @param defines The generated defines for the effect
  19778. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  19779. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  19780. */
  19781. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  19782. /**
  19783. * Binds the fog information from the scene to the effect for the given mesh.
  19784. * @param scene The scene the lights belongs to
  19785. * @param mesh The mesh we are binding the information to render
  19786. * @param effect The effect we are binding the data to
  19787. */
  19788. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  19789. /**
  19790. * Binds the bones information from the mesh to the effect.
  19791. * @param mesh The mesh we are binding the information to render
  19792. * @param effect The effect we are binding the data to
  19793. */
  19794. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  19795. /**
  19796. * Binds the morph targets information from the mesh to the effect.
  19797. * @param abstractMesh The mesh we are binding the information to render
  19798. * @param effect The effect we are binding the data to
  19799. */
  19800. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  19801. /**
  19802. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  19803. * @param defines The generated defines used in the effect
  19804. * @param effect The effect we are binding the data to
  19805. * @param scene The scene we are willing to render with logarithmic scale for
  19806. */
  19807. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  19808. /**
  19809. * Binds the clip plane information from the scene to the effect.
  19810. * @param scene The scene the clip plane information are extracted from
  19811. * @param effect The effect we are binding the data to
  19812. */
  19813. static BindClipPlane(effect: Effect, scene: Scene): void;
  19814. =======
  19815. * Sets the mesh indices.
  19816. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19817. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19818. * This method creates a new index buffer each call.
  19819. * Returns the Mesh.
  19820. */
  19821. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19822. /**
  19823. * Boolean : True if the mesh owns the requested kind of data.
  19824. */
  19825. isVerticesDataPresent(kind: string): boolean;
  19826. /**
  19827. * Returns an array of indices (IndicesArray).
  19828. */
  19829. getIndices(): Nullable<IndicesArray>;
  19830. readonly _positions: Nullable<Vector3[]>;
  19831. /**
  19832. * Sets a new updated BoundingInfo to the mesh.
  19833. * Returns the mesh.
  19834. */
  19835. refreshBoundingInfo(): InstancedMesh;
  19836. _preActivate(): InstancedMesh;
  19837. _activate(renderId: number): InstancedMesh;
  19838. /**
  19839. * Returns the current associated LOD AbstractMesh.
  19840. */
  19841. getLOD(camera: Camera): AbstractMesh;
  19842. _syncSubMeshes(): InstancedMesh;
  19843. _generatePointsArray(): boolean;
  19844. /**
  19845. * Creates a new InstancedMesh from the current mesh.
  19846. * - name (string) : the cloned mesh name
  19847. * - newParent (optional Node) : the optional Node to parent the clone to.
  19848. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19849. *
  19850. * Returns the clone.
  19851. */
  19852. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19853. /**
  19854. * Disposes the InstancedMesh.
  19855. * Returns nothing.
  19856. */
  19857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19858. }
  19859. }
  19860. declare module BABYLON {
  19861. class LinesMesh extends Mesh {
  19862. useVertexColor: boolean | undefined;
  19863. useVertexAlpha: boolean | undefined;
  19864. color: Color3;
  19865. alpha: number;
  19866. /**
  19867. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19868. * This margin is expressed in world space coordinates, so its value may vary.
  19869. * Default value is 0.1
  19870. * @returns the intersection Threshold value.
  19871. */
  19872. /**
  19873. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19874. * This margin is expressed in world space coordinates, so its value may vary.
  19875. * @param value the new threshold to apply
  19876. */
  19877. intersectionThreshold: number;
  19878. private _intersectionThreshold;
  19879. private _colorShader;
  19880. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  19881. /**
  19882. * Returns the string "LineMesh"
  19883. */
  19884. getClassName(): string;
  19885. material: Material;
  19886. readonly checkCollisions: boolean;
  19887. createInstance(name: string): InstancedMesh;
  19888. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19889. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19890. dispose(doNotRecurse?: boolean): void;
  19891. /**
  19892. * Returns a new LineMesh object cloned from the current one.
  19893. */
  19894. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19895. }
  19896. }
  19897. declare module BABYLON {
  19898. class _InstancesBatch {
  19899. mustReturn: boolean;
  19900. visibleInstances: Nullable<InstancedMesh[]>[];
  19901. renderSelf: boolean[];
  19902. }
  19903. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19904. static _FRONTSIDE: number;
  19905. static _BACKSIDE: number;
  19906. static _DOUBLESIDE: number;
  19907. static _DEFAULTSIDE: number;
  19908. static _NO_CAP: number;
  19909. static _CAP_START: number;
  19910. static _CAP_END: number;
  19911. static _CAP_ALL: number;
  19912. /**
  19913. * Mesh side orientation : usually the external or front surface
  19914. */
  19915. static readonly FRONTSIDE: number;
  19916. /**
  19917. * Mesh side orientation : usually the internal or back surface
  19918. */
  19919. static readonly BACKSIDE: number;
  19920. /**
  19921. * Mesh side orientation : both internal and external or front and back surfaces
  19922. */
  19923. static readonly DOUBLESIDE: number;
  19924. /**
  19925. * Mesh side orientation : by default, `FRONTSIDE`
  19926. */
  19927. static readonly DEFAULTSIDE: number;
  19928. /**
  19929. * Mesh cap setting : no cap
  19930. */
  19931. static readonly NO_CAP: number;
  19932. /**
  19933. * Mesh cap setting : one cap at the beginning of the mesh
  19934. */
  19935. static readonly CAP_START: number;
  19936. /**
  19937. * Mesh cap setting : one cap at the end of the mesh
  19938. */
  19939. static readonly CAP_END: number;
  19940. /**
  19941. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19942. */
  19943. static readonly CAP_ALL: number;
  19944. /**
  19945. * An event triggered before rendering the mesh
  19946. * @type {BABYLON.Observable}
  19947. */
  19948. onBeforeRenderObservable: Observable<Mesh>;
  19949. /**
  19950. * An event triggered after rendering the mesh
  19951. * @type {BABYLON.Observable}
  19952. */
  19953. onAfterRenderObservable: Observable<Mesh>;
  19954. /**
  19955. * An event triggered before drawing the mesh
  19956. * @type {BABYLON.Observable}
  19957. */
  19958. onBeforeDrawObservable: Observable<Mesh>;
  19959. private _onBeforeDrawObserver;
  19960. onBeforeDraw: () => void;
  19961. delayLoadState: number;
  19962. instances: InstancedMesh[];
  19963. delayLoadingFile: string;
  19964. _binaryInfo: any;
  19965. private _LODLevels;
  19966. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  19967. private _morphTargetManager;
  19968. morphTargetManager: Nullable<MorphTargetManager>;
  19969. _geometry: Nullable<Geometry>;
  19970. _delayInfo: Array<string>;
  19971. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19972. _visibleInstances: any;
  19973. private _renderIdForInstances;
  19974. private _batchCache;
  19975. private _instancesBufferSize;
  19976. private _instancesBuffer;
  19977. private _instancesData;
  19978. private _overridenInstanceCount;
  19979. private _effectiveMaterial;
  19980. _shouldGenerateFlatShading: boolean;
  19981. private _preActivateId;
  19982. _originalBuilderSideOrientation: number;
  19983. overrideMaterialSideOrientation: Nullable<number>;
  19984. private _areNormalsFrozen;
  19985. private _sourcePositions;
  19986. private _sourceNormals;
  19987. private _source;
  19988. readonly source: Nullable<Mesh>;
  19989. isUnIndexed: boolean;
  19990. /**
  19991. * @constructor
  19992. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  19993. * @param {Scene} scene The scene to add this mesh to.
  19994. * @param {Node} parent The parent of this mesh, if it has one
  19995. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  19996. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19997. * When false, achieved by calling a clone(), also passing False.
  19998. * This will make creation of children, recursive.
  19999. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20000. */
  20001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20002. /**
  20003. * Returns the string "Mesh".
  20004. */
  20005. getClassName(): string;
  20006. /**
  20007. * Returns a string.
  20008. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20009. */
  20010. toString(fullDetails?: boolean): string;
  20011. /**
  20012. * True if the mesh has some Levels Of Details (LOD).
  20013. * Returns a boolean.
  20014. */
  20015. readonly hasLODLevels: boolean;
  20016. /**
  20017. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20018. * @returns an array of {BABYLON.MeshLODLevel}
  20019. */
  20020. getLODLevels(): MeshLODLevel[];
  20021. private _sortLODLevels();
  20022. /**
  20023. * Add a mesh as LOD level triggered at the given distance.
  20024. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20025. * @param {number} distance The distance from the center of the object to show this level
  20026. * @param {Mesh} mesh The mesh to be added as LOD level
  20027. * @return {Mesh} This mesh (for chaining)
  20028. */
  20029. addLODLevel(distance: number, mesh: Mesh): Mesh;
  20030. /**
  20031. * Returns the LOD level mesh at the passed distance or null if not found.
  20032. * It is related to the method `addLODLevel(distance, mesh)`.
  20033. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20034. * Returns an object Mesh or `null`.
  20035. */
  20036. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20037. /**
  20038. * Remove a mesh from the LOD array
  20039. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20040. * @param {Mesh} mesh The mesh to be removed.
  20041. * @return {Mesh} This mesh (for chaining)
  20042. */
  20043. removeLODLevel(mesh: Mesh): Mesh;
  20044. /**
  20045. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20046. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20047. */
  20048. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  20049. /**
  20050. * Returns the mesh internal Geometry object.
  20051. */
  20052. readonly geometry: Nullable<Geometry>;
  20053. /**
  20054. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20055. */
  20056. getTotalVertices(): number;
  20057. /**
  20058. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20059. * 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.
  20060. * You can force the copy with forceCopy === true
  20061. * Returns null if the mesh has no geometry or no vertex buffer.
  20062. * Possible `kind` values :
  20063. * - BABYLON.VertexBuffer.PositionKind
  20064. * - BABYLON.VertexBuffer.UVKind
  20065. * - BABYLON.VertexBuffer.UV2Kind
  20066. * - BABYLON.VertexBuffer.UV3Kind
  20067. * - BABYLON.VertexBuffer.UV4Kind
  20068. * - BABYLON.VertexBuffer.UV5Kind
  20069. * - BABYLON.VertexBuffer.UV6Kind
  20070. * - BABYLON.VertexBuffer.ColorKind
  20071. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20072. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20073. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20074. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20075. */
  20076. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20077. /**
  20078. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20079. * Returns `null` if the mesh has no geometry.
  20080. * Possible `kind` values :
  20081. * - BABYLON.VertexBuffer.PositionKind
  20082. * - BABYLON.VertexBuffer.UVKind
  20083. * - BABYLON.VertexBuffer.UV2Kind
  20084. * - BABYLON.VertexBuffer.UV3Kind
  20085. * - BABYLON.VertexBuffer.UV4Kind
  20086. * - BABYLON.VertexBuffer.UV5Kind
  20087. * - BABYLON.VertexBuffer.UV6Kind
  20088. * - BABYLON.VertexBuffer.ColorKind
  20089. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20090. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20091. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20092. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20093. */
  20094. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20095. /**
  20096. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  20097. * Possible `kind` values :
  20098. * - BABYLON.VertexBuffer.PositionKind
  20099. * - BABYLON.VertexBuffer.UVKind
  20100. * - BABYLON.VertexBuffer.UV2Kind
  20101. * - BABYLON.VertexBuffer.UV3Kind
  20102. * - BABYLON.VertexBuffer.UV4Kind
  20103. * - BABYLON.VertexBuffer.UV5Kind
  20104. * - BABYLON.VertexBuffer.UV6Kind
  20105. * - BABYLON.VertexBuffer.ColorKind
  20106. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20107. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20108. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20109. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20110. */
  20111. isVerticesDataPresent(kind: string): boolean;
  20112. /**
  20113. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20114. * Possible `kind` values :
  20115. * - BABYLON.VertexBuffer.PositionKind
  20116. * - BABYLON.VertexBuffer.UVKind
  20117. * - BABYLON.VertexBuffer.UV2Kind
  20118. * - BABYLON.VertexBuffer.UV3Kind
  20119. * - BABYLON.VertexBuffer.UV4Kind
  20120. * - BABYLON.VertexBuffer.UV5Kind
  20121. * - BABYLON.VertexBuffer.UV6Kind
  20122. * - BABYLON.VertexBuffer.ColorKind
  20123. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20124. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20125. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20126. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20127. */
  20128. isVertexBufferUpdatable(kind: string): boolean;
  20129. /**
  20130. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20131. * Possible `kind` values :
  20132. * - BABYLON.VertexBuffer.PositionKind
  20133. * - BABYLON.VertexBuffer.UVKind
  20134. * - BABYLON.VertexBuffer.UV2Kind
  20135. * - BABYLON.VertexBuffer.UV3Kind
  20136. * - BABYLON.VertexBuffer.UV4Kind
  20137. * - BABYLON.VertexBuffer.UV5Kind
  20138. * - BABYLON.VertexBuffer.UV6Kind
  20139. * - BABYLON.VertexBuffer.ColorKind
  20140. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20141. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20142. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20143. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20144. */
  20145. getVerticesDataKinds(): string[];
  20146. /**
  20147. * Returns a positive integer : the total number of indices in this mesh geometry.
  20148. * Returns zero if the mesh has no geometry.
  20149. */
  20150. getTotalIndices(): number;
  20151. /**
  20152. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20153. * 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.
  20154. * Returns an empty array if the mesh has no geometry.
  20155. */
  20156. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20157. readonly isBlocked: boolean;
  20158. /**
  20159. * Determine if the current mesh is ready to be rendered
  20160. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20161. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20162. * @returns true if all associated assets are ready (material, textures, shaders)
  20163. */
  20164. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20165. /**
  20166. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20167. * This property is pertinent only for updatable parametric shapes.
  20168. */
  20169. readonly areNormalsFrozen: boolean;
  20170. /**
  20171. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20172. * It has no effect at all on other shapes.
  20173. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20174. * Returns the Mesh.
  20175. */
  20176. freezeNormals(): Mesh;
  20177. /**
  20178. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20179. * It has no effect at all on other shapes.
  20180. * It reactivates the mesh normals computation if it was previously frozen.
  20181. * Returns the Mesh.
  20182. */
  20183. unfreezeNormals(): Mesh;
  20184. /**
  20185. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20186. */
  20187. overridenInstanceCount: number;
  20188. _preActivate(): Mesh;
  20189. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20190. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20191. /**
  20192. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20193. * This means the mesh underlying bounding box and sphere are recomputed.
  20194. * Returns the Mesh.
  20195. */
  20196. refreshBoundingInfo(): Mesh;
  20197. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20198. private _getPositionData(applySkeleton);
  20199. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20200. subdivide(count: number): void;
  20201. /**
  20202. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20203. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20204. * The `data` are either a numeric array either a Float32Array.
  20205. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20206. * 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).
  20207. * Note that a new underlying VertexBuffer object is created each call.
  20208. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20209. *
  20210. * Possible `kind` values :
  20211. * - BABYLON.VertexBuffer.PositionKind
  20212. * - BABYLON.VertexBuffer.UVKind
  20213. * - BABYLON.VertexBuffer.UV2Kind
  20214. * - BABYLON.VertexBuffer.UV3Kind
  20215. * - BABYLON.VertexBuffer.UV4Kind
  20216. * - BABYLON.VertexBuffer.UV5Kind
  20217. * - BABYLON.VertexBuffer.UV6Kind
  20218. * - BABYLON.VertexBuffer.ColorKind
  20219. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20220. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20221. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20222. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20223. *
  20224. * Returns the Mesh.
  20225. */
  20226. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20227. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20228. /**
  20229. * Sets the mesh VertexBuffer.
  20230. * Returns the Mesh.
  20231. */
  20232. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20233. /**
  20234. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20235. * If the mesh has no geometry, it is simply returned as it is.
  20236. * The `data` are either a numeric array either a Float32Array.
  20237. * No new underlying VertexBuffer object is created.
  20238. * 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.
  20239. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20240. *
  20241. * Possible `kind` values :
  20242. * - BABYLON.VertexBuffer.PositionKind
  20243. * - BABYLON.VertexBuffer.UVKind
  20244. * - BABYLON.VertexBuffer.UV2Kind
  20245. * - BABYLON.VertexBuffer.UV3Kind
  20246. * - BABYLON.VertexBuffer.UV4Kind
  20247. * - BABYLON.VertexBuffer.UV5Kind
  20248. * - BABYLON.VertexBuffer.UV6Kind
  20249. * - BABYLON.VertexBuffer.ColorKind
  20250. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20251. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20252. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20253. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20254. *
  20255. * Returns the Mesh.
  20256. */
  20257. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20258. /**
  20259. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20260. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20261. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20262. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20263. * Returns the Mesh.
  20264. */
  20265. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20266. /**
  20267. * Creates a un-shared specific occurence of the geometry for the mesh.
  20268. * Returns the Mesh.
  20269. */
  20270. makeGeometryUnique(): Mesh;
  20271. /**
  20272. * Sets the mesh indices.
  20273. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20274. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  20275. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20276. * This method creates a new index buffer each call.
  20277. * Returns the Mesh.
  20278. */
  20279. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20280. /**
  20281. * Update the current index buffer
  20282. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20283. * Returns the Mesh.
  20284. */
  20285. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20286. /**
  20287. * Invert the geometry to move from a right handed system to a left handed one.
  20288. * Returns the Mesh.
  20289. */
  20290. toLeftHanded(): Mesh;
  20291. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20292. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20293. /**
  20294. * Registers for this mesh a javascript function called just before the rendering process.
  20295. * This function is passed the current mesh.
  20296. * Return the Mesh.
  20297. */
  20298. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20299. /**
  20300. * Disposes a previously registered javascript function called before the rendering.
  20301. * This function is passed the current mesh.
  20302. * Returns the Mesh.
  20303. */
  20304. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20305. /**
  20306. * Registers for this mesh a javascript function called just after the rendering is complete.
  20307. * This function is passed the current mesh.
  20308. * Returns the Mesh.
  20309. */
  20310. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20311. /**
  20312. * Disposes a previously registered javascript function called after the rendering.
  20313. * This function is passed the current mesh.
  20314. * Return the Mesh.
  20315. */
  20316. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20317. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20318. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20319. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20320. /**
  20321. * Triggers the draw call for the mesh.
  20322. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20323. * Returns the Mesh.
  20324. */
  20325. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20326. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20327. /**
  20328. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20329. */
  20330. getEmittedParticleSystems(): IParticleSystem[];
  20331. /**
  20332. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20333. */
  20334. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20335. _checkDelayState(): Mesh;
  20336. private _queueLoad(scene);
  20337. /**
  20338. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20339. */
  20340. isInFrustum(frustumPlanes: Plane[]): boolean;
  20341. /**
  20342. * Sets the mesh material by the material or multiMaterial `id` property.
  20343. * The material `id` is a string identifying the material or the multiMaterial.
  20344. * This method returns the Mesh.
  20345. */
  20346. setMaterialByID(id: string): Mesh;
  20347. /**
  20348. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20349. */
  20350. getAnimatables(): IAnimatable[];
  20351. /**
  20352. * Modifies the mesh geometry according to the passed transformation matrix.
  20353. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20354. * The mesh normals are modified accordingly the same transformation.
  20355. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  20356. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20357. * Returns the Mesh.
  20358. */
  20359. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20360. /**
  20361. * Modifies the mesh geometry according to its own current World Matrix.
  20362. * The mesh World Matrix is then reset.
  20363. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20364. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20365. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20366. * Returns the Mesh.
  20367. */
  20368. bakeCurrentTransformIntoVertices(): Mesh;
  20369. readonly _positions: Nullable<Vector3[]>;
  20370. _resetPointsArrayCache(): Mesh;
  20371. _generatePointsArray(): boolean;
  20372. /**
  20373. * Returns a new Mesh object generated from the current mesh properties.
  20374. * This method must not get confused with createInstance().
  20375. * The parameter `name` is a string, the name given to the new mesh.
  20376. * The optional parameter `newParent` can be any Node object (default `null`).
  20377. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20378. * 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.
  20379. */
  20380. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20381. /**
  20382. * Releases resources associated with this mesh.
  20383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20385. */
  20386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20387. /**
  20388. * Modifies the mesh geometry according to a displacement map.
  20389. * 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.
  20390. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20391. * This method returns nothing.
  20392. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20393. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20394. * 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.
  20395. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20396. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20397. *
  20398. * Returns the Mesh.
  20399. */
  20400. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20401. /**
  20402. * Modifies the mesh geometry according to a displacementMap buffer.
  20403. * 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.
  20404. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20405. * This method returns nothing.
  20406. * 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.
  20407. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20408. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20409. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20410. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20411. *
  20412. * Returns the Mesh.
  20413. */
  20414. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20415. /**
  20416. * Modify the mesh to get a flat shading rendering.
  20417. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20418. * This method returns the Mesh.
  20419. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20420. */
  20421. convertToFlatShadedMesh(): Mesh;
  20422. /**
  20423. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20424. * In other words, more vertices, no more indices and a single bigger VBO.
  20425. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20426. * Returns the Mesh.
  20427. */
  20428. convertToUnIndexedMesh(): Mesh;
  20429. /**
  20430. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20431. * This method returns the Mesh.
  20432. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20433. */
  20434. flipFaces(flipNormals?: boolean): Mesh;
  20435. /**
  20436. * Creates a new InstancedMesh object from the mesh model.
  20437. * An instance shares the same properties and the same material than its model.
  20438. * Only these properties of each instance can then be set individually :
  20439. * - position
  20440. * - rotation
  20441. * - rotationQuaternion
  20442. * - setPivotMatrix
  20443. * - scaling
  20444. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20445. * Warning : this method is not supported for Line mesh and LineSystem
  20446. */
  20447. createInstance(name: string): InstancedMesh;
  20448. /**
  20449. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20450. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20451. * This method returns the Mesh.
  20452. */
  20453. synchronizeInstances(): Mesh;
  20454. /**
  20455. * Simplify the mesh according to the given array of settings.
  20456. * Function will return immediately and will simplify async. It returns the Mesh.
  20457. * @param settings a collection of simplification settings.
  20458. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20459. * @param type the type of simplification to run.
  20460. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20461. */
  20462. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20463. /**
  20464. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20465. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20466. * This should be used together with the simplification to avoid disappearing triangles.
  20467. * Returns the Mesh.
  20468. * @param successCallback an optional success callback to be called after the optimization finished.
  20469. */
  20470. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20471. serialize(serializationObject: any): void;
  20472. _syncGeometryWithMorphTargetManager(): void;
  20473. /**
  20474. * Returns a new Mesh object parsed from the source provided.
  20475. * The parameter `parsedMesh` is the source.
  20476. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20477. */
  20478. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20479. /**
  20480. * Creates a ribbon mesh.
  20481. * Please consider using the same method from the MeshBuilder class instead.
  20482. * 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.
  20483. *
  20484. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20485. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20486. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20487. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20488. * 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.
  20489. * 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.
  20490. * 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
  20491. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20492. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20493. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20494. */
  20495. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20496. /**
  20497. * Creates a plane polygonal mesh. By default, this is a disc.
  20498. * Please consider using the same method from the MeshBuilder class instead.
  20499. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20500. * 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.
  20501. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20502. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20503. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20504. */
  20505. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20506. /**
  20507. * Creates a box mesh.
  20508. * Please consider using the same method from the MeshBuilder class instead.
  20509. * The parameter `size` sets the size (float) of each box side (default 1).
  20510. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20511. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20512. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20513. */
  20514. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20515. /**
  20516. * Creates a sphere mesh.
  20517. * Please consider using the same method from the MeshBuilder class instead.
  20518. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20519. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20520. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20521. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20522. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20523. */
  20524. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20525. /**
  20526. * Creates a cylinder or a cone mesh.
  20527. * Please consider using the same method from the MeshBuilder class instead.
  20528. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20529. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20530. * 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.
  20531. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20532. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20533. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20534. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20535. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20536. */
  20537. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20538. /**
  20539. * Creates a torus mesh.
  20540. * Please consider using the same method from the MeshBuilder class instead.
  20541. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20542. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20543. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20544. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20545. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20546. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20547. */
  20548. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20549. /**
  20550. * Creates a torus knot mesh.
  20551. * Please consider using the same method from the MeshBuilder class instead.
  20552. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20553. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20554. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20555. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20556. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20557. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20558. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20559. */
  20560. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20561. /**
  20562. * Creates a line mesh.
  20563. * Please consider using the same method from the MeshBuilder class instead.
  20564. * 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.
  20565. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20566. * The parameter `points` is an array successive Vector3.
  20567. * 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
  20568. * When updating an instance, remember that only point positions can change, not the number of points.
  20569. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20570. */
  20571. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20572. /**
  20573. * Creates a dashed line mesh.
  20574. * Please consider using the same method from the MeshBuilder class instead.
  20575. * 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.
  20576. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20577. * The parameter `points` is an array successive Vector3.
  20578. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20579. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20580. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20581. * 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
  20582. * When updating an instance, remember that only point positions can change, not the number of points.
  20583. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20584. */
  20585. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20586. /**
  20587. * Creates a polygon mesh.
  20588. * Please consider using the same method from the MeshBuilder class instead.
  20589. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20590. * 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.
  20591. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20592. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20593. * Remember you can only change the shape positions, not their number when updating a polygon.
  20594. */
  20595. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20596. /**
  20597. * Creates an extruded polygon mesh, with depth in the Y direction.
  20598. * Please consider using the same method from the MeshBuilder class instead.
  20599. */
  20600. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20601. /**
  20602. * Creates an extruded shape mesh.
  20603. * 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.
  20604. * Please consider using the same method from the MeshBuilder class instead.
  20605. *
  20606. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  20607. * 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
  20608. * extruded along the Z axis.
  20609. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20610. * 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.
  20611. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20612. * 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
  20613. * 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
  20614. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20615. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20616. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20617. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20618. */
  20619. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20620. /**
  20621. * Creates an custom extruded shape mesh.
  20622. * 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.
  20623. * Please consider using the same method from the MeshBuilder class instead.
  20624. *
  20625. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  20626. * 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
  20627. * extruded along the Z axis.
  20628. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20629. * 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
  20630. * and the distance of this point from the begining of the path :
  20631. * ```javascript
  20632. * var rotationFunction = function(i, distance) {
  20633. * // do things
  20634. * return rotationValue; }
  20635. * ```
  20636. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20637. * 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
  20638. * and the distance of this point from the begining of the path :
  20639. * ```javascript
  20640. * var scaleFunction = function(i, distance) {
  20641. * // do things
  20642. * return scaleValue;}
  20643. * ```
  20644. * It must returns a float value that will be the scale value applied to the shape on each path point.
  20645. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  20646. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  20647. * 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
  20648. * 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
  20649. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20650. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20651. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20652. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20653. */
  20654. 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;
  20655. /**
  20656. * Creates lathe mesh.
  20657. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20658. * Please consider using the same method from the MeshBuilder class instead.
  20659. * 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
  20660. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  20661. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  20662. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  20663. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20664. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20665. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20666. */
  20667. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20668. /**
  20669. * Creates a plane mesh.
  20670. * Please consider using the same method from the MeshBuilder class instead.
  20671. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  20672. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20673. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20674. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20675. */
  20676. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20677. /**
  20678. * Creates a ground mesh.
  20679. * Please consider using the same method from the MeshBuilder class instead.
  20680. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  20681. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  20682. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20683. */
  20684. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20685. /**
  20686. * Creates a tiled ground mesh.
  20687. * Please consider using the same method from the MeshBuilder class instead.
  20688. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  20689. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  20690. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  20691. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  20692. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  20693. * numbers of subdivisions on the ground width and height of each tile.
  20694. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20695. */
  20696. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20697. w: number;
  20698. h: number;
  20699. }, precision: {
  20700. w: number;
  20701. h: number;
  20702. }, scene: Scene, updatable?: boolean): Mesh;
  20703. /**
  20704. * Creates a ground mesh from a height map.
  20705. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  20706. * Please consider using the same method from the MeshBuilder class instead.
  20707. * The parameter `url` sets the URL of the height map image resource.
  20708. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20709. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20710. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20711. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20712. * 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).
  20713. * This function is passed the newly built mesh :
  20714. * ```javascript
  20715. * function(mesh) { // do things
  20716. * return; }
  20717. * ```
  20718. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20719. */
  20720. 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;
  20721. /**
  20722. * Creates a tube mesh.
  20723. * 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.
  20724. * Please consider using the same method from the MeshBuilder class instead.
  20725. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  20726. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  20727. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  20728. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  20729. * 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.
  20730. * It must return a radius value (positive float) :
  20731. * ```javascript
  20732. * var radiusFunction = function(i, distance) {
  20733. * // do things
  20734. * return radius; }
  20735. * ```
  20736. * 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
  20737. * 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
  20738. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20739. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20740. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20741. */
  20742. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20743. (i: number, distance: number): number;
  20744. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20745. /**
  20746. * Creates a polyhedron mesh.
  20747. * Please consider using the same method from the MeshBuilder class instead.
  20748. * 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
  20749. * to choose the wanted type.
  20750. * The parameter `size` (positive float, default 1) sets the polygon size.
  20751. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  20752. * 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`.
  20753. * 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
  20754. * 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)`).
  20755. * 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
  20756. * 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.
  20757. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20758. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20759. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20760. */
  20761. static CreatePolyhedron(name: string, options: {
  20762. type?: number;
  20763. size?: number;
  20764. sizeX?: number;
  20765. sizeY?: number;
  20766. sizeZ?: number;
  20767. custom?: any;
  20768. faceUV?: Vector4[];
  20769. faceColors?: Color4[];
  20770. updatable?: boolean;
  20771. sideOrientation?: number;
  20772. }, scene: Scene): Mesh;
  20773. /**
  20774. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  20775. * Please consider using the same method from the MeshBuilder class instead.
  20776. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  20777. * 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`).
  20778. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  20779. * 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.
  20780. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20781. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  20782. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20783. */
  20784. static CreateIcoSphere(name: string, options: {
  20785. radius?: number;
  20786. flat?: boolean;
  20787. subdivisions?: number;
  20788. sideOrientation?: number;
  20789. updatable?: boolean;
  20790. }, scene: Scene): Mesh;
  20791. /**
  20792. * Creates a decal mesh.
  20793. * Please consider using the same method from the MeshBuilder class instead.
  20794. * 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.
  20795. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  20796. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  20797. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  20798. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  20799. */
  20800. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20801. /**
  20802. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20803. */
  20804. setPositionsForCPUSkinning(): Float32Array;
  20805. /**
  20806. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20807. */
  20808. setNormalsForCPUSkinning(): Float32Array;
  20809. /**
  20810. * Updates the vertex buffer by applying transformation from the bones.
  20811. * Returns the Mesh.
  20812. *
  20813. * @param {skeleton} skeleton to apply
  20814. */
  20815. applySkeleton(skeleton: Skeleton): Mesh;
  20816. /**
  20817. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  20818. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  20819. */
  20820. static MinMax(meshes: AbstractMesh[]): {
  20821. min: Vector3;
  20822. max: Vector3;
  20823. };
  20824. /**
  20825. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  20826. */
  20827. static Center(meshesOrMinMaxVector: {
  20828. min: Vector3;
  20829. max: Vector3;
  20830. } | AbstractMesh[]): Vector3;
  20831. /**
  20832. * Merge the array of meshes into a single mesh for performance reasons.
  20833. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  20834. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  20835. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  20836. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20837. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  20838. */
  20839. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20840. }
  20841. }
  20842. declare module BABYLON {
  20843. interface IGetSetVerticesData {
  20844. isVerticesDataPresent(kind: string): boolean;
  20845. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20846. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20847. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20848. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20849. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20850. }
  20851. class VertexData {
  20852. positions: Nullable<FloatArray>;
  20853. normals: Nullable<FloatArray>;
  20854. tangents: Nullable<FloatArray>;
  20855. uvs: Nullable<FloatArray>;
  20856. uvs2: Nullable<FloatArray>;
  20857. uvs3: Nullable<FloatArray>;
  20858. uvs4: Nullable<FloatArray>;
  20859. uvs5: Nullable<FloatArray>;
  20860. uvs6: Nullable<FloatArray>;
  20861. colors: Nullable<FloatArray>;
  20862. matricesIndices: Nullable<FloatArray>;
  20863. matricesWeights: Nullable<FloatArray>;
  20864. matricesIndicesExtra: Nullable<FloatArray>;
  20865. matricesWeightsExtra: Nullable<FloatArray>;
  20866. indices: Nullable<IndicesArray>;
  20867. set(data: FloatArray, kind: string): void;
  20868. /**
  20869. * Associates the vertexData to the passed Mesh.
  20870. * Sets it as updatable or not (default `false`).
  20871. * Returns the VertexData.
  20872. */
  20873. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20874. /**
  20875. * Associates the vertexData to the passed Geometry.
  20876. * Sets it as updatable or not (default `false`).
  20877. * Returns the VertexData.
  20878. */
  20879. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20880. /**
  20881. * Updates the associated mesh.
  20882. * Returns the VertexData.
  20883. */
  20884. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20885. /**
  20886. * Updates the associated geometry.
  20887. * Returns the VertexData.
  20888. */
  20889. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20890. private _applyTo(meshOrGeometry, updatable?);
  20891. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  20892. /**
  20893. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  20894. * Returns the VertexData.
  20895. */
  20896. transform(matrix: Matrix): VertexData;
  20897. /**
  20898. * Merges the passed VertexData into the current one.
  20899. * Returns the modified VertexData.
  20900. */
  20901. merge(other: VertexData): VertexData;
  20902. private _mergeElement(source, other);
  20903. private _validate();
  20904. /**
  20905. * Serializes the VertexData.
  20906. * Returns a serialized object.
  20907. */
  20908. serialize(): any;
  20909. /**
  20910. * Returns the object VertexData associated to the passed mesh.
  20911. */
  20912. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20913. /**
  20914. * Returns the object VertexData associated to the passed geometry.
  20915. */
  20916. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20917. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  20918. /**
  20919. * Creates the vertexData of the Ribbon.
  20920. */
  20921. static CreateRibbon(options: {
  20922. pathArray: Vector3[][];
  20923. closeArray?: boolean;
  20924. closePath?: boolean;
  20925. offset?: number;
  20926. sideOrientation?: number;
  20927. frontUVs?: Vector4;
  20928. backUVs?: Vector4;
  20929. invertUV?: boolean;
  20930. uvs?: Vector2[];
  20931. colors?: Color4[];
  20932. }): VertexData;
  20933. /**
  20934. * Creates the VertexData of the Box.
  20935. */
  20936. static CreateBox(options: {
  20937. size?: number;
  20938. width?: number;
  20939. height?: number;
  20940. depth?: number;
  20941. faceUV?: Vector4[];
  20942. faceColors?: Color4[];
  20943. sideOrientation?: number;
  20944. frontUVs?: Vector4;
  20945. backUVs?: Vector4;
  20946. }): VertexData;
  20947. /**
  20948. * Creates the VertexData of the Sphere.
  20949. */
  20950. static CreateSphere(options: {
  20951. segments?: number;
  20952. diameter?: number;
  20953. diameterX?: number;
  20954. diameterY?: number;
  20955. diameterZ?: number;
  20956. arc?: number;
  20957. slice?: number;
  20958. sideOrientation?: number;
  20959. frontUVs?: Vector4;
  20960. backUVs?: Vector4;
  20961. }): VertexData;
  20962. /**
  20963. * Creates the VertexData of the Cylinder or Cone.
  20964. */
  20965. static CreateCylinder(options: {
  20966. height?: number;
  20967. diameterTop?: number;
  20968. diameterBottom?: number;
  20969. diameter?: number;
  20970. tessellation?: number;
  20971. subdivisions?: number;
  20972. arc?: number;
  20973. faceColors?: Color4[];
  20974. faceUV?: Vector4[];
  20975. hasRings?: boolean;
  20976. enclose?: boolean;
  20977. sideOrientation?: number;
  20978. frontUVs?: Vector4;
  20979. backUVs?: Vector4;
  20980. }): VertexData;
  20981. /**
  20982. * Creates the VertexData of the Torus.
  20983. */
  20984. static CreateTorus(options: {
  20985. diameter?: number;
  20986. thickness?: number;
  20987. tessellation?: number;
  20988. sideOrientation?: number;
  20989. frontUVs?: Vector4;
  20990. backUVs?: Vector4;
  20991. }): VertexData;
  20992. /**
  20993. * Creates the VertexData of the LineSystem.
  20994. */
  20995. static CreateLineSystem(options: {
  20996. lines: Vector3[][];
  20997. colors?: Nullable<Color4[][]>;
  20998. }): VertexData;
  20999. /**
  21000. * Create the VertexData of the DashedLines.
  21001. */
  21002. static CreateDashedLines(options: {
  21003. points: Vector3[];
  21004. dashSize?: number;
  21005. gapSize?: number;
  21006. dashNb?: number;
  21007. }): VertexData;
  21008. /**
  21009. * Creates the VertexData of the Ground.
  21010. */
  21011. static CreateGround(options: {
  21012. width?: number;
  21013. height?: number;
  21014. subdivisions?: number;
  21015. subdivisionsX?: number;
  21016. subdivisionsY?: number;
  21017. }): VertexData;
  21018. /**
  21019. * Creates the VertexData of the TiledGround.
  21020. */
  21021. static CreateTiledGround(options: {
  21022. xmin: number;
  21023. zmin: number;
  21024. xmax: number;
  21025. zmax: number;
  21026. subdivisions?: {
  21027. w: number;
  21028. h: number;
  21029. };
  21030. precision?: {
  21031. w: number;
  21032. h: number;
  21033. };
  21034. }): VertexData;
  21035. /**
  21036. * Creates the VertexData of the Ground designed from a heightmap.
  21037. */
  21038. static CreateGroundFromHeightMap(options: {
  21039. width: number;
  21040. height: number;
  21041. subdivisions: number;
  21042. minHeight: number;
  21043. maxHeight: number;
  21044. colorFilter: Color3;
  21045. buffer: Uint8Array;
  21046. bufferWidth: number;
  21047. bufferHeight: number;
  21048. }): VertexData;
  21049. /**
  21050. * Creates the VertexData of the Plane.
  21051. */
  21052. static CreatePlane(options: {
  21053. size?: number;
  21054. width?: number;
  21055. height?: number;
  21056. sideOrientation?: number;
  21057. frontUVs?: Vector4;
  21058. backUVs?: Vector4;
  21059. }): VertexData;
  21060. /**
  21061. * Creates the VertexData of the Disc or regular Polygon.
  21062. */
  21063. static CreateDisc(options: {
  21064. radius?: number;
  21065. tessellation?: number;
  21066. arc?: number;
  21067. sideOrientation?: number;
  21068. frontUVs?: Vector4;
  21069. backUVs?: Vector4;
  21070. }): VertexData;
  21071. /**
  21072. * Re-creates the VertexData of the Polygon for sideOrientation.
  21073. */
  21074. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21075. /**
  21076. * Creates the VertexData of the IcoSphere.
  21077. */
  21078. static CreateIcoSphere(options: {
  21079. radius?: number;
  21080. radiusX?: number;
  21081. radiusY?: number;
  21082. radiusZ?: number;
  21083. flat?: boolean;
  21084. subdivisions?: number;
  21085. sideOrientation?: number;
  21086. frontUVs?: Vector4;
  21087. backUVs?: Vector4;
  21088. }): VertexData;
  21089. /**
  21090. * Creates the VertexData of the Polyhedron.
  21091. */
  21092. static CreatePolyhedron(options: {
  21093. type?: number;
  21094. size?: number;
  21095. sizeX?: number;
  21096. sizeY?: number;
  21097. sizeZ?: number;
  21098. custom?: any;
  21099. faceUV?: Vector4[];
  21100. faceColors?: Color4[];
  21101. flat?: boolean;
  21102. sideOrientation?: number;
  21103. frontUVs?: Vector4;
  21104. backUVs?: Vector4;
  21105. }): VertexData;
  21106. /**
  21107. * Creates the VertexData of the Torus Knot.
  21108. */
  21109. static CreateTorusKnot(options: {
  21110. radius?: number;
  21111. tube?: number;
  21112. radialSegments?: number;
  21113. tubularSegments?: number;
  21114. p?: number;
  21115. q?: number;
  21116. sideOrientation?: number;
  21117. frontUVs?: Vector4;
  21118. backUVs?: Vector4;
  21119. }): VertexData;
  21120. /**
  21121. * @param {any} - positions (number[] or Float32Array)
  21122. * @param {any} - indices (number[] or Uint16Array)
  21123. * @param {any} - normals (number[] or Float32Array)
  21124. * options (optional) :
  21125. * facetPositions : optional array of facet positions (vector3)
  21126. * facetNormals : optional array of facet normals (vector3)
  21127. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21128. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21129. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21130. * bbSize : optional bounding box size data, required for facetPartitioning computation
  21131. * bInfo : optional bounding info, required for facetPartitioning computation
  21132. * useRightHandedSystem: optional boolean to for right handed system computation
  21133. * depthSort : optional boolean to enable the facet depth sort computation
  21134. * distanceTo : optional Vector3 to compute the facet depth from this location
  21135. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21136. */
  21137. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21138. facetNormals?: any;
  21139. facetPositions?: any;
  21140. facetPartitioning?: any;
  21141. ratio?: number;
  21142. bInfo?: any;
  21143. bbSize?: Vector3;
  21144. subDiv?: any;
  21145. useRightHandedSystem?: boolean;
  21146. depthSort?: boolean;
  21147. distanceTo?: Vector3;
  21148. depthSortedFacets?: any;
  21149. }): void;
  21150. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21151. /**
  21152. * Creates a new VertexData from the imported parameters.
  21153. */
  21154. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. class MeshBuilder {
  21159. private static updateSideOrientation(orientation?);
  21160. /**
  21161. * Creates a box mesh.
  21162. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21163. * The parameter `size` sets the size (float) of each box side (default 1).
  21164. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  21165. * 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).
  21166. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21167. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21168. * 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).
  21169. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21170. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21171. */
  21172. static CreateBox(name: string, options: {
  21173. size?: number;
  21174. width?: number;
  21175. height?: number;
  21176. depth?: number;
  21177. faceUV?: Vector4[];
  21178. faceColors?: Color4[];
  21179. sideOrientation?: number;
  21180. frontUVs?: Vector4;
  21181. backUVs?: Vector4;
  21182. updatable?: boolean;
  21183. }, scene?: Nullable<Scene>): Mesh;
  21184. /**
  21185. * Creates a sphere mesh.
  21186. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21187. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21188. * 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`).
  21189. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21190. * 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
  21191. * 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).
  21192. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21193. * 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).
  21194. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21195. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21196. */
  21197. static CreateSphere(name: string, options: {
  21198. segments?: number;
  21199. diameter?: number;
  21200. diameterX?: number;
  21201. diameterY?: number;
  21202. diameterZ?: number;
  21203. arc?: number;
  21204. slice?: number;
  21205. sideOrientation?: number;
  21206. frontUVs?: Vector4;
  21207. backUVs?: Vector4;
  21208. updatable?: boolean;
  21209. }, scene: any): Mesh;
  21210. /**
  21211. * Creates a plane polygonal mesh. By default, this is a disc.
  21212. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  21213. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21214. * 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.
  21215. * 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
  21216. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21217. * 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).
  21218. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21219. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21220. */
  21221. static CreateDisc(name: string, options: {
  21222. radius?: number;
  21223. tessellation?: number;
  21224. arc?: number;
  21225. updatable?: boolean;
  21226. sideOrientation?: number;
  21227. frontUVs?: Vector4;
  21228. backUVs?: Vector4;
  21229. }, scene?: Nullable<Scene>): Mesh;
  21230. /**
  21231. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21232. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  21233. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21234. * 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`).
  21235. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21236. * 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.
  21237. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21238. * 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).
  21239. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21240. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21241. */
  21242. static CreateIcoSphere(name: string, options: {
  21243. radius?: number;
  21244. radiusX?: number;
  21245. radiusY?: number;
  21246. radiusZ?: number;
  21247. flat?: boolean;
  21248. subdivisions?: number;
  21249. sideOrientation?: number;
  21250. frontUVs?: Vector4;
  21251. backUVs?: Vector4;
  21252. updatable?: boolean;
  21253. }, scene: Scene): Mesh;
  21254. /**
  21255. * Creates a ribbon mesh.
  21256. * 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.
  21257. *
  21258. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21259. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21260. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21261. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21262. * 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.
  21263. * 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.
  21264. * 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
  21265. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21266. * 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).
  21267. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21268. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21269. * 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.
  21270. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  21271. * 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
  21272. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  21273. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  21274. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21275. */
  21276. static CreateRibbon(name: string, options: {
  21277. pathArray: Vector3[][];
  21278. closeArray?: boolean;
  21279. closePath?: boolean;
  21280. offset?: number;
  21281. updatable?: boolean;
  21282. sideOrientation?: number;
  21283. frontUVs?: Vector4;
  21284. backUVs?: Vector4;
  21285. instance?: Mesh;
  21286. invertUV?: boolean;
  21287. uvs?: Vector2[];
  21288. colors?: Color4[];
  21289. }, scene?: Nullable<Scene>): Mesh;
  21290. /**
  21291. * Creates a cylinder or a cone mesh.
  21292. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21293. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21294. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21295. * 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.
  21296. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21297. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21298. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21299. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21300. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21301. * 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).
  21302. * 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
  21303. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21304. * 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
  21305. * 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.
  21306. * If `enclose` is false, a ring surface is one element.
  21307. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21308. * 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
  21309. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21310. * 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).
  21311. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21312. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21313. */
  21314. static CreateCylinder(name: string, options: {
  21315. height?: number;
  21316. diameterTop?: number;
  21317. diameterBottom?: number;
  21318. diameter?: number;
  21319. tessellation?: number;
  21320. subdivisions?: number;
  21321. arc?: number;
  21322. faceColors?: Color4[];
  21323. faceUV?: Vector4[];
  21324. updatable?: boolean;
  21325. hasRings?: boolean;
  21326. enclose?: boolean;
  21327. sideOrientation?: number;
  21328. frontUVs?: Vector4;
  21329. backUVs?: Vector4;
  21330. }, scene: any): Mesh;
  21331. /**
  21332. * Creates a torus mesh.
  21333. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21334. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21335. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21336. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21337. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21338. * 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).
  21339. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21340. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21341. */
  21342. static CreateTorus(name: string, options: {
  21343. diameter?: number;
  21344. thickness?: number;
  21345. tessellation?: number;
  21346. updatable?: boolean;
  21347. sideOrientation?: number;
  21348. frontUVs?: Vector4;
  21349. backUVs?: Vector4;
  21350. }, scene: any): Mesh;
  21351. /**
  21352. * Creates a torus knot mesh.
  21353. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21354. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21355. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21356. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21357. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21358. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21359. * 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).
  21360. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21361. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21362. */
  21363. static CreateTorusKnot(name: string, options: {
  21364. radius?: number;
  21365. tube?: number;
  21366. radialSegments?: number;
  21367. tubularSegments?: number;
  21368. p?: number;
  21369. q?: number;
  21370. updatable?: boolean;
  21371. sideOrientation?: number;
  21372. frontUVs?: Vector4;
  21373. backUVs?: Vector4;
  21374. }, scene: any): Mesh;
  21375. /**
  21376. * Creates a line system mesh.
  21377. * A line system is a pool of many lines gathered in a single mesh.
  21378. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  21379. * 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.
  21380. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  21381. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  21382. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  21383. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  21384. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  21385. * 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
  21386. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  21387. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21388. */
  21389. static CreateLineSystem(name: string, options: {
  21390. lines: Vector3[][];
  21391. updatable: boolean;
  21392. instance: Nullable<LinesMesh>;
  21393. colors?: Nullable<Color4[][]>;
  21394. useVertexAlpha?: boolean;
  21395. }, scene: Nullable<Scene>): LinesMesh;
  21396. /**
  21397. * Creates a line mesh.
  21398. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  21399. * 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.
  21400. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21401. * The parameter `points` is an array successive Vector3.
  21402. * 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
  21403. * The optional parameter `colors` is an array of successive Color4, one per line point.
  21404. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  21405. * When updating an instance, remember that only point positions can change, not the number of points.
  21406. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21407. */
  21408. static CreateLines(name: string, options: {
  21409. points: Vector3[];
  21410. updatable: boolean;
  21411. instance: Nullable<LinesMesh>;
  21412. colors?: Color4[];
  21413. useVertexAlpha?: boolean;
  21414. }, scene?: Nullable<Scene>): LinesMesh;
  21415. /**
  21416. * Creates a dashed line mesh.
  21417. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  21418. * 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.
  21419. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21420. * The parameter `points` is an array successive Vector3.
  21421. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21422. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21423. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21424. * 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
  21425. * When updating an instance, remember that only point positions can change, not the number of points.
  21426. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21427. */
  21428. static CreateDashedLines(name: string, options: {
  21429. points: Vector3[];
  21430. dashSize?: number;
  21431. gapSize?: number;
  21432. dashNb?: number;
  21433. updatable?: boolean;
  21434. instance?: LinesMesh;
  21435. }, scene?: Nullable<Scene>): LinesMesh;
  21436. /**
  21437. * Creates an extruded shape mesh.
  21438. * 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.
  21439. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  21440. *
  21441. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  21442. * 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
  21443. * extruded along the Z axis.
  21444. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21445. * 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.
  21446. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21447. * 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
  21448. * 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
  21449. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21450. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21451. * 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).
  21452. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21453. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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 ExtrudeShape(name: string, options: {
  21457. shape: Vector3[];
  21458. path: Vector3[];
  21459. scale?: number;
  21460. rotation?: number;
  21461. cap?: number;
  21462. updatable?: boolean;
  21463. sideOrientation?: number;
  21464. frontUVs?: Vector4;
  21465. backUVs?: Vector4;
  21466. instance?: Mesh;
  21467. invertUV?: boolean;
  21468. }, scene?: Nullable<Scene>): Mesh;
  21469. /**
  21470. * Creates an custom extruded shape mesh.
  21471. * 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.
  21472. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  21473. *
  21474. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  21475. * 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
  21476. * extruded along the Z axis.
  21477. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21478. * 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
  21479. * and the distance of this point from the begining of the path :
  21480. * ```javascript
  21481. * var rotationFunction = function(i, distance) {
  21482. * // do things
  21483. * return rotationValue; }
  21484. * ```
  21485. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21486. * 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
  21487. * and the distance of this point from the begining of the path :
  21488. * ```javascript
  21489. * var scaleFunction = function(i, distance) {
  21490. * // do things
  21491. * return scaleValue;}
  21492. * ```
  21493. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21494. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21495. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21496. * 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
  21497. * 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
  21498. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21499. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21500. * 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).
  21501. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21502. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21503. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21504. */
  21505. static ExtrudeShapeCustom(name: string, options: {
  21506. shape: Vector3[];
  21507. path: Vector3[];
  21508. scaleFunction?: any;
  21509. rotationFunction?: any;
  21510. ribbonCloseArray?: boolean;
  21511. ribbonClosePath?: boolean;
  21512. cap?: number;
  21513. updatable?: boolean;
  21514. sideOrientation?: number;
  21515. frontUVs?: Vector4;
  21516. backUVs?: Vector4;
  21517. instance?: Mesh;
  21518. invertUV?: boolean;
  21519. }, scene: Scene): Mesh;
  21520. /**
  21521. * Creates lathe mesh.
  21522. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21523. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  21524. *
  21525. * 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
  21526. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21527. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21528. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21529. * 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.
  21530. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  21531. * 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
  21532. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21533. * 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).
  21534. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21535. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21536. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21537. */
  21538. static CreateLathe(name: string, options: {
  21539. shape: Vector3[];
  21540. radius?: number;
  21541. tessellation?: number;
  21542. arc?: number;
  21543. closed?: boolean;
  21544. updatable?: boolean;
  21545. sideOrientation?: number;
  21546. frontUVs?: Vector4;
  21547. backUVs?: Vector4;
  21548. cap?: number;
  21549. invertUV?: boolean;
  21550. }, scene: Scene): Mesh;
  21551. /**
  21552. * Creates a plane mesh.
  21553. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21554. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21555. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  21556. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  21557. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21558. * 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).
  21559. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21560. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21561. */
  21562. static CreatePlane(name: string, options: {
  21563. size?: number;
  21564. width?: number;
  21565. height?: number;
  21566. sideOrientation?: number;
  21567. frontUVs?: Vector4;
  21568. backUVs?: Vector4;
  21569. updatable?: boolean;
  21570. sourcePlane?: Plane;
  21571. }, scene: Scene): Mesh;
  21572. /**
  21573. * Creates a ground mesh.
  21574. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21575. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21576. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21577. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21578. */
  21579. static CreateGround(name: string, options: {
  21580. width?: number;
  21581. height?: number;
  21582. subdivisions?: number;
  21583. subdivisionsX?: number;
  21584. subdivisionsY?: number;
  21585. updatable?: boolean;
  21586. }, scene: any): Mesh;
  21587. /**
  21588. * Creates a tiled ground mesh.
  21589. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  21590. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21591. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21592. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21593. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21594. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21595. * numbers of subdivisions on the ground width and height of each tile.
  21596. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21597. */
  21598. static CreateTiledGround(name: string, options: {
  21599. xmin: number;
  21600. zmin: number;
  21601. xmax: number;
  21602. zmax: number;
  21603. subdivisions?: {
  21604. w: number;
  21605. h: number;
  21606. };
  21607. precision?: {
  21608. w: number;
  21609. h: number;
  21610. };
  21611. updatable?: boolean;
  21612. }, scene: Scene): Mesh;
  21613. /**
  21614. * Creates a ground mesh from a height map.
  21615. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  21616. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  21617. * The parameter `url` sets the URL of the height map image resource.
  21618. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21619. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21620. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21621. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21622. * 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.
  21623. * 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).
  21624. * This function is passed the newly built mesh :
  21625. * ```javascript
  21626. * function(mesh) { // do things
  21627. * return; }
  21628. * ```
  21629. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21630. */
  21631. static CreateGroundFromHeightMap(name: string, url: string, options: {
  21632. width?: number;
  21633. height?: number;
  21634. subdivisions?: number;
  21635. minHeight?: number;
  21636. maxHeight?: number;
  21637. colorFilter?: Color3;
  21638. updatable?: boolean;
  21639. onReady?: (mesh: GroundMesh) => void;
  21640. }, scene: Scene): GroundMesh;
  21641. /**
  21642. * Creates a polygon mesh.
  21643. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21644. * 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.
  21645. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21646. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21647. * 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).
  21648. * Remember you can only change the shape positions, not their number when updating a polygon.
  21649. */
  21650. static CreatePolygon(name: string, options: {
  21651. shape: Vector3[];
  21652. holes?: Vector3[][];
  21653. depth?: number;
  21654. faceUV?: Vector4[];
  21655. faceColors?: Color4[];
  21656. updatable?: boolean;
  21657. sideOrientation?: number;
  21658. frontUVs?: Vector4;
  21659. backUVs?: Vector4;
  21660. }, scene: Scene): Mesh;
  21661. /**
  21662. * Creates an extruded polygon mesh, with depth in the Y direction.
  21663. * 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).
  21664. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21665. */
  21666. static ExtrudePolygon(name: string, options: {
  21667. shape: Vector3[];
  21668. holes?: Vector3[][];
  21669. depth?: number;
  21670. faceUV?: Vector4[];
  21671. faceColors?: Color4[];
  21672. updatable?: boolean;
  21673. sideOrientation?: number;
  21674. frontUVs?: Vector4;
  21675. backUVs?: Vector4;
  21676. }, scene: Scene): Mesh;
  21677. /**
  21678. * Creates a tube mesh.
  21679. * 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.
  21680. *
  21681. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  21682. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21683. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21684. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21685. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21686. * 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.
  21687. * It must return a radius value (positive float) :
  21688. * ```javascript
  21689. * var radiusFunction = function(i, distance) {
  21690. * // do things
  21691. * return radius; }
  21692. * ```
  21693. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  21694. * 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
  21695. * 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
  21696. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21697. * 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).
  21698. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21699. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21700. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21701. */
  21702. static CreateTube(name: string, options: {
  21703. path: Vector3[];
  21704. radius?: number;
  21705. tessellation?: number;
  21706. radiusFunction?: {
  21707. (i: number, distance: number): number;
  21708. };
  21709. cap?: number;
  21710. arc?: number;
  21711. updatable?: boolean;
  21712. sideOrientation?: number;
  21713. frontUVs?: Vector4;
  21714. backUVs?: Vector4;
  21715. instance?: Mesh;
  21716. invertUV?: boolean;
  21717. }, scene: Scene): Mesh;
  21718. /**
  21719. * Creates a polyhedron mesh.
  21720. *
  21721. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  21722. * 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
  21723. * to choose the wanted type.
  21724. * The parameter `size` (positive float, default 1) sets the polygon size.
  21725. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21726. * 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`.
  21727. * 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
  21728. * 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)`).
  21729. * 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
  21730. * 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.
  21731. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21732. * 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).
  21733. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21734. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21735. */
  21736. static CreatePolyhedron(name: string, options: {
  21737. type?: number;
  21738. size?: number;
  21739. sizeX?: number;
  21740. sizeY?: number;
  21741. sizeZ?: number;
  21742. custom?: any;
  21743. faceUV?: Vector4[];
  21744. faceColors?: Color4[];
  21745. flat?: boolean;
  21746. updatable?: boolean;
  21747. sideOrientation?: number;
  21748. frontUVs?: Vector4;
  21749. backUVs?: Vector4;
  21750. }, scene: Scene): Mesh;
  21751. /**
  21752. * Creates a decal mesh.
  21753. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  21754. * 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.
  21755. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21756. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21757. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21758. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21759. */
  21760. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  21761. position?: Vector3;
  21762. normal?: Vector3;
  21763. size?: Vector3;
  21764. angle?: number;
  21765. }): Mesh;
  21766. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  21767. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  21768. }
  21769. }
  21770. declare module BABYLON {
  21771. <<<<<<< HEAD
  21772. class MultiMaterial extends Material {
  21773. private _subMaterials;
  21774. subMaterials: Nullable<Material>[];
  21775. constructor(name: string, scene: Scene);
  21776. private _hookArray(array);
  21777. getSubMaterial(index: number): Nullable<Material>;
  21778. getActiveTextures(): BaseTexture[];
  21779. getClassName(): string;
  21780. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21781. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21782. serialize(): any;
  21783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21784. =======
  21785. class MeshLODLevel {
  21786. distance: number;
  21787. mesh: Mesh;
  21788. constructor(distance: number, mesh: Mesh);
  21789. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  21790. }
  21791. }
  21792. declare module BABYLON {
  21793. <<<<<<< HEAD
  21794. class PushMaterial extends Material {
  21795. protected _activeEffect: Effect;
  21796. protected _normalMatrix: Matrix;
  21797. constructor(name: string, scene: Scene);
  21798. getEffect(): Effect;
  21799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21800. /**
  21801. * Binds the given world matrix to the active effect
  21802. *
  21803. * @param world the matrix to bind
  21804. */
  21805. bindOnlyWorldMatrix(world: Matrix): void;
  21806. /**
  21807. * Binds the given normal matrix to the active effect
  21808. *
  21809. * @param normalMatrix the matrix to bind
  21810. */
  21811. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21812. bind(world: Matrix, mesh?: Mesh): void;
  21813. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21814. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21815. =======
  21816. /**
  21817. * A simplifier interface for future simplification implementations.
  21818. */
  21819. interface ISimplifier {
  21820. /**
  21821. * Simplification of a given mesh according to the given settings.
  21822. * Since this requires computation, it is assumed that the function runs async.
  21823. * @param settings The settings of the simplification, including quality and distance
  21824. * @param successCallback A callback that will be called after the mesh was simplified.
  21825. * @param errorCallback in case of an error, this callback will be called. optional.
  21826. */
  21827. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  21828. }
  21829. /**
  21830. * Expected simplification settings.
  21831. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  21832. */
  21833. interface ISimplificationSettings {
  21834. quality: number;
  21835. distance: number;
  21836. optimizeMesh?: boolean;
  21837. }
  21838. class SimplificationSettings implements ISimplificationSettings {
  21839. quality: number;
  21840. distance: number;
  21841. optimizeMesh: boolean | undefined;
  21842. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  21843. }
  21844. interface ISimplificationTask {
  21845. settings: Array<ISimplificationSettings>;
  21846. simplificationType: SimplificationType;
  21847. mesh: Mesh;
  21848. successCallback?: () => void;
  21849. parallelProcessing: boolean;
  21850. }
  21851. class SimplificationQueue {
  21852. private _simplificationArray;
  21853. running: boolean;
  21854. constructor();
  21855. addTask(task: ISimplificationTask): void;
  21856. executeNext(): void;
  21857. runSimplification(task: ISimplificationTask): void;
  21858. private getSimplifier(task);
  21859. }
  21860. /**
  21861. * The implemented types of simplification.
  21862. * At the moment only Quadratic Error Decimation is implemented.
  21863. */
  21864. enum SimplificationType {
  21865. QUADRATIC = 0,
  21866. }
  21867. class DecimationTriangle {
  21868. vertices: Array<DecimationVertex>;
  21869. normal: Vector3;
  21870. error: Array<number>;
  21871. deleted: boolean;
  21872. isDirty: boolean;
  21873. borderFactor: number;
  21874. deletePending: boolean;
  21875. originalOffset: number;
  21876. constructor(vertices: Array<DecimationVertex>);
  21877. }
  21878. class DecimationVertex {
  21879. position: Vector3;
  21880. id: number;
  21881. q: QuadraticMatrix;
  21882. isBorder: boolean;
  21883. triangleStart: number;
  21884. triangleCount: number;
  21885. originalOffsets: Array<number>;
  21886. constructor(position: Vector3, id: number);
  21887. updatePosition(newPosition: Vector3): void;
  21888. }
  21889. class QuadraticMatrix {
  21890. data: Array<number>;
  21891. constructor(data?: Array<number>);
  21892. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  21893. addInPlace(matrix: QuadraticMatrix): void;
  21894. addArrayInPlace(data: Array<number>): void;
  21895. add(matrix: QuadraticMatrix): QuadraticMatrix;
  21896. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  21897. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  21898. }
  21899. class Reference {
  21900. vertexId: number;
  21901. triangleId: number;
  21902. constructor(vertexId: number, triangleId: number);
  21903. }
  21904. /**
  21905. * An implementation of the Quadratic Error simplification algorithm.
  21906. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  21907. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  21908. * @author RaananW
  21909. */
  21910. class QuadraticErrorSimplification implements ISimplifier {
  21911. private _mesh;
  21912. private triangles;
  21913. private vertices;
  21914. private references;
  21915. private _reconstructedMesh;
  21916. syncIterations: number;
  21917. aggressiveness: number;
  21918. decimationIterations: number;
  21919. boundingBoxEpsilon: number;
  21920. constructor(_mesh: Mesh);
  21921. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  21922. private runDecimation(settings, submeshIndex, successCallback);
  21923. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  21924. private init(callback);
  21925. private reconstructMesh(submeshIndex);
  21926. private initDecimatedMesh();
  21927. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  21928. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  21929. private identifyBorder();
  21930. private updateMesh(identifyBorders?);
  21931. private vertexError(q, point);
  21932. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  21933. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  21934. }
  21935. }
  21936. declare module BABYLON {
  21937. <<<<<<< HEAD
  21938. class ShaderMaterial extends Material {
  21939. private _shaderPath;
  21940. private _options;
  21941. private _textures;
  21942. private _textureArrays;
  21943. private _floats;
  21944. private _ints;
  21945. private _floatsArrays;
  21946. private _colors3;
  21947. private _colors3Arrays;
  21948. private _colors4;
  21949. private _vectors2;
  21950. private _vectors3;
  21951. private _vectors4;
  21952. private _matrices;
  21953. private _matrices3x3;
  21954. private _matrices2x2;
  21955. private _vectors2Arrays;
  21956. private _vectors3Arrays;
  21957. private _cachedWorldViewMatrix;
  21958. private _renderId;
  21959. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  21960. getClassName(): string;
  21961. needAlphaBlending(): boolean;
  21962. needAlphaTesting(): boolean;
  21963. private _checkUniform(uniformName);
  21964. setTexture(name: string, texture: Texture): ShaderMaterial;
  21965. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  21966. setFloat(name: string, value: number): ShaderMaterial;
  21967. setInt(name: string, value: number): ShaderMaterial;
  21968. setFloats(name: string, value: number[]): ShaderMaterial;
  21969. setColor3(name: string, value: Color3): ShaderMaterial;
  21970. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  21971. setColor4(name: string, value: Color4): ShaderMaterial;
  21972. setVector2(name: string, value: Vector2): ShaderMaterial;
  21973. setVector3(name: string, value: Vector3): ShaderMaterial;
  21974. setVector4(name: string, value: Vector4): ShaderMaterial;
  21975. setMatrix(name: string, value: Matrix): ShaderMaterial;
  21976. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  21977. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  21978. setArray2(name: string, value: number[]): ShaderMaterial;
  21979. setArray3(name: string, value: number[]): ShaderMaterial;
  21980. private _checkCache(scene, mesh?, useInstances?);
  21981. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21982. bindOnlyWorldMatrix(world: Matrix): void;
  21983. bind(world: Matrix, mesh?: Mesh): void;
  21984. getActiveTextures(): BaseTexture[];
  21985. hasTexture(texture: BaseTexture): boolean;
  21986. clone(name: string): ShaderMaterial;
  21987. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21988. serialize(): any;
  21989. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  21990. =======
  21991. class Polygon {
  21992. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  21993. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  21994. static Parse(input: string): Vector2[];
  21995. static StartingAt(x: number, y: number): Path2;
  21996. }
  21997. class PolygonMeshBuilder {
  21998. private _points;
  21999. private _outlinepoints;
  22000. private _holes;
  22001. private _name;
  22002. private _scene;
  22003. private _epoints;
  22004. private _eholes;
  22005. private _addToepoint(points);
  22006. constructor(name: string, contours: Path2, scene: Scene);
  22007. constructor(name: string, contours: Vector2[], scene: Scene);
  22008. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22009. build(updatable?: boolean, depth?: number): Mesh;
  22010. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22011. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  22012. }
  22013. }
  22014. declare module BABYLON {
  22015. <<<<<<< HEAD
  22016. /** @ignore */
  22017. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22018. MAINUV1: boolean;
  22019. MAINUV2: boolean;
  22020. DIFFUSE: boolean;
  22021. DIFFUSEDIRECTUV: number;
  22022. AMBIENT: boolean;
  22023. AMBIENTDIRECTUV: number;
  22024. OPACITY: boolean;
  22025. OPACITYDIRECTUV: number;
  22026. OPACITYRGB: boolean;
  22027. REFLECTION: boolean;
  22028. EMISSIVE: boolean;
  22029. EMISSIVEDIRECTUV: number;
  22030. SPECULAR: boolean;
  22031. SPECULARDIRECTUV: number;
  22032. BUMP: boolean;
  22033. BUMPDIRECTUV: number;
  22034. PARALLAX: boolean;
  22035. PARALLAXOCCLUSION: boolean;
  22036. SPECULAROVERALPHA: boolean;
  22037. CLIPPLANE: boolean;
  22038. ALPHATEST: boolean;
  22039. DEPTHPREPASS: boolean;
  22040. ALPHAFROMDIFFUSE: boolean;
  22041. POINTSIZE: boolean;
  22042. FOG: boolean;
  22043. SPECULARTERM: boolean;
  22044. DIFFUSEFRESNEL: boolean;
  22045. OPACITYFRESNEL: boolean;
  22046. REFLECTIONFRESNEL: boolean;
  22047. REFRACTIONFRESNEL: boolean;
  22048. EMISSIVEFRESNEL: boolean;
  22049. FRESNEL: boolean;
  22050. NORMAL: boolean;
  22051. UV1: boolean;
  22052. UV2: boolean;
  22053. VERTEXCOLOR: boolean;
  22054. VERTEXALPHA: boolean;
  22055. NUM_BONE_INFLUENCERS: number;
  22056. BonesPerMesh: number;
  22057. INSTANCES: boolean;
  22058. GLOSSINESS: boolean;
  22059. ROUGHNESS: boolean;
  22060. EMISSIVEASILLUMINATION: boolean;
  22061. LINKEMISSIVEWITHDIFFUSE: boolean;
  22062. REFLECTIONFRESNELFROMSPECULAR: boolean;
  22063. LIGHTMAP: boolean;
  22064. LIGHTMAPDIRECTUV: number;
  22065. OBJECTSPACE_NORMALMAP: boolean;
  22066. USELIGHTMAPASSHADOWMAP: boolean;
  22067. REFLECTIONMAP_3D: boolean;
  22068. REFLECTIONMAP_SPHERICAL: boolean;
  22069. REFLECTIONMAP_PLANAR: boolean;
  22070. REFLECTIONMAP_CUBIC: boolean;
  22071. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22072. REFLECTIONMAP_PROJECTION: boolean;
  22073. REFLECTIONMAP_SKYBOX: boolean;
  22074. REFLECTIONMAP_EXPLICIT: boolean;
  22075. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22076. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22077. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22078. INVERTCUBICMAP: boolean;
  22079. LOGARITHMICDEPTH: boolean;
  22080. REFRACTION: boolean;
  22081. REFRACTIONMAP_3D: boolean;
  22082. REFLECTIONOVERALPHA: boolean;
  22083. TWOSIDEDLIGHTING: boolean;
  22084. SHADOWFLOAT: boolean;
  22085. MORPHTARGETS: boolean;
  22086. MORPHTARGETS_NORMAL: boolean;
  22087. MORPHTARGETS_TANGENT: boolean;
  22088. NUM_MORPH_INFLUENCERS: number;
  22089. NONUNIFORMSCALING: boolean;
  22090. PREMULTIPLYALPHA: boolean;
  22091. IMAGEPROCESSING: boolean;
  22092. VIGNETTE: boolean;
  22093. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22094. VIGNETTEBLENDMODEOPAQUE: boolean;
  22095. TONEMAPPING: boolean;
  22096. CONTRAST: boolean;
  22097. COLORCURVES: boolean;
  22098. COLORGRADING: boolean;
  22099. COLORGRADING3D: boolean;
  22100. SAMPLER3DGREENDEPTH: boolean;
  22101. SAMPLER3DBGRMAP: boolean;
  22102. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22103. EXPOSURE: boolean;
  22104. GRAIN: boolean;
  22105. constructor();
  22106. setReflectionMode(modeToEnable: string): void;
  22107. }
  22108. class StandardMaterial extends PushMaterial {
  22109. private _diffuseTexture;
  22110. diffuseTexture: Nullable<BaseTexture>;
  22111. private _ambientTexture;
  22112. ambientTexture: Nullable<BaseTexture>;
  22113. private _opacityTexture;
  22114. opacityTexture: Nullable<BaseTexture>;
  22115. private _reflectionTexture;
  22116. reflectionTexture: Nullable<BaseTexture>;
  22117. private _emissiveTexture;
  22118. emissiveTexture: Nullable<BaseTexture>;
  22119. private _specularTexture;
  22120. specularTexture: Nullable<BaseTexture>;
  22121. private _bumpTexture;
  22122. bumpTexture: Nullable<BaseTexture>;
  22123. private _lightmapTexture;
  22124. lightmapTexture: Nullable<BaseTexture>;
  22125. private _refractionTexture;
  22126. refractionTexture: Nullable<BaseTexture>;
  22127. ambientColor: Color3;
  22128. diffuseColor: Color3;
  22129. specularColor: Color3;
  22130. emissiveColor: Color3;
  22131. specularPower: number;
  22132. private _useAlphaFromDiffuseTexture;
  22133. useAlphaFromDiffuseTexture: boolean;
  22134. private _useEmissiveAsIllumination;
  22135. useEmissiveAsIllumination: boolean;
  22136. private _linkEmissiveWithDiffuse;
  22137. linkEmissiveWithDiffuse: boolean;
  22138. private _useSpecularOverAlpha;
  22139. useSpecularOverAlpha: boolean;
  22140. private _useReflectionOverAlpha;
  22141. useReflectionOverAlpha: boolean;
  22142. private _disableLighting;
  22143. disableLighting: boolean;
  22144. private _useObjectSpaceNormalMap;
  22145. /**
  22146. * Allows using an object space normal map (instead of tangent space).
  22147. */
  22148. useObjectSpaceNormalMap: boolean;
  22149. private _useParallax;
  22150. useParallax: boolean;
  22151. private _useParallaxOcclusion;
  22152. useParallaxOcclusion: boolean;
  22153. parallaxScaleBias: number;
  22154. private _roughness;
  22155. roughness: number;
  22156. indexOfRefraction: number;
  22157. invertRefractionY: boolean;
  22158. private _useLightmapAsShadowmap;
  22159. useLightmapAsShadowmap: boolean;
  22160. private _diffuseFresnelParameters;
  22161. diffuseFresnelParameters: FresnelParameters;
  22162. private _opacityFresnelParameters;
  22163. opacityFresnelParameters: FresnelParameters;
  22164. private _reflectionFresnelParameters;
  22165. reflectionFresnelParameters: FresnelParameters;
  22166. private _refractionFresnelParameters;
  22167. refractionFresnelParameters: FresnelParameters;
  22168. private _emissiveFresnelParameters;
  22169. emissiveFresnelParameters: FresnelParameters;
  22170. private _useReflectionFresnelFromSpecular;
  22171. useReflectionFresnelFromSpecular: boolean;
  22172. private _useGlossinessFromSpecularMapAlpha;
  22173. useGlossinessFromSpecularMapAlpha: boolean;
  22174. private _maxSimultaneousLights;
  22175. maxSimultaneousLights: number;
  22176. /**
  22177. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22178. */
  22179. private _invertNormalMapX;
  22180. invertNormalMapX: boolean;
  22181. /**
  22182. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22183. */
  22184. private _invertNormalMapY;
  22185. invertNormalMapY: boolean;
  22186. /**
  22187. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22188. */
  22189. private _twoSidedLighting;
  22190. twoSidedLighting: boolean;
  22191. /**
  22192. * Default configuration related to image processing available in the standard Material.
  22193. */
  22194. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22195. /**
  22196. * Gets the image processing configuration used either in this material.
  22197. */
  22198. /**
  22199. * Sets the Default image processing configuration used either in the this material.
  22200. *
  22201. * If sets to null, the scene one is in use.
  22202. */
  22203. imageProcessingConfiguration: ImageProcessingConfiguration;
  22204. /**
  22205. * Keep track of the image processing observer to allow dispose and replace.
  22206. */
  22207. private _imageProcessingObserver;
  22208. /**
  22209. * Attaches a new image processing configuration to the Standard Material.
  22210. * @param configuration
  22211. */
  22212. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22213. /**
  22214. * Gets wether the color curves effect is enabled.
  22215. */
  22216. /**
  22217. * Sets wether the color curves effect is enabled.
  22218. */
  22219. cameraColorCurvesEnabled: boolean;
  22220. /**
  22221. * Gets wether the color grading effect is enabled.
  22222. */
  22223. /**
  22224. * Gets wether the color grading effect is enabled.
  22225. */
  22226. cameraColorGradingEnabled: boolean;
  22227. /**
  22228. * Gets wether tonemapping is enabled or not.
  22229. */
  22230. /**
  22231. * Sets wether tonemapping is enabled or not
  22232. */
  22233. cameraToneMappingEnabled: boolean;
  22234. /**
  22235. * The camera exposure used on this material.
  22236. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22237. * This corresponds to a photographic exposure.
  22238. */
  22239. /**
  22240. * The camera exposure used on this material.
  22241. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22242. * This corresponds to a photographic exposure.
  22243. */
  22244. cameraExposure: number;
  22245. /**
  22246. * Gets The camera contrast used on this material.
  22247. */
  22248. /**
  22249. * Sets The camera contrast used on this material.
  22250. */
  22251. cameraContrast: number;
  22252. /**
  22253. * Gets the Color Grading 2D Lookup Texture.
  22254. */
  22255. /**
  22256. * Sets the Color Grading 2D Lookup Texture.
  22257. */
  22258. cameraColorGradingTexture: Nullable<BaseTexture>;
  22259. /**
  22260. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22261. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22262. * 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;
  22263. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22264. */
  22265. /**
  22266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22268. * 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;
  22269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22270. */
  22271. cameraColorCurves: Nullable<ColorCurves>;
  22272. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  22273. protected _renderTargets: SmartArray<RenderTargetTexture>;
  22274. protected _worldViewProjectionMatrix: Matrix;
  22275. protected _globalAmbientColor: Color3;
  22276. protected _useLogarithmicDepth: boolean;
  22277. constructor(name: string, scene: Scene);
  22278. getClassName(): string;
  22279. useLogarithmicDepth: boolean;
  22280. needAlphaBlending(): boolean;
  22281. needAlphaTesting(): boolean;
  22282. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  22283. getAlphaTestTexture(): Nullable<BaseTexture>;
  22284. /**
  22285. * Child classes can use it to update shaders
  22286. */
  22287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22288. buildUniformLayout(): void;
  22289. unbind(): void;
  22290. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22291. getAnimatables(): IAnimatable[];
  22292. getActiveTextures(): BaseTexture[];
  22293. hasTexture(texture: BaseTexture): boolean;
  22294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22295. clone(name: string): StandardMaterial;
  22296. serialize(): any;
  22297. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  22298. static _DiffuseTextureEnabled: boolean;
  22299. static DiffuseTextureEnabled: boolean;
  22300. static _AmbientTextureEnabled: boolean;
  22301. static AmbientTextureEnabled: boolean;
  22302. static _OpacityTextureEnabled: boolean;
  22303. static OpacityTextureEnabled: boolean;
  22304. static _ReflectionTextureEnabled: boolean;
  22305. static ReflectionTextureEnabled: boolean;
  22306. static _EmissiveTextureEnabled: boolean;
  22307. static EmissiveTextureEnabled: boolean;
  22308. static _SpecularTextureEnabled: boolean;
  22309. static SpecularTextureEnabled: boolean;
  22310. static _BumpTextureEnabled: boolean;
  22311. static BumpTextureEnabled: boolean;
  22312. static _LightmapTextureEnabled: boolean;
  22313. static LightmapTextureEnabled: boolean;
  22314. static _RefractionTextureEnabled: boolean;
  22315. static RefractionTextureEnabled: boolean;
  22316. static _ColorGradingTextureEnabled: boolean;
  22317. static ColorGradingTextureEnabled: boolean;
  22318. static _FresnelEnabled: boolean;
  22319. static FresnelEnabled: boolean;
  22320. }
  22321. }
  22322. declare module BABYLON {
  22323. class UniformBuffer {
  22324. private _engine;
  22325. private _buffer;
  22326. private _data;
  22327. private _bufferData;
  22328. private _dynamic?;
  22329. private _uniformLocations;
  22330. private _uniformSizes;
  22331. private _uniformLocationPointer;
  22332. private _needSync;
  22333. private _noUBO;
  22334. private _currentEffect;
  22335. private static _MAX_UNIFORM_SIZE;
  22336. private static _tempBuffer;
  22337. /**
  22338. * Wrapper for updateUniform.
  22339. * @method updateMatrix3x3
  22340. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22341. * @param {Float32Array} matrix
  22342. */
  22343. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  22344. /**
  22345. * Wrapper for updateUniform.
  22346. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22347. * @param {Float32Array} matrix
  22348. */
  22349. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  22350. /**
  22351. * Wrapper for updateUniform.
  22352. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22353. * @param {number} x
  22354. */
  22355. updateFloat: (name: string, x: number) => void;
  22356. /**
  22357. * Wrapper for updateUniform.
  22358. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22359. * @param {number} x
  22360. * @param {number} y
  22361. * @param {string} [suffix] Suffix to add to the uniform name.
  22362. */
  22363. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  22364. /**
  22365. * Wrapper for updateUniform.
  22366. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22367. * @param {number} x
  22368. * @param {number} y
  22369. * @param {number} z
  22370. * @param {string} [suffix] Suffix to add to the uniform name.
  22371. */
  22372. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  22373. /**
  22374. * Wrapper for updateUniform.
  22375. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22376. * @param {number} x
  22377. * @param {number} y
  22378. * @param {number} z
  22379. * @param {number} w
  22380. * @param {string} [suffix] Suffix to add to the uniform name.
  22381. */
  22382. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  22383. /**
  22384. * Wrapper for updateUniform.
  22385. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22386. * @param {Matrix} A 4x4 matrix.
  22387. */
  22388. updateMatrix: (name: string, mat: Matrix) => void;
  22389. /**
  22390. * Wrapper for updateUniform.
  22391. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22392. * @param {Vector3} vector
  22393. */
  22394. updateVector3: (name: string, vector: Vector3) => void;
  22395. /**
  22396. * Wrapper for updateUniform.
  22397. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22398. * @param {Vector4} vector
  22399. */
  22400. updateVector4: (name: string, vector: Vector4) => void;
  22401. /**
  22402. * Wrapper for updateUniform.
  22403. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22404. * @param {Color3} color
  22405. * @param {string} [suffix] Suffix to add to the uniform name.
  22406. */
  22407. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  22408. /**
  22409. * Wrapper for updateUniform.
  22410. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22411. * @param {Color3} color
  22412. * @param {number} alpha
  22413. * @param {string} [suffix] Suffix to add to the uniform name.
  22414. */
  22415. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  22416. /**
  22417. * Uniform buffer objects.
  22418. *
  22419. * Handles blocks of uniform on the GPU.
  22420. *
  22421. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  22422. *
  22423. * For more information, please refer to :
  22424. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  22425. */
  22426. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  22427. /**
  22428. * Indicates if the buffer is using the WebGL2 UBO implementation,
  22429. * or just falling back on setUniformXXX calls.
  22430. */
  22431. readonly useUbo: boolean;
  22432. /**
  22433. * Indicates if the WebGL underlying uniform buffer is in sync
  22434. * with the javascript cache data.
  22435. */
  22436. readonly isSync: boolean;
  22437. /**
  22438. * Indicates if the WebGL underlying uniform buffer is dynamic.
  22439. * Also, a dynamic UniformBuffer will disable cache verification and always
  22440. * update the underlying WebGL uniform buffer to the GPU.
  22441. */
  22442. isDynamic(): boolean;
  22443. /**
  22444. * The data cache on JS side.
  22445. */
  22446. getData(): Float32Array;
  22447. /**
  22448. * The underlying WebGL Uniform buffer.
  22449. */
  22450. getBuffer(): Nullable<WebGLBuffer>;
  22451. /**
  22452. * std140 layout specifies how to align data within an UBO structure.
  22453. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  22454. * for specs.
  22455. */
  22456. private _fillAlignment(size);
  22457. /**
  22458. * Adds an uniform in the buffer.
  22459. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  22460. * for the layout to be correct !
  22461. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22462. * @param {number|number[]} size Data size, or data directly.
  22463. */
  22464. addUniform(name: string, size: number | number[]): void;
  22465. /**
  22466. * Wrapper for addUniform.
  22467. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22468. * @param {Matrix} mat A 4x4 matrix.
  22469. */
  22470. addMatrix(name: string, mat: Matrix): void;
  22471. /**
  22472. * Wrapper for addUniform.
  22473. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22474. * @param {number} x
  22475. * @param {number} y
  22476. */
  22477. addFloat2(name: string, x: number, y: number): void;
  22478. /**
  22479. * Wrapper for addUniform.
  22480. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22481. * @param {number} x
  22482. * @param {number} y
  22483. * @param {number} z
  22484. */
  22485. addFloat3(name: string, x: number, y: number, z: number): void;
  22486. /**
  22487. * Wrapper for addUniform.
  22488. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22489. * @param {Color3} color
  22490. */
  22491. addColor3(name: string, color: Color3): void;
  22492. /**
  22493. * Wrapper for addUniform.
  22494. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22495. * @param {Color3} color
  22496. * @param {number} alpha
  22497. */
  22498. addColor4(name: string, color: Color3, alpha: number): void;
  22499. /**
  22500. * Wrapper for addUniform.
  22501. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22502. * @param {Vector3} vector
  22503. */
  22504. addVector3(name: string, vector: Vector3): void;
  22505. /**
  22506. * Wrapper for addUniform.
  22507. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22508. */
  22509. addMatrix3x3(name: string): void;
  22510. /**
  22511. * Wrapper for addUniform.
  22512. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  22513. */
  22514. addMatrix2x2(name: string): void;
  22515. /**
  22516. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  22517. */
  22518. create(): void;
  22519. _rebuild(): void;
  22520. /**
  22521. * Updates the WebGL Uniform Buffer on the GPU.
  22522. * If the `dynamic` flag is set to true, no cache comparison is done.
  22523. * Otherwise, the buffer will be updated only if the cache differs.
  22524. */
  22525. update(): void;
  22526. /**
  22527. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  22528. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  22529. * @param {number[]|Float32Array} data Flattened data
  22530. * @param {number} size Size of the data.
  22531. */
  22532. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  22533. private _updateMatrix3x3ForUniform(name, matrix);
  22534. private _updateMatrix3x3ForEffect(name, matrix);
  22535. private _updateMatrix2x2ForEffect(name, matrix);
  22536. private _updateMatrix2x2ForUniform(name, matrix);
  22537. private _updateFloatForEffect(name, x);
  22538. private _updateFloatForUniform(name, x);
  22539. private _updateFloat2ForEffect(name, x, y, suffix?);
  22540. private _updateFloat2ForUniform(name, x, y, suffix?);
  22541. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  22542. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  22543. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  22544. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  22545. private _updateMatrixForEffect(name, mat);
  22546. private _updateMatrixForUniform(name, mat);
  22547. private _updateVector3ForEffect(name, vector);
  22548. private _updateVector3ForUniform(name, vector);
  22549. private _updateVector4ForEffect(name, vector);
  22550. private _updateVector4ForUniform(name, vector);
  22551. private _updateColor3ForEffect(name, color, suffix?);
  22552. private _updateColor3ForUniform(name, color, suffix?);
  22553. private _updateColor4ForEffect(name, color, alpha, suffix?);
  22554. private _updateColor4ForUniform(name, color, alpha, suffix?);
  22555. /**
  22556. * Sets a sampler uniform on the effect.
  22557. * @param {string} name Name of the sampler.
  22558. * @param {Texture} texture
  22559. */
  22560. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  22561. /**
  22562. * Directly updates the value of the uniform in the cache AND on the GPU.
  22563. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  22564. * @param {number[]|Float32Array} data Flattened data
  22565. */
  22566. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  22567. /**
  22568. * Binds this uniform buffer to an effect.
  22569. * @param {Effect} effect
  22570. * @param {string} name Name of the uniform block in the shader.
  22571. */
  22572. bindToEffect(effect: Effect, name: string): void;
  22573. /**
  22574. * Disposes the uniform buffer.
  22575. */
  22576. dispose(): void;
  22577. =======
  22578. class BaseSubMesh {
  22579. _materialDefines: Nullable<MaterialDefines>;
  22580. _materialEffect: Nullable<Effect>;
  22581. readonly effect: Nullable<Effect>;
  22582. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22583. }
  22584. class SubMesh extends BaseSubMesh implements ICullable {
  22585. materialIndex: number;
  22586. verticesStart: number;
  22587. verticesCount: number;
  22588. indexStart: number;
  22589. indexCount: number;
  22590. linesIndexCount: number;
  22591. private _mesh;
  22592. private _renderingMesh;
  22593. private _boundingInfo;
  22594. private _linesIndexBuffer;
  22595. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22596. _trianglePlanes: Plane[];
  22597. _lastColliderTransformMatrix: Matrix;
  22598. _renderId: number;
  22599. _alphaIndex: number;
  22600. _distanceToCamera: number;
  22601. _id: number;
  22602. private _currentMaterial;
  22603. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22604. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22605. readonly IsGlobal: boolean;
  22606. /**
  22607. * Returns the submesh BoudingInfo object.
  22608. */
  22609. getBoundingInfo(): BoundingInfo;
  22610. /**
  22611. * Sets the submesh BoundingInfo.
  22612. * Return the SubMesh.
  22613. */
  22614. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22615. /**
  22616. * Returns the mesh of the current submesh.
  22617. */
  22618. getMesh(): AbstractMesh;
  22619. /**
  22620. * Returns the rendering mesh of the submesh.
  22621. */
  22622. getRenderingMesh(): Mesh;
  22623. /**
  22624. * Returns the submesh material.
  22625. */
  22626. getMaterial(): Nullable<Material>;
  22627. /**
  22628. * Sets a new updated BoundingInfo object to the submesh.
  22629. * Returns the SubMesh.
  22630. */
  22631. refreshBoundingInfo(): SubMesh;
  22632. _checkCollision(collider: Collider): boolean;
  22633. /**
  22634. * Updates the submesh BoundingInfo.
  22635. * Returns the Submesh.
  22636. */
  22637. updateBoundingInfo(world: Matrix): SubMesh;
  22638. /**
  22639. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22640. * Boolean returned.
  22641. */
  22642. isInFrustum(frustumPlanes: Plane[]): boolean;
  22643. /**
  22644. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22645. * Boolean returned.
  22646. */
  22647. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22648. /**
  22649. * Renders the submesh.
  22650. * Returns it.
  22651. */
  22652. render(enableAlphaMode: boolean): SubMesh;
  22653. /**
  22654. * Returns a new Index Buffer.
  22655. * Type returned : WebGLBuffer.
  22656. */
  22657. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22658. /**
  22659. * True is the passed Ray intersects the submesh bounding box.
  22660. * Boolean returned.
  22661. */
  22662. canIntersects(ray: Ray): boolean;
  22663. /**
  22664. * Returns an object IntersectionInfo.
  22665. */
  22666. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22667. _rebuild(): void;
  22668. /**
  22669. * Creates a new Submesh from the passed Mesh.
  22670. */
  22671. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22672. /**
  22673. * Disposes the Submesh.
  22674. * Returns nothing.
  22675. */
  22676. dispose(): void;
  22677. /**
  22678. * Creates a new Submesh from the passed parameters :
  22679. * - materialIndex (integer) : the index of the main mesh material.
  22680. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22681. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22682. * - mesh (Mesh) : the main mesh to create the submesh from.
  22683. * - renderingMesh (optional Mesh) : rendering mesh.
  22684. */
  22685. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22686. }
  22687. }
  22688. declare module BABYLON {
  22689. class TransformNode extends Node {
  22690. static BILLBOARDMODE_NONE: number;
  22691. static BILLBOARDMODE_X: number;
  22692. static BILLBOARDMODE_Y: number;
  22693. static BILLBOARDMODE_Z: number;
  22694. static BILLBOARDMODE_ALL: number;
  22695. private _forward;
  22696. private _forwardInverted;
  22697. private _up;
  22698. private _right;
  22699. private _rightInverted;
  22700. private _rotation;
  22701. private _rotationQuaternion;
  22702. protected _scaling: Vector3;
  22703. protected _isDirty: boolean;
  22704. private _transformToBoneReferal;
  22705. billboardMode: number;
  22706. scalingDeterminant: number;
  22707. infiniteDistance: boolean;
  22708. position: Vector3;
  22709. _poseMatrix: Matrix;
  22710. private _localWorld;
  22711. _worldMatrix: Matrix;
  22712. _worldMatrixDeterminant: number;
  22713. private _absolutePosition;
  22714. private _pivotMatrix;
  22715. private _pivotMatrixInverse;
  22716. private _postMultiplyPivotMatrix;
  22717. protected _isWorldMatrixFrozen: boolean;
  22718. /**
  22719. * An event triggered after the world matrix is updated
  22720. * @type {BABYLON.Observable}
  22721. */
  22722. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22723. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22724. /**
  22725. * Gets a string idenfifying the name of the class
  22726. * @returns "TransformNode" string
  22727. */
  22728. getClassName(): string;
  22729. /**
  22730. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22731. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22732. * Default : (0.0, 0.0, 0.0)
  22733. */
  22734. rotation: Vector3;
  22735. /**
  22736. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22737. * Default : (1.0, 1.0, 1.0)
  22738. */
  22739. /**
  22740. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22741. * Default : (1.0, 1.0, 1.0)
  22742. */
  22743. scaling: Vector3;
  22744. /**
  22745. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22746. * It's null by default.
  22747. * 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)
  22748. */
  22749. rotationQuaternion: Nullable<Quaternion>;
  22750. /**
  22751. * The forward direction of that transform in world space.
  22752. */
  22753. readonly forward: Vector3;
  22754. /**
  22755. * The up direction of that transform in world space.
  22756. */
  22757. readonly up: Vector3;
  22758. /**
  22759. * The right direction of that transform in world space.
  22760. */
  22761. readonly right: Vector3;
  22762. /**
  22763. * Returns the latest update of the World matrix
  22764. * Returns a Matrix.
  22765. */
  22766. getWorldMatrix(): Matrix;
  22767. /**
  22768. * Returns the latest update of the World matrix determinant.
  22769. */
  22770. protected _getWorldMatrixDeterminant(): number;
  22771. /**
  22772. * Returns directly the latest state of the mesh World matrix.
  22773. * A Matrix is returned.
  22774. */
  22775. readonly worldMatrixFromCache: Matrix;
  22776. /**
  22777. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22778. * Returns the TransformNode.
  22779. */
  22780. updatePoseMatrix(matrix: Matrix): TransformNode;
  22781. /**
  22782. * Returns the mesh Pose matrix.
  22783. * Returned object : Matrix
  22784. */
  22785. getPoseMatrix(): Matrix;
  22786. _isSynchronized(): boolean;
  22787. _initCache(): void;
  22788. markAsDirty(property: string): TransformNode;
  22789. /**
  22790. * Returns the current mesh absolute position.
  22791. * Retuns a Vector3.
  22792. */
  22793. readonly absolutePosition: Vector3;
  22794. /**
  22795. * Sets a new matrix to apply before all other transformation
  22796. * @param matrix defines the transform matrix
  22797. * @returns the current TransformNode
  22798. */
  22799. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22800. /**
  22801. * Sets a new pivot matrix to the current node
  22802. * @param matrix defines the new pivot matrix to use
  22803. * @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
  22804. * @returns the current TransformNode
  22805. */
  22806. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22807. /**
  22808. * Returns the mesh pivot matrix.
  22809. * Default : Identity.
  22810. * A Matrix is returned.
  22811. */
  22812. getPivotMatrix(): Matrix;
  22813. /**
  22814. * Prevents the World matrix to be computed any longer.
  22815. * Returns the TransformNode.
  22816. */
  22817. freezeWorldMatrix(): TransformNode;
  22818. /**
  22819. * Allows back the World matrix computation.
  22820. * Returns the TransformNode.
  22821. */
  22822. unfreezeWorldMatrix(): this;
  22823. /**
  22824. * True if the World matrix has been frozen.
  22825. * Returns a boolean.
  22826. */
  22827. readonly isWorldMatrixFrozen: boolean;
  22828. /**
  22829. * Retuns the mesh absolute position in the World.
  22830. * Returns a Vector3.
  22831. */
  22832. getAbsolutePosition(): Vector3;
  22833. /**
  22834. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22835. * Returns the TransformNode.
  22836. */
  22837. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22838. /**
  22839. * Sets the mesh position in its local space.
  22840. * Returns the TransformNode.
  22841. */
  22842. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22843. /**
  22844. * Returns the mesh position in the local space from the current World matrix values.
  22845. * Returns a new Vector3.
  22846. */
  22847. getPositionExpressedInLocalSpace(): Vector3;
  22848. /**
  22849. * Translates the mesh along the passed Vector3 in its local space.
  22850. * Returns the TransformNode.
  22851. */
  22852. locallyTranslate(vector3: Vector3): TransformNode;
  22853. private static _lookAtVectorCache;
  22854. /**
  22855. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22856. * @param targetPoint the position (must be in same space as current mesh) to look at
  22857. * @param yawCor optional yaw (y-axis) correction in radians
  22858. * @param pitchCor optional pitch (x-axis) correction in radians
  22859. * @param rollCor optional roll (z-axis) correction in radians
  22860. * @param space the choosen space of the target
  22861. * @returns the TransformNode.
  22862. */
  22863. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22864. /**
  22865. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22866. * This Vector3 is expressed in the World space.
  22867. */
  22868. getDirection(localAxis: Vector3): Vector3;
  22869. /**
  22870. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22871. * localAxis is expressed in the mesh local space.
  22872. * result is computed in the Wordl space from the mesh World matrix.
  22873. * Returns the TransformNode.
  22874. */
  22875. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22876. /**
  22877. * Sets a new pivot point to the current node
  22878. * @param point defines the new pivot point to use
  22879. * @param space defines if the point is in world or local space (local by default)
  22880. * @returns the current TransformNode
  22881. */
  22882. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22883. /**
  22884. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22885. */
  22886. getPivotPoint(): Vector3;
  22887. /**
  22888. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22889. * Returns the TransformNode.
  22890. */
  22891. getPivotPointToRef(result: Vector3): TransformNode;
  22892. /**
  22893. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22894. */
  22895. getAbsolutePivotPoint(): Vector3;
  22896. /**
  22897. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22898. * Returns the TransformNode.
  22899. */
  22900. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22901. /**
  22902. * Defines the passed node as the parent of the current node.
  22903. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22904. * Returns the TransformNode.
  22905. */
  22906. setParent(node: Nullable<Node>): TransformNode;
  22907. private _nonUniformScaling;
  22908. readonly nonUniformScaling: boolean;
  22909. _updateNonUniformScalingState(value: boolean): boolean;
  22910. /**
  22911. * Attach the current TransformNode to another TransformNode associated with a bone
  22912. * @param bone Bone affecting the TransformNode
  22913. * @param affectedTransformNode TransformNode associated with the bone
  22914. */
  22915. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22916. detachFromBone(): TransformNode;
  22917. private static _rotationAxisCache;
  22918. /**
  22919. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22920. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22921. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22922. * The passed axis is also normalized.
  22923. * Returns the TransformNode.
  22924. */
  22925. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22926. /**
  22927. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22928. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22929. * The passed axis is also normalized.
  22930. * Returns the TransformNode.
  22931. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22932. */
  22933. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22934. /**
  22935. * Translates the mesh along the axis vector for the passed distance in the given space.
  22936. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22937. * Returns the TransformNode.
  22938. */
  22939. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22940. /**
  22941. * Adds a rotation step to the mesh current rotation.
  22942. * x, y, z are Euler angles expressed in radians.
  22943. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22944. * This means this rotation is made in the mesh local space only.
  22945. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22946. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22947. * ```javascript
  22948. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22949. * ```
  22950. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22951. * 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.
  22952. * Returns the TransformNode.
  22953. */
  22954. addRotation(x: number, y: number, z: number): TransformNode;
  22955. /**
  22956. * Computes the mesh World matrix and returns it.
  22957. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22958. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22959. * If the parameter `force`is set to `true`, the actual computation is done.
  22960. * Returns the mesh World Matrix.
  22961. */
  22962. computeWorldMatrix(force?: boolean): Matrix;
  22963. protected _afterComputeWorldMatrix(): void;
  22964. /**
  22965. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22966. * @param func: callback function to add
  22967. *
  22968. * Returns the TransformNode.
  22969. */
  22970. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22971. /**
  22972. * Removes a registered callback function.
  22973. * Returns the TransformNode.
  22974. */
  22975. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22976. /**
  22977. * Clone the current transform node
  22978. * Returns the new transform node
  22979. * @param name Name of the new clone
  22980. * @param newParent New parent for the clone
  22981. * @param doNotCloneChildren Do not clone children hierarchy
  22982. */
  22983. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22984. serialize(currentSerializationObject?: any): any;
  22985. /**
  22986. * Returns a new TransformNode object parsed from the source provided.
  22987. * The parameter `parsedMesh` is the source.
  22988. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22989. */
  22990. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22991. /**
  22992. * Releases resources associated with this transform node.
  22993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22995. */
  22996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22997. }
  22998. }
  22999. declare module BABYLON {
  23000. class VertexBuffer {
  23001. private _buffer;
  23002. private _kind;
  23003. private _offset;
  23004. private _size;
  23005. private _stride;
  23006. private _ownsBuffer;
  23007. private _instanced;
  23008. private _instanceDivisor;
  23009. /**
  23010. * Gets or sets the instance divisor when in instanced mode
  23011. */
  23012. instanceDivisor: number;
  23013. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  23014. _rebuild(): void;
  23015. /**
  23016. * Returns the kind of the VertexBuffer (string).
  23017. */
  23018. getKind(): string;
  23019. /**
  23020. * Boolean : is the VertexBuffer updatable ?
  23021. */
  23022. isUpdatable(): boolean;
  23023. /**
  23024. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  23025. */
  23026. getData(): Nullable<FloatArray>;
  23027. /**
  23028. * Returns the WebGLBuffer associated to the VertexBuffer.
  23029. */
  23030. getBuffer(): Nullable<WebGLBuffer>;
  23031. /**
  23032. * Returns the stride of the VertexBuffer (integer).
  23033. */
  23034. getStrideSize(): number;
  23035. /**
  23036. * Returns the offset (integer).
  23037. */
  23038. getOffset(): number;
  23039. /**
  23040. * Returns the VertexBuffer total size (integer).
  23041. */
  23042. getSize(): number;
  23043. /**
  23044. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23045. */
  23046. getIsInstanced(): boolean;
  23047. /**
  23048. * Returns the instancing divisor, zero for non-instanced (integer).
  23049. */
  23050. getInstanceDivisor(): number;
  23051. /**
  23052. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23053. * Returns the created WebGLBuffer.
  23054. */
  23055. create(data?: FloatArray): void;
  23056. /**
  23057. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23058. * This function will create a new buffer if the current one is not updatable
  23059. * Returns the updated WebGLBuffer.
  23060. */
  23061. update(data: FloatArray): void;
  23062. /**
  23063. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23064. * Returns the directly updated WebGLBuffer.
  23065. */
  23066. updateDirectly(data: Float32Array, offset: number): void;
  23067. /**
  23068. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23069. */
  23070. dispose(): void;
  23071. private static _PositionKind;
  23072. private static _NormalKind;
  23073. private static _TangentKind;
  23074. private static _UVKind;
  23075. private static _UV2Kind;
  23076. private static _UV3Kind;
  23077. private static _UV4Kind;
  23078. private static _UV5Kind;
  23079. private static _UV6Kind;
  23080. private static _ColorKind;
  23081. private static _MatricesIndicesKind;
  23082. private static _MatricesWeightsKind;
  23083. private static _MatricesIndicesExtraKind;
  23084. private static _MatricesWeightsExtraKind;
  23085. static readonly PositionKind: string;
  23086. static readonly NormalKind: string;
  23087. static readonly TangentKind: string;
  23088. static readonly UVKind: string;
  23089. static readonly UV2Kind: string;
  23090. static readonly UV3Kind: string;
  23091. static readonly UV4Kind: string;
  23092. static readonly UV5Kind: string;
  23093. static readonly UV6Kind: string;
  23094. static readonly ColorKind: string;
  23095. static readonly MatricesIndicesKind: string;
  23096. static readonly MatricesWeightsKind: string;
  23097. static readonly MatricesIndicesExtraKind: string;
  23098. static readonly MatricesWeightsExtraKind: string;
  23099. /**
  23100. * Deduces the stride given a kind.
  23101. * @param kind The kind string to deduce
  23102. * @returns The deduced stride
  23103. */
  23104. static DeduceStride(kind: string): number;
  23105. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23106. }
  23107. }
  23108. declare module BABYLON {
  23109. /**
  23110. * This represents a GPU particle system in Babylon
  23111. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23112. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23113. */
  23114. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23115. /**
  23116. * The id of the Particle system.
  23117. */
  23118. id: string;
  23119. /**
  23120. * The friendly name of the Particle system.
  23121. */
  23122. name: string;
  23123. /**
  23124. * The emitter represents the Mesh or position we are attaching the particle system to.
  23125. */
  23126. emitter: Nullable<AbstractMesh | Vector3>;
  23127. /**
  23128. * The rendering group used by the Particle system to chose when to render.
  23129. */
  23130. renderingGroupId: number;
  23131. /**
  23132. * The layer mask we are rendering the particles through.
  23133. */
  23134. layerMask: number;
  23135. private _capacity;
  23136. private _activeCount;
  23137. private _currentActiveCount;
  23138. private _renderEffect;
  23139. private _updateEffect;
  23140. private _buffer0;
  23141. private _buffer1;
  23142. private _spriteBuffer;
  23143. private _updateVAO;
  23144. private _renderVAO;
  23145. private _targetIndex;
  23146. private _sourceBuffer;
  23147. private _targetBuffer;
  23148. private _scene;
  23149. private _engine;
  23150. private _currentRenderId;
  23151. private _started;
  23152. private _stopped;
  23153. private _timeDelta;
  23154. private _randomTexture;
  23155. private readonly _attributesStrideSize;
  23156. private _updateEffectOptions;
  23157. private _randomTextureSize;
  23158. private _actualFrame;
  23159. /**
  23160. * List of animations used by the particle system.
  23161. */
  23162. animations: Animation[];
  23163. /**
  23164. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23165. */
  23166. <<<<<<< HEAD
  23167. layerMask: number;
  23168. private _capacity;
  23169. private _activeCount;
  23170. private _currentActiveCount;
  23171. private _renderEffect;
  23172. private _updateEffect;
  23173. private _buffer0;
  23174. private _buffer1;
  23175. private _spriteBuffer;
  23176. private _updateVAO;
  23177. private _renderVAO;
  23178. private _targetIndex;
  23179. private _sourceBuffer;
  23180. private _targetBuffer;
  23181. private _scene;
  23182. private _engine;
  23183. private _currentRenderId;
  23184. private _started;
  23185. private _stopped;
  23186. private _timeDelta;
  23187. private _randomTexture;
  23188. private readonly _attributesStrideSize;
  23189. private _updateEffectOptions;
  23190. private _randomTextureSize;
  23191. private _actualFrame;
  23192. /**
  23193. * List of animations used by the particle system.
  23194. */
  23195. animations: Animation[];
  23196. /**
  23197. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23198. */
  23199. static readonly IsSupported: boolean;
  23200. /**
  23201. =======
  23202. static readonly IsSupported: boolean;
  23203. /**
  23204. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23205. * An event triggered when the system is disposed.
  23206. */
  23207. onDisposeObservable: Observable<GPUParticleSystem>;
  23208. /**
  23209. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23210. */
  23211. updateSpeed: number;
  23212. /**
  23213. * The amount of time the particle system is running (depends of the overall update speed).
  23214. */
  23215. targetStopDuration: number;
  23216. /**
  23217. * The texture used to render each particle. (this can be a spritesheet)
  23218. */
  23219. particleTexture: Nullable<Texture>;
  23220. /**
  23221. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23222. */
  23223. blendMode: number;
  23224. /**
  23225. * Minimum life time of emitting particles.
  23226. */
  23227. minLifeTime: number;
  23228. /**
  23229. * Maximum life time of emitting particles.
  23230. */
  23231. maxLifeTime: number;
  23232. /**
  23233. * Minimum Size of emitting particles.
  23234. */
  23235. minSize: number;
  23236. /**
  23237. * Maximum Size of emitting particles.
  23238. */
  23239. maxSize: number;
  23240. /**
  23241. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23242. */
  23243. color1: Color4;
  23244. /**
  23245. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23246. */
  23247. color2: Color4;
  23248. /**
  23249. * Color the particle will have at the end of its lifetime.
  23250. */
  23251. colorDead: Color4;
  23252. /**
  23253. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23254. */
  23255. emitRate: number;
  23256. /**
  23257. * You can use gravity if you want to give an orientation to your particles.
  23258. */
  23259. gravity: Vector3;
  23260. /**
  23261. * Minimum power of emitting particles.
  23262. */
  23263. minEmitPower: number;
  23264. /**
  23265. * Maximum power of emitting particles.
  23266. */
  23267. maxEmitPower: number;
  23268. /**
  23269. * The particle emitter type defines the emitter used by the particle system.
  23270. * It can be for example box, sphere, or cone...
  23271. */
  23272. particleEmitterType: Nullable<IParticleEmitterType>;
  23273. /**
  23274. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23275. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23276. <<<<<<< HEAD
  23277. */
  23278. direction1: Vector3;
  23279. /**
  23280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23281. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23282. */
  23283. direction2: Vector3;
  23284. /**
  23285. * 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.
  23286. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23287. */
  23288. minEmitBox: Vector3;
  23289. /**
  23290. * 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.
  23291. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23292. */
  23293. maxEmitBox: Vector3;
  23294. /**
  23295. * Gets the maximum number of particles active at the same time.
  23296. * @returns The max number of active particles.
  23297. */
  23298. getCapacity(): number;
  23299. /**
  23300. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23301. * to override the particles.
  23302. */
  23303. forceDepthWrite: boolean;
  23304. /**
  23305. * Gets or set the number of active particles
  23306. */
  23307. activeParticleCount: number;
  23308. =======
  23309. */
  23310. direction1: Vector3;
  23311. /**
  23312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23313. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23314. */
  23315. direction2: Vector3;
  23316. /**
  23317. * 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.
  23318. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23319. */
  23320. minEmitBox: Vector3;
  23321. /**
  23322. * 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.
  23323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23324. */
  23325. maxEmitBox: Vector3;
  23326. /**
  23327. * Gets the maximum number of particles active at the same time.
  23328. * @returns The max number of active particles.
  23329. */
  23330. getCapacity(): number;
  23331. /**
  23332. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23333. * to override the particles.
  23334. */
  23335. forceDepthWrite: boolean;
  23336. /**
  23337. * Gets or set the number of active particles
  23338. */
  23339. activeParticleCount: number;
  23340. /**
  23341. * Is this system ready to be used/rendered
  23342. * @return true if the system is ready
  23343. */
  23344. isReady(): boolean;
  23345. /**
  23346. * Gets Wether the system has been started.
  23347. * @returns True if it has been started, otherwise false.
  23348. */
  23349. isStarted(): boolean;
  23350. /**
  23351. * Starts the particle system and begins to emit.
  23352. */
  23353. start(): void;
  23354. /**
  23355. * Stops the particle system.
  23356. */
  23357. stop(): void;
  23358. /**
  23359. * Remove all active particles
  23360. */
  23361. reset(): void;
  23362. /**
  23363. * Returns the string "GPUParticleSystem"
  23364. * @returns a string containing the class name
  23365. */
  23366. getClassName(): string;
  23367. /**
  23368. * Instantiates a GPU particle system.
  23369. * 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.
  23370. * @param name The name of the particle system
  23371. * @param capacity The max number of particles alive at the same time
  23372. * @param scene The scene the particle system belongs to
  23373. */
  23374. constructor(name: string, options: Partial<{
  23375. capacity: number;
  23376. randomTextureSize: number;
  23377. }>, scene: Scene);
  23378. private _createUpdateVAO(source);
  23379. private _createRenderVAO(source, spriteSource);
  23380. private _initialize(force?);
  23381. /** @ignore */
  23382. _recreateUpdateEffect(): void;
  23383. /** @ignore */
  23384. _recreateRenderEffect(): void;
  23385. /**
  23386. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23387. */
  23388. animate(): void;
  23389. /**
  23390. * Renders the particle system in its current state.
  23391. * @returns the current number of particles
  23392. */
  23393. render(): number;
  23394. /**
  23395. * Rebuilds the particle system
  23396. */
  23397. rebuild(): void;
  23398. private _releaseBuffers();
  23399. private _releaseVAOs();
  23400. /**
  23401. * Disposes the particle system and free the associated resources
  23402. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23403. */
  23404. dispose(disposeTexture?: boolean): void;
  23405. /**
  23406. * Clones the particle system.
  23407. * @param name The name of the cloned object
  23408. * @param newEmitter The new emitter to use
  23409. * @returns the cloned particle system
  23410. */
  23411. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  23412. /**
  23413. * Serializes the particle system to a JSON object.
  23414. * @returns the JSON object
  23415. */
  23416. serialize(): any;
  23417. /**
  23418. * Parses a JSON object to create a GPU particle system.
  23419. * @param parsedParticleSystem The JSON object to parse
  23420. * @param scene The scene to create the particle system in
  23421. * @param rootUrl The root url to use to load external dependencies like texture
  23422. * @returns the parsed GPU particle system
  23423. */
  23424. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  23425. }
  23426. }
  23427. declare module BABYLON {
  23428. /**
  23429. * Interface representing a particle system in Babylon.
  23430. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  23431. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  23432. */
  23433. interface IParticleSystem {
  23434. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23435. /**
  23436. * Is this system ready to be used/rendered
  23437. * @return true if the system is ready
  23438. */
  23439. isReady(): boolean;
  23440. /**
  23441. <<<<<<< HEAD
  23442. * Gets Wether the system has been started.
  23443. * @returns True if it has been started, otherwise false.
  23444. =======
  23445. * The name of the Particle system.
  23446. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23447. */
  23448. isStarted(): boolean;
  23449. /**
  23450. <<<<<<< HEAD
  23451. * Starts the particle system and begins to emit.
  23452. */
  23453. start(): void;
  23454. /**
  23455. * Stops the particle system.
  23456. =======
  23457. * The emitter represents the Mesh or position we are attaching the particle system to.
  23458. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23459. */
  23460. stop(): void;
  23461. /**
  23462. <<<<<<< HEAD
  23463. * Remove all active particles
  23464. */
  23465. reset(): void;
  23466. /**
  23467. * Returns the string "GPUParticleSystem"
  23468. * @returns a string containing the class name
  23469. */
  23470. getClassName(): string;
  23471. /**
  23472. * Instantiates a GPU particle system.
  23473. * 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.
  23474. * @param name The name of the particle system
  23475. * @param capacity The max number of particles alive at the same time
  23476. * @param scene The scene the particle system belongs to
  23477. */
  23478. constructor(name: string, options: Partial<{
  23479. capacity: number;
  23480. randomTextureSize: number;
  23481. }>, scene: Scene);
  23482. private _createUpdateVAO(source);
  23483. private _createRenderVAO(source, spriteSource);
  23484. private _initialize(force?);
  23485. /** @ignore */
  23486. _recreateUpdateEffect(): void;
  23487. /** @ignore */
  23488. _recreateRenderEffect(): void;
  23489. =======
  23490. * The rendering group used by the Particle system to chose when to render.
  23491. */
  23492. renderingGroupId: number;
  23493. /**
  23494. * The layer mask we are rendering the particles through.
  23495. */
  23496. layerMask: number;
  23497. /**
  23498. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23499. */
  23500. updateSpeed: number;
  23501. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23502. /**
  23503. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23504. */
  23505. animate(): void;
  23506. /**
  23507. <<<<<<< HEAD
  23508. * Renders the particle system in its current state.
  23509. * @returns the current number of particles
  23510. */
  23511. render(): number;
  23512. /**
  23513. * Rebuilds the particle system
  23514. */
  23515. rebuild(): void;
  23516. private _releaseBuffers();
  23517. private _releaseVAOs();
  23518. /**
  23519. * Disposes the particle system and free the associated resources
  23520. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23521. */
  23522. dispose(disposeTexture?: boolean): void;
  23523. =======
  23524. * The texture used to render each particle. (this can be a spritesheet)
  23525. */
  23526. particleTexture: Nullable<Texture>;
  23527. /**
  23528. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23529. */
  23530. blendMode: number;
  23531. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23532. /**
  23533. * Clones the particle system.
  23534. * @param name The name of the cloned object
  23535. * @param newEmitter The new emitter to use
  23536. * @returns the cloned particle system
  23537. */
  23538. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  23539. /**
  23540. * Serializes the particle system to a JSON object.
  23541. * @returns the JSON object
  23542. */
  23543. serialize(): any;
  23544. /**
  23545. * Parses a JSON object to create a GPU particle system.
  23546. * @param parsedParticleSystem The JSON object to parse
  23547. * @param scene The scene to create the particle system in
  23548. * @param rootUrl The root url to use to load external dependencies like texture
  23549. * @returns the parsed GPU particle system
  23550. */
  23551. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  23552. }
  23553. }
  23554. declare module BABYLON {
  23555. /**
  23556. * Interface representing a particle system in Babylon.
  23557. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  23558. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  23559. */
  23560. interface IParticleSystem {
  23561. /**
  23562. * The id of the Particle system.
  23563. */
  23564. id: string;
  23565. /**
  23566. <<<<<<< HEAD
  23567. * The name of the Particle system.
  23568. */
  23569. name: string;
  23570. /**
  23571. * The emitter represents the Mesh or position we are attaching the particle system to.
  23572. */
  23573. emitter: Nullable<AbstractMesh | Vector3>;
  23574. /**
  23575. * The rendering group used by the Particle system to chose when to render.
  23576. */
  23577. renderingGroupId: number;
  23578. /**
  23579. * The layer mask we are rendering the particles through.
  23580. */
  23581. layerMask: number;
  23582. /**
  23583. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23584. */
  23585. updateSpeed: number;
  23586. /**
  23587. * The amount of time the particle system is running (depends of the overall update speed).
  23588. */
  23589. targetStopDuration: number;
  23590. /**
  23591. * The texture used to render each particle. (this can be a spritesheet)
  23592. */
  23593. particleTexture: Nullable<Texture>;
  23594. =======
  23595. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23596. */
  23597. color1: Color4;
  23598. /**
  23599. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23600. */
  23601. color2: Color4;
  23602. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23603. /**
  23604. * Color the particle will have at the end of its lifetime.
  23605. */
  23606. colorDead: Color4;
  23607. /**
  23608. <<<<<<< HEAD
  23609. * Minimum life time of emitting particles.
  23610. */
  23611. minLifeTime: number;
  23612. /**
  23613. * Maximum life time of emitting particles.
  23614. */
  23615. maxLifeTime: number;
  23616. /**
  23617. * Minimum Size of emitting particles.
  23618. */
  23619. minSize: number;
  23620. /**
  23621. * Maximum Size of emitting particles.
  23622. */
  23623. maxSize: number;
  23624. =======
  23625. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23626. */
  23627. emitRate: number;
  23628. /**
  23629. * You can use gravity if you want to give an orientation to your particles.
  23630. */
  23631. gravity: Vector3;
  23632. /**
  23633. * Minimum power of emitting particles.
  23634. */
  23635. minEmitPower: number;
  23636. /**
  23637. * Maximum power of emitting particles.
  23638. */
  23639. maxEmitPower: number;
  23640. /**
  23641. * The particle emitter type defines the emitter used by the particle system.
  23642. * It can be for example box, sphere, or cone...
  23643. */
  23644. particleEmitterType: Nullable<IParticleEmitterType>;
  23645. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23646. /**
  23647. * Gets the maximum number of particles active at the same time.
  23648. * @returns The max number of active particles.
  23649. */
  23650. getCapacity(): number;
  23651. /**
  23652. * Gets Wether the system has been started.
  23653. * @returns True if it has been started, otherwise false.
  23654. */
  23655. isStarted(): boolean;
  23656. /**
  23657. * Gets if the particle system has been started.
  23658. * @return true if the system has been started, otherwise false.
  23659. */
  23660. isStarted(): boolean;
  23661. /**
  23662. <<<<<<< HEAD
  23663. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23664. */
  23665. emitRate: number;
  23666. /**
  23667. * You can use gravity if you want to give an orientation to your particles.
  23668. */
  23669. gravity: Vector3;
  23670. /**
  23671. * Minimum power of emitting particles.
  23672. */
  23673. minEmitPower: number;
  23674. /**
  23675. * Maximum power of emitting particles.
  23676. */
  23677. maxEmitPower: number;
  23678. /**
  23679. * The particle emitter type defines the emitter used by the particle system.
  23680. * It can be for example box, sphere, or cone...
  23681. */
  23682. particleEmitterType: Nullable<IParticleEmitterType>;
  23683. /**
  23684. * Gets the maximum number of particles active at the same time.
  23685. * @returns The max number of active particles.
  23686. */
  23687. getCapacity(): number;
  23688. /**
  23689. * Gets Wether the system has been started.
  23690. * @returns True if it has been started, otherwise false.
  23691. */
  23692. isStarted(): boolean;
  23693. /**
  23694. * Gets if the particle system has been started.
  23695. * @return true if the system has been started, otherwise false.
  23696. */
  23697. isStarted(): boolean;
  23698. /**
  23699. * Animates the particle system for this frame.
  23700. */
  23701. animate(): void;
  23702. /**
  23703. * Renders the particle system in its current state.
  23704. * @returns the current number of particles
  23705. */
  23706. render(): number;
  23707. /**
  23708. * Dispose the particle system and frees its associated resources.
  23709. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23710. */
  23711. dispose(disposeTexture?: boolean): void;
  23712. /**
  23713. * Clones the particle system.
  23714. * @param name The name of the cloned object
  23715. * @param newEmitter The new emitter to use
  23716. * @returns the cloned particle system
  23717. */
  23718. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23719. /**
  23720. * Serializes the particle system to a JSON object.
  23721. * @returns the JSON object
  23722. */
  23723. serialize(): any;
  23724. /**
  23725. * Rebuild the particle system
  23726. */
  23727. rebuild(): void;
  23728. =======
  23729. * Animates the particle system for this frame.
  23730. */
  23731. animate(): void;
  23732. /**
  23733. * Renders the particle system in its current state.
  23734. * @returns the current number of particles
  23735. */
  23736. render(): number;
  23737. /**
  23738. * Dispose the particle system and frees its associated resources.
  23739. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23740. */
  23741. dispose(disposeTexture?: boolean): void;
  23742. /**
  23743. * Clones the particle system.
  23744. * @param name The name of the cloned object
  23745. * @param newEmitter The new emitter to use
  23746. * @returns the cloned particle system
  23747. */
  23748. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23749. /**
  23750. * Serializes the particle system to a JSON object.
  23751. * @returns the JSON object
  23752. */
  23753. serialize(): any;
  23754. /**
  23755. * Rebuild the particle system
  23756. */
  23757. rebuild(): void;
  23758. /**
  23759. * Starts the particle system and begins to emit.
  23760. */
  23761. start(): void;
  23762. /**
  23763. * Stops the particle system.
  23764. */
  23765. stop(): void;
  23766. /**
  23767. * Remove all active particles
  23768. */
  23769. reset(): void;
  23770. /**
  23771. * Is this system ready to be used/rendered
  23772. * @return true if the system is ready
  23773. */
  23774. isReady(): boolean;
  23775. }
  23776. }
  23777. declare module BABYLON {
  23778. /**
  23779. * A particle represents one of the element emitted by a particle system.
  23780. * This is mainly define by its coordinates, direction, velocity and age.
  23781. */
  23782. class Particle {
  23783. /**
  23784. * particleSystem the particle system the particle belongs to.
  23785. */
  23786. particleSystem: ParticleSystem;
  23787. /**
  23788. * The world position of the particle in the scene.
  23789. */
  23790. position: Vector3;
  23791. /**
  23792. * The world direction of the particle in the scene.
  23793. */
  23794. direction: Vector3;
  23795. /**
  23796. * The color of the particle.
  23797. */
  23798. color: Color4;
  23799. /**
  23800. * The color change of the particle per step.
  23801. */
  23802. colorStep: Color4;
  23803. /**
  23804. * Defines how long will the life of the particle be.
  23805. */
  23806. lifeTime: number;
  23807. /**
  23808. * The current age of the particle.
  23809. */
  23810. age: number;
  23811. /**
  23812. * The current size of the particle.
  23813. */
  23814. size: number;
  23815. /**
  23816. * The current angle of the particle.
  23817. */
  23818. angle: number;
  23819. /**
  23820. * Defines how fast is the angle changing.
  23821. */
  23822. angularSpeed: number;
  23823. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23824. /**
  23825. * Defines the cell index used by the particle to be rendered from a sprite.
  23826. */
  23827. cellIndex: number;
  23828. private _currentFrameCounter;
  23829. /**
  23830. <<<<<<< HEAD
  23831. * Stops the particle system.
  23832. */
  23833. stop(): void;
  23834. =======
  23835. * Creates a new instance of @see Particle
  23836. * @param particleSystem the particle system the particle belongs to
  23837. */
  23838. constructor(
  23839. /**
  23840. * particleSystem the particle system the particle belongs to.
  23841. */
  23842. particleSystem: ParticleSystem);
  23843. private updateCellInfoFromSystem();
  23844. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23845. /**
  23846. * Defines how the sprite cell index is updated for the particle. This is
  23847. * defined as a callback.
  23848. */
  23849. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23850. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23851. private _updateCellIndexWithCustomSpeed();
  23852. /**
  23853. <<<<<<< HEAD
  23854. * Is this system ready to be used/rendered
  23855. * @return true if the system is ready
  23856. */
  23857. isReady(): boolean;
  23858. =======
  23859. * Copy the properties of particle to another one.
  23860. * @param other the particle to copy the information to.
  23861. */
  23862. copyTo(other: Particle): void;
  23863. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  23864. }
  23865. }
  23866. declare module BABYLON {
  23867. /**
  23868. <<<<<<< HEAD
  23869. * A particle represents one of the element emitted by a particle system.
  23870. * This is mainly define by its coordinates, direction, velocity and age.
  23871. */
  23872. class Particle {
  23873. /**
  23874. * particleSystem the particle system the particle belongs to.
  23875. */
  23876. particleSystem: ParticleSystem;
  23877. /**
  23878. * The world position of the particle in the scene.
  23879. */
  23880. position: Vector3;
  23881. /**
  23882. * The world direction of the particle in the scene.
  23883. */
  23884. direction: Vector3;
  23885. /**
  23886. * The color of the particle.
  23887. */
  23888. color: Color4;
  23889. /**
  23890. * The color change of the particle per step.
  23891. */
  23892. colorStep: Color4;
  23893. /**
  23894. * Defines how long will the life of the particle be.
  23895. */
  23896. lifeTime: number;
  23897. /**
  23898. * The current age of the particle.
  23899. */
  23900. age: number;
  23901. /**
  23902. * The current size of the particle.
  23903. */
  23904. size: number;
  23905. /**
  23906. * The current angle of the particle.
  23907. */
  23908. angle: number;
  23909. /**
  23910. * Defines how fast is the angle changing.
  23911. */
  23912. angularSpeed: number;
  23913. /**
  23914. * Defines the cell index used by the particle to be rendered from a sprite.
  23915. */
  23916. cellIndex: number;
  23917. private _currentFrameCounter;
  23918. /**
  23919. * Creates a new instance Particle
  23920. * @param particleSystem the particle system the particle belongs to
  23921. */
  23922. constructor(
  23923. /**
  23924. * particleSystem the particle system the particle belongs to.
  23925. */
  23926. particleSystem: ParticleSystem);
  23927. private updateCellInfoFromSystem();
  23928. /**
  23929. * Defines how the sprite cell index is updated for the particle. This is
  23930. * defined as a callback.
  23931. */
  23932. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23933. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23934. private _updateCellIndexWithCustomSpeed();
  23935. /**
  23936. * Copy the properties of particle to another one.
  23937. * @param other the particle to copy the information to.
  23938. */
  23939. copyTo(other: Particle): void;
  23940. }
  23941. }
  23942. declare module BABYLON {
  23943. /**
  23944. * This represents a particle system in Babylon.
  23945. * 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.
  23946. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  23947. * @example https://doc.babylonjs.com/babylon101/particles
  23948. */
  23949. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  23950. /**
  23951. * Source color is added to the destination color without alpha affecting the result.
  23952. */
  23953. static BLENDMODE_ONEONE: number;
  23954. /**
  23955. * Blend current color and particle color using particle’s alpha.
  23956. */
  23957. static BLENDMODE_STANDARD: number;
  23958. /**
  23959. * List of animations used by the particle system.
  23960. */
  23961. animations: Animation[];
  23962. /**
  23963. * The id of the Particle system.
  23964. */
  23965. id: string;
  23966. /**
  23967. * The friendly name of the Particle system.
  23968. */
  23969. name: string;
  23970. /**
  23971. * The rendering group used by the Particle system to chose when to render.
  23972. */
  23973. renderingGroupId: number;
  23974. /**
  23975. * The emitter represents the Mesh or position we are attaching the particle system to.
  23976. */
  23977. emitter: Nullable<AbstractMesh | Vector3>;
  23978. /**
  23979. * The maximum number of particles to emit per frame
  23980. */
  23981. emitRate: number;
  23982. /**
  23983. * If you want to launch only a few particles at once, that can be done, as well.
  23984. */
  23985. manualEmitCount: number;
  23986. /**
  23987. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23988. */
  23989. updateSpeed: number;
  23990. /**
  23991. * The amount of time the particle system is running (depends of the overall update speed).
  23992. */
  23993. targetStopDuration: number;
  23994. /**
  23995. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  23996. */
  23997. disposeOnStop: boolean;
  23998. /**
  23999. * Minimum power of emitting particles.
  24000. */
  24001. minEmitPower: number;
  24002. /**
  24003. * Maximum power of emitting particles.
  24004. */
  24005. maxEmitPower: number;
  24006. /**
  24007. * Minimum life time of emitting particles.
  24008. */
  24009. minLifeTime: number;
  24010. /**
  24011. * Maximum life time of emitting particles.
  24012. */
  24013. maxLifeTime: number;
  24014. /**
  24015. * Minimum Size of emitting particles.
  24016. */
  24017. minSize: number;
  24018. /**
  24019. * Maximum Size of emitting particles.
  24020. */
  24021. maxSize: number;
  24022. /**
  24023. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24024. */
  24025. minAngularSpeed: number;
  24026. /**
  24027. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24028. */
  24029. maxAngularSpeed: number;
  24030. /**
  24031. * The texture used to render each particle. (this can be a spritesheet)
  24032. */
  24033. particleTexture: Nullable<Texture>;
  24034. /**
  24035. * The layer mask we are rendering the particles through.
  24036. */
  24037. layerMask: number;
  24038. /**
  24039. * This can help using your own shader to render the particle system.
  24040. * The according effect will be created
  24041. */
  24042. customShader: any;
  24043. /**
  24044. * By default particle system starts as soon as they are created. This prevents the
  24045. * automatic start to happen and let you decide when to start emitting particles.
  24046. */
  24047. preventAutoStart: boolean;
  24048. /**
  24049. * This function can be defined to provide custom update for active particles.
  24050. * This function will be called instead of regular update (age, position, color, etc.).
  24051. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  24052. */
  24053. updateFunction: (particles: Particle[]) => void;
  24054. /**
  24055. * Callback triggered when the particle animation is ending.
  24056. */
  24057. onAnimationEnd: Nullable<() => void>;
  24058. /**
  24059. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24060. */
  24061. blendMode: number;
  24062. /**
  24063. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24064. * to override the particles.
  24065. */
  24066. forceDepthWrite: boolean;
  24067. /**
  24068. * You can use gravity if you want to give an orientation to your particles.
  24069. */
  24070. gravity: Vector3;
  24071. /**
  24072. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24073. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24074. */
  24075. direction1: Vector3;
  24076. /**
  24077. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24078. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24079. */
  24080. direction2: Vector3;
  24081. /**
  24082. * 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.
  24083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24084. */
  24085. minEmitBox: Vector3;
  24086. /**
  24087. * 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.
  24088. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24089. */
  24090. maxEmitBox: Vector3;
  24091. /**
  24092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24093. */
  24094. color1: Color4;
  24095. /**
  24096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24097. */
  24098. color2: Color4;
  24099. /**
  24100. * Color the particle will have at the end of its lifetime.
  24101. */
  24102. colorDead: Color4;
  24103. /**
  24104. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  24105. */
  24106. textureMask: Color4;
  24107. /**
  24108. * The particle emitter type defines the emitter used by the particle system.
  24109. * It can be for example box, sphere, or cone...
  24110. */
  24111. particleEmitterType: IParticleEmitterType;
  24112. /**
  24113. * This function can be defined to specify initial direction for every new particle.
  24114. * It by default use the emitterType defined function.
  24115. */
  24116. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  24117. /**
  24118. * This function can be defined to specify initial position for every new particle.
  24119. * It by default use the emitterType defined function.
  24120. */
  24121. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  24122. /**
  24123. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  24124. */
  24125. spriteCellLoop: boolean;
  24126. /**
  24127. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  24128. */
  24129. spriteCellChangeSpeed: number;
  24130. /**
  24131. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  24132. */
  24133. startSpriteCellID: number;
  24134. /**
  24135. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  24136. */
  24137. endSpriteCellID: number;
  24138. /**
  24139. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  24140. */
  24141. spriteCellWidth: number;
  24142. /**
  24143. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  24144. */
  24145. spriteCellHeight: number;
  24146. /**
  24147. * An event triggered when the system is disposed.
  24148. */
  24149. onDisposeObservable: Observable<ParticleSystem>;
  24150. private _onDisposeObserver;
  24151. /**
  24152. * Sets a callback that will be triggered when the system is disposed.
  24153. */
  24154. onDispose: () => void;
  24155. /**
  24156. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  24157. */
  24158. readonly isAnimationSheetEnabled: Boolean;
  24159. private _particles;
  24160. private _epsilon;
  24161. private _capacity;
  24162. private _scene;
  24163. private _stockParticles;
  24164. private _newPartsExcess;
  24165. private _vertexData;
  24166. private _vertexBuffer;
  24167. private _vertexBuffers;
  24168. private _indexBuffer;
  24169. private _effect;
  24170. private _customEffect;
  24171. private _cachedDefines;
  24172. private _scaledColorStep;
  24173. private _colorDiff;
  24174. private _scaledDirection;
  24175. private _scaledGravity;
  24176. private _currentRenderId;
  24177. private _alive;
  24178. private _started;
  24179. private _stopped;
  24180. private _actualFrame;
  24181. private _scaledUpdateSpeed;
  24182. private _vertexBufferSize;
  24183. private _isAnimationSheetEnabled;
  24184. /**
  24185. * 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.
  24186. */
  24187. subEmitters: ParticleSystem[];
  24188. /**
  24189. * The current active Sub-systems, this property is used by the root particle system only.
  24190. */
  24191. activeSubSystems: Array<ParticleSystem>;
  24192. private _rootParticleSystem;
  24193. /**
  24194. * Gets the current list of active particles
  24195. */
  24196. readonly particles: Particle[];
  24197. /**
  24198. * Returns the string "ParticleSystem"
  24199. * @returns a string containing the class name
  24200. */
  24201. getClassName(): string;
  24202. /**
  24203. * Instantiates a particle system.
  24204. * 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.
  24205. * @param name The name of the particle system
  24206. * @param capacity The max number of particles alive at the same time
  24207. * @param scene The scene the particle system belongs to
  24208. * @param customEffect a custom effect used to change the way particles are rendered by default
  24209. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24210. * @param epsilon Offset used to render the particles
  24211. */
  24212. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  24213. private _createIndexBuffer();
  24214. /**
  24215. * Gets the maximum number of particles active at the same time.
  24216. * @returns The max number of active particles.
  24217. */
  24218. getCapacity(): number;
  24219. /**
  24220. * Gets Wether there are still active particles in the system.
  24221. * @returns True if it is alive, otherwise false.
  24222. */
  24223. isAlive(): boolean;
  24224. /**
  24225. * Gets Wether the system has been started.
  24226. * @returns True if it has been started, otherwise false.
  24227. */
  24228. isStarted(): boolean;
  24229. /**
  24230. * Starts the particle system and begins to emit.
  24231. */
  24232. start(): void;
  24233. /**
  24234. * Stops the particle system.
  24235. * @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.
  24236. */
  24237. stop(stopSubEmitters?: boolean): void;
  24238. /**
  24239. * Remove all active particles
  24240. */
  24241. reset(): void;
  24242. /**
  24243. * @ignore (for internal use only)
  24244. */
  24245. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  24246. /**
  24247. * @ignore (for internal use only)
  24248. */
  24249. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  24250. /**
  24251. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  24252. * Its lifetime will start back at 0.
  24253. */
  24254. recycleParticle: (particle: Particle) => void;
  24255. private _stopSubEmitters();
  24256. private _createParticle;
  24257. private _removeFromRoot();
  24258. private _emitFromParticle;
  24259. private _update(newParticles);
  24260. private _getEffect();
  24261. /**
  24262. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24263. */
  24264. animate(): void;
  24265. private _appendParticleVertexes;
  24266. private _appenedParticleVertexesWithSheet(offset, particle);
  24267. private _appenedParticleVertexesNoSheet(offset, particle);
  24268. /**
  24269. * Rebuilds the particle system.
  24270. */
  24271. rebuild(): void;
  24272. /**
  24273. * Is this system ready to be used/rendered
  24274. * @return true if the system is ready
  24275. */
  24276. isReady(): boolean;
  24277. /**
  24278. * Renders the particle system in its current state.
  24279. * @returns the current number of particles
  24280. */
  24281. render(): number;
  24282. /**
  24283. * Disposes the particle system and free the associated resources
  24284. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24285. */
  24286. dispose(disposeTexture?: boolean): void;
  24287. /**
  24288. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  24289. * @param radius The radius of the sphere to emit from
  24290. * @returns the emitter
  24291. */
  24292. createSphereEmitter(radius?: number): SphereParticleEmitter;
  24293. /**
  24294. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  24295. * @param radius The radius of the sphere to emit from
  24296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24298. * @returns the emitter
  24299. */
  24300. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24301. /**
  24302. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  24303. * @param radius The radius of the cone to emit from
  24304. * @param angle The base angle of the cone
  24305. * @returns the emitter
  24306. */
  24307. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24308. /**
  24309. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24312. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24313. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24314. * @returns the emitter
  24315. */
  24316. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24317. /**
  24318. * Clones the particle system.
  24319. * @param name The name of the cloned object
  24320. * @param newEmitter The new emitter to use
  24321. * @returns the cloned particle system
  24322. */
  24323. clone(name: string, newEmitter: any): ParticleSystem;
  24324. /**
  24325. * Serializes the particle system to a JSON object.
  24326. * @returns the JSON object
  24327. */
  24328. serialize(): any;
  24329. /**
  24330. * Parses a JSON object to create a particle system.
  24331. * @param parsedParticleSystem The JSON object to parse
  24332. * @param scene The scene to create the particle system in
  24333. * @param rootUrl The root url to use to load external dependencies like texture
  24334. * @returns the Parsed particle system
  24335. */
  24336. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  24337. }
  24338. }
  24339. declare module BABYLON {
  24340. /**
  24341. * Represents one particle of a solid particle system.
  24342. */
  24343. class SolidParticle {
  24344. /**
  24345. * particle global index
  24346. */
  24347. idx: number;
  24348. /**
  24349. * The color of the particle
  24350. */
  24351. color: Nullable<Color4>;
  24352. /**
  24353. * The world space position of the particle.
  24354. */
  24355. position: Vector3;
  24356. /**
  24357. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24358. */
  24359. rotation: Vector3;
  24360. /**
  24361. * The world space rotation quaternion of the particle.
  24362. */
  24363. rotationQuaternion: Nullable<Quaternion>;
  24364. /**
  24365. * The scaling of the particle.
  24366. */
  24367. scaling: Vector3;
  24368. /**
  24369. * The uvs of the particle.
  24370. */
  24371. uvs: Vector4;
  24372. /**
  24373. * The current speed of the particle.
  24374. */
  24375. velocity: Vector3;
  24376. /**
  24377. * The pivot point in the particle local space.
  24378. */
  24379. pivot: Vector3;
  24380. /**
  24381. * Must the particle be translated from its pivot point in its local space ?
  24382. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24383. * Default : false
  24384. */
  24385. translateFromPivot: boolean;
  24386. /**
  24387. * Is the particle active or not ?
  24388. */
  24389. alive: boolean;
  24390. /**
  24391. * Is the particle visible or not ?
  24392. */
  24393. isVisible: boolean;
  24394. /**
  24395. * Index of this particle in the global "positions" array (Internal use)
  24396. */
  24397. _pos: number;
  24398. /**
  24399. * Index of this particle in the global "indices" array (Internal use)
  24400. */
  24401. _ind: number;
  24402. /**
  24403. * ModelShape of this particle (Internal use)
  24404. */
  24405. _model: ModelShape;
  24406. /**
  24407. * ModelShape id of this particle
  24408. */
  24409. shapeId: number;
  24410. /**
  24411. * Index of the particle in its shape id (Internal use)
  24412. */
  24413. idxInShape: number;
  24414. /**
  24415. * Reference to the shape model BoundingInfo object (Internal use)
  24416. */
  24417. _modelBoundingInfo: BoundingInfo;
  24418. /**
  24419. * Particle BoundingInfo object (Internal use)
  24420. */
  24421. _boundingInfo: BoundingInfo;
  24422. /**
  24423. * Reference to the SPS what the particle belongs to (Internal use)
  24424. */
  24425. _sps: SolidParticleSystem;
  24426. /**
  24427. * Still set as invisible in order to skip useless computations (Internal use)
  24428. */
  24429. _stillInvisible: boolean;
  24430. /**
  24431. * Last computed particle rotation matrix
  24432. */
  24433. _rotationMatrix: number[];
  24434. /**
  24435. * Parent particle Id, if any.
  24436. * Default null.
  24437. */
  24438. parentId: Nullable<number>;
  24439. /**
  24440. * Internal global position in the SPS.
  24441. */
  24442. _globalPosition: Vector3;
  24443. /**
  24444. * Creates a Solid Particle object.
  24445. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24446. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24447. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24448. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24449. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24450. * @param shapeId (integer) is the model shape identifier in the SPS.
  24451. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24452. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24453. */
  24454. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24455. /**
  24456. * Legacy support, changed scale to scaling
  24457. */
  24458. /**
  24459. * Legacy support, changed scale to scaling
  24460. */
  24461. scale: Vector3;
  24462. /**
  24463. * Legacy support, changed quaternion to rotationQuaternion
  24464. */
  24465. /**
  24466. * Legacy support, changed quaternion to rotationQuaternion
  24467. */
  24468. quaternion: Nullable<Quaternion>;
  24469. /**
  24470. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24471. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24472. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24473. * @returns true if it intersects
  24474. */
  24475. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24476. }
  24477. /**
  24478. * Represents the shape of the model used by one particle of a solid particle system.
  24479. * SPS internal tool, don't use it manually.
  24480. */
  24481. class ModelShape {
  24482. /**
  24483. * The shape id.
  24484. */
  24485. shapeID: number;
  24486. /**
  24487. * flat array of model positions (internal use)
  24488. */
  24489. _shape: Vector3[];
  24490. /**
  24491. * flat array of model UVs (internal use)
  24492. */
  24493. _shapeUV: number[];
  24494. /**
  24495. * length of the shape in the model indices array (internal use)
  24496. */
  24497. _indicesLength: number;
  24498. /**
  24499. * Custom position function (internal use)
  24500. */
  24501. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24502. /**
  24503. * Custom vertex function (internal use)
  24504. */
  24505. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24506. /**
  24507. * 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.
  24508. * SPS internal tool, don't use it manually.
  24509. * @ignore
  24510. */
  24511. 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>);
  24512. }
  24513. /**
  24514. * Represents a Depth Sorted Particle in the solid particle system.
  24515. */
  24516. class DepthSortedParticle {
  24517. /**
  24518. * Index of the particle in the "indices" array
  24519. */
  24520. ind: number;
  24521. /**
  24522. * Length of the particle shape in the "indices" array
  24523. */
  24524. indicesLength: number;
  24525. /**
  24526. * Squared distance from the particle to the camera
  24527. */
  24528. sqDistance: number;
  24529. }
  24530. }
  24531. declare module BABYLON {
  24532. /**
  24533. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24534. *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.
  24535. * The SPS is also a particle system. It provides some methods to manage the particles.
  24536. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24537. *
  24538. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24539. */
  24540. class SolidParticleSystem implements IDisposable {
  24541. /**
  24542. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24543. * Example : var p = SPS.particles[i];
  24544. */
  24545. particles: SolidParticle[];
  24546. /**
  24547. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24548. */
  24549. nbParticles: number;
  24550. /**
  24551. * If the particles must ever face the camera (default false). Useful for planar particles.
  24552. */
  24553. billboard: boolean;
  24554. /**
  24555. * Recompute normals when adding a shape
  24556. */
  24557. recomputeNormals: boolean;
  24558. /**
  24559. * This a counter ofr your own usage. It's not set by any SPS functions.
  24560. */
  24561. counter: number;
  24562. /**
  24563. * The SPS name. This name is also given to the underlying mesh.
  24564. */
  24565. name: string;
  24566. /**
  24567. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24568. */
  24569. mesh: Mesh;
  24570. /**
  24571. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24572. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24573. */
  24574. vars: any;
  24575. /**
  24576. * This array is populated when the SPS is set as 'pickable'.
  24577. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24578. * Each element of this array is an object `{idx: int, faceId: int}`.
  24579. * `idx` is the picked particle index in the `SPS.particles` array
  24580. * `faceId` is the picked face index counted within this particle.
  24581. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24582. */
  24583. pickedParticles: {
  24584. idx: number;
  24585. faceId: number;
  24586. }[];
  24587. /**
  24588. * This array is populated when `enableDepthSort` is set to true.
  24589. * Each element of this array is an instance of the class DepthSortedParticle.
  24590. */
  24591. depthSortedParticles: DepthSortedParticle[];
  24592. /**
  24593. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24594. */
  24595. _bSphereOnly: boolean;
  24596. /**
  24597. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24598. */
  24599. _bSphereRadiusFactor: number;
  24600. private _scene;
  24601. private _positions;
  24602. private _indices;
  24603. private _normals;
  24604. private _colors;
  24605. private _uvs;
  24606. private _indices32;
  24607. private _positions32;
  24608. private _normals32;
  24609. private _fixedNormal32;
  24610. private _colors32;
  24611. private _uvs32;
  24612. private _index;
  24613. private _updatable;
  24614. private _pickable;
  24615. private _isVisibilityBoxLocked;
  24616. private _alwaysVisible;
  24617. private _depthSort;
  24618. private _shapeCounter;
  24619. private _copy;
  24620. private _shape;
  24621. private _shapeUV;
  24622. private _color;
  24623. private _computeParticleColor;
  24624. private _computeParticleTexture;
  24625. private _computeParticleRotation;
  24626. private _computeParticleVertex;
  24627. private _computeBoundingBox;
  24628. private _depthSortParticles;
  24629. private _cam_axisZ;
  24630. private _cam_axisY;
  24631. private _cam_axisX;
  24632. private _axisZ;
  24633. private _camera;
  24634. private _particle;
  24635. private _camDir;
  24636. private _camInvertedPosition;
  24637. private _rotMatrix;
  24638. private _invertMatrix;
  24639. private _rotated;
  24640. private _quaternion;
  24641. private _vertex;
  24642. private _normal;
  24643. private _yaw;
  24644. private _pitch;
  24645. private _roll;
  24646. private _halfroll;
  24647. private _halfpitch;
  24648. private _halfyaw;
  24649. private _sinRoll;
  24650. private _cosRoll;
  24651. private _sinPitch;
  24652. private _cosPitch;
  24653. private _sinYaw;
  24654. private _cosYaw;
  24655. private _mustUnrotateFixedNormals;
  24656. private _minimum;
  24657. private _maximum;
  24658. private _minBbox;
  24659. private _maxBbox;
  24660. private _particlesIntersect;
  24661. private _depthSortFunction;
  24662. private _needs32Bits;
  24663. private _pivotBackTranslation;
  24664. private _scaledPivot;
  24665. private _particleHasParent;
  24666. private _parent;
  24667. /**
  24668. * Creates a SPS (Solid Particle System) object.
  24669. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24670. * @param scene (Scene) is the scene in which the SPS is added.
  24671. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24672. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24673. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24674. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24675. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24676. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24677. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24678. */
  24679. constructor(name: string, scene: Scene, options?: {
  24680. updatable?: boolean;
  24681. isPickable?: boolean;
  24682. enableDepthSort?: boolean;
  24683. particleIntersection?: boolean;
  24684. boundingSphereOnly?: boolean;
  24685. bSphereRadiusFactor?: number;
  24686. });
  24687. /**
  24688. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24689. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24690. * @returns the created mesh
  24691. */
  24692. buildMesh(): Mesh;
  24693. /**
  24694. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24695. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24696. * Thus the particles generated from `digest()` have their property `position` set yet.
  24697. * @param mesh ( Mesh ) is the mesh to be digested
  24698. * @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
  24699. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24700. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24701. * @returns the current SPS
  24702. */
  24703. digest(mesh: Mesh, options?: {
  24704. facetNb?: number;
  24705. number?: number;
  24706. delta?: number;
  24707. }): SolidParticleSystem;
  24708. private _unrotateFixedNormals();
  24709. private _resetCopy();
  24710. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  24711. private _posToShape(positions);
  24712. private _uvsToShapeUV(uvs);
  24713. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  24714. /**
  24715. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24716. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24717. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24718. * @param nb (positive integer) the number of particles to be created from this model
  24719. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24720. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24721. * @returns the number of shapes in the system
  24722. */
  24723. addShape(mesh: Mesh, nb: number, options?: {
  24724. positionFunction?: any;
  24725. vertexFunction?: any;
  24726. }): number;
  24727. private _rebuildParticle(particle);
  24728. /**
  24729. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24730. * @returns the SPS.
  24731. */
  24732. rebuildMesh(): SolidParticleSystem;
  24733. /**
  24734. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24735. * This method calls `updateParticle()` for each particle of the SPS.
  24736. * For an animated SPS, it is usually called within the render loop.
  24737. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24738. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24739. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24740. * @returns the SPS.
  24741. */
  24742. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24743. private _quaternionRotationYPR();
  24744. private _quaternionToRotationMatrix();
  24745. /**
  24746. * Disposes the SPS.
  24747. */
  24748. dispose(): void;
  24749. /**
  24750. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24751. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24752. * @returns the SPS.
  24753. */
  24754. refreshVisibleSize(): SolidParticleSystem;
  24755. /**
  24756. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24757. * @param size the size (float) of the visibility box
  24758. * note : this doesn't lock the SPS mesh bounding box.
  24759. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24760. */
  24761. setVisibilityBox(size: number): void;
  24762. /**
  24763. * Gets whether the SPS as always visible or not
  24764. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24765. */
  24766. /**
  24767. * Sets the SPS as always visible or not
  24768. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24769. */
  24770. isAlwaysVisible: boolean;
  24771. /**
  24772. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24774. */
  24775. /**
  24776. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24777. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24778. */
  24779. isVisibilityBoxLocked: boolean;
  24780. /**
  24781. * Gets if `setParticles()` computes the particle rotations or not.
  24782. * Default value : true. The SPS is faster when it's set to false.
  24783. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24784. */
  24785. /**
  24786. * Tells to `setParticles()` to compute the particle rotations or not.
  24787. * Default value : true. The SPS is faster when it's set to false.
  24788. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24789. */
  24790. computeParticleRotation: boolean;
  24791. /**
  24792. * Gets if `setParticles()` computes the particle colors or not.
  24793. * Default value : true. The SPS is faster when it's set to false.
  24794. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24795. */
  24796. /**
  24797. * Tells to `setParticles()` to compute the particle colors or not.
  24798. * Default value : true. The SPS is faster when it's set to false.
  24799. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24800. */
  24801. computeParticleColor: boolean;
  24802. /**
  24803. * Gets if `setParticles()` computes the particle textures or not.
  24804. * Default value : true. The SPS is faster when it's set to false.
  24805. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24806. */
  24807. computeParticleTexture: boolean;
  24808. /**
  24809. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24810. * Default value : false. The SPS is faster when it's set to false.
  24811. * Note : the particle custom vertex positions aren't stored values.
  24812. */
  24813. /**
  24814. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24815. * Default value : false. The SPS is faster when it's set to false.
  24816. * Note : the particle custom vertex positions aren't stored values.
  24817. */
  24818. computeParticleVertex: boolean;
  24819. /**
  24820. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24821. */
  24822. /**
  24823. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24824. */
  24825. computeBoundingBox: boolean;
  24826. /**
  24827. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24828. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24829. * Default : `true`
  24830. */
  24831. /**
  24832. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24833. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24834. * Default : `true`
  24835. */
  24836. depthSortParticles: boolean;
  24837. /**
  24838. * This function does nothing. It may be overwritten to set all the particle first values.
  24839. * The SPS doesn't call this function, you may have to call it by your own.
  24840. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24841. */
  24842. initParticles(): void;
  24843. /**
  24844. * This function does nothing. It may be overwritten to recycle a particle.
  24845. * The SPS doesn't call this function, you may have to call it by your own.
  24846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24847. * @param particle The particle to recycle
  24848. * @returns the recycled particle
  24849. */
  24850. recycleParticle(particle: SolidParticle): SolidParticle;
  24851. /**
  24852. * Updates a particle : this function should be overwritten by the user.
  24853. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24854. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24855. * @example : just set a particle position or velocity and recycle conditions
  24856. * @param particle The particle to update
  24857. * @returns the updated particle
  24858. */
  24859. updateParticle(particle: SolidParticle): SolidParticle;
  24860. /**
  24861. * Updates a vertex of a particle : it can be overwritten by the user.
  24862. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24863. * @param particle the current particle
  24864. * @param vertex the current index of the current particle
  24865. * @param pt the index of the current vertex in the particle shape
  24866. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24867. * @example : just set a vertex particle position
  24868. * @returns the updated vertex
  24869. */
  24870. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24871. /**
  24872. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24873. * This does nothing and may be overwritten by the user.
  24874. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24875. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24876. * @param update the boolean update value actually passed to setParticles()
  24877. */
  24878. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24879. /**
  24880. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24881. * This will be passed three parameters.
  24882. * This does nothing and may be overwritten by the user.
  24883. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24885. * @param update the boolean update value actually passed to setParticles()
  24886. */
  24887. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24888. }
  24889. }
  24890. declare module BABYLON {
  24891. interface PhysicsImpostorJoint {
  24892. mainImpostor: PhysicsImpostor;
  24893. connectedImpostor: PhysicsImpostor;
  24894. joint: PhysicsJoint;
  24895. }
  24896. class PhysicsEngine {
  24897. private _physicsPlugin;
  24898. gravity: Vector3;
  24899. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24900. setGravity(gravity: Vector3): void;
  24901. /**
  24902. * Set the time step of the physics engine.
  24903. * default is 1/60.
  24904. * To slow it down, enter 1/600 for example.
  24905. * To speed it up, 1/30
  24906. * @param {number} newTimeStep the new timestep to apply to this world.
  24907. */
  24908. setTimeStep(newTimeStep?: number): void;
  24909. /**
  24910. * Get the time step of the physics engine.
  24911. */
  24912. getTimeStep(): number;
  24913. dispose(): void;
  24914. getPhysicsPluginName(): string;
  24915. static Epsilon: number;
  24916. private _impostors;
  24917. private _joints;
  24918. /**
  24919. * Adding a new impostor for the impostor tracking.
  24920. * This will be done by the impostor itself.
  24921. * @param {PhysicsImpostor} impostor the impostor to add
  24922. */
  24923. addImpostor(impostor: PhysicsImpostor): void;
  24924. /**
  24925. * Remove an impostor from the engine.
  24926. * This impostor and its mesh will not longer be updated by the physics engine.
  24927. * @param {PhysicsImpostor} impostor the impostor to remove
  24928. */
  24929. removeImpostor(impostor: PhysicsImpostor): void;
  24930. /**
  24931. * Add a joint to the physics engine
  24932. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24933. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24934. * @param {PhysicsJoint} the joint that will connect both impostors.
  24935. */
  24936. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24937. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24938. /**
  24939. * Called by the scene. no need to call it.
  24940. */
  24941. _step(delta: number): void;
  24942. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24943. getImpostors(): Array<PhysicsImpostor>;
  24944. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24945. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24946. }
  24947. interface IPhysicsEnginePlugin {
  24948. world: any;
  24949. name: string;
  24950. setGravity(gravity: Vector3): void;
  24951. setTimeStep(timeStep: number): void;
  24952. getTimeStep(): number;
  24953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24956. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24957. removePhysicsBody(impostor: PhysicsImpostor): void;
  24958. generateJoint(joint: PhysicsImpostorJoint): void;
  24959. removeJoint(joint: PhysicsImpostorJoint): void;
  24960. isSupported(): boolean;
  24961. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24962. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24963. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24964. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24965. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24966. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24967. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24968. getBodyMass(impostor: PhysicsImpostor): number;
  24969. getBodyFriction(impostor: PhysicsImpostor): number;
  24970. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24971. getBodyRestitution(impostor: PhysicsImpostor): number;
  24972. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24973. sleepBody(impostor: PhysicsImpostor): void;
  24974. wakeUpBody(impostor: PhysicsImpostor): void;
  24975. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24976. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24977. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24978. getRadius(impostor: PhysicsImpostor): number;
  24979. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24980. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24981. dispose(): void;
  24982. }
  24983. }
  24984. declare module BABYLON {
  24985. class PhysicsHelper {
  24986. private _scene;
  24987. private _physicsEngine;
  24988. constructor(scene: Scene);
  24989. /**
  24990. * @param {Vector3} origin the origin of the explosion
  24991. * @param {number} radius the explosion radius
  24992. * @param {number} strength the explosion strength
  24993. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24994. */
  24995. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24996. /**
  24997. * @param {Vector3} origin the origin of the explosion
  24998. * @param {number} radius the explosion radius
  24999. * @param {number} strength the explosion strength
  25000. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25001. */
  25002. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25003. /**
  25004. * @param {Vector3} origin the origin of the explosion
  25005. * @param {number} radius the explosion radius
  25006. * @param {number} strength the explosion strength
  25007. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25008. */
  25009. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25010. /**
  25011. * @param {Vector3} origin the origin of the updraft
  25012. * @param {number} radius the radius of the updraft
  25013. * @param {number} strength the strength of the updraft
  25014. * @param {number} height the height of the updraft
  25015. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  25016. */
  25017. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  25018. /**
  25019. * @param {Vector3} origin the of the vortex
  25020. * @param {number} radius the radius of the vortex
  25021. * @param {number} strength the strength of the vortex
  25022. * @param {number} height the height of the vortex
  25023. */
  25024. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  25025. }
  25026. /***** Radial explosion *****/
  25027. class PhysicsRadialExplosionEvent {
  25028. private _scene;
  25029. private _sphere;
  25030. private _sphereOptions;
  25031. private _rays;
  25032. private _dataFetched;
  25033. constructor(scene: Scene);
  25034. /**
  25035. * Returns the data related to the radial explosion event (sphere & rays).
  25036. * @returns {PhysicsRadialExplosionEventData}
  25037. */
  25038. getData(): PhysicsRadialExplosionEventData;
  25039. /**
  25040. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  25041. * @param impostor
  25042. * @param {Vector3} origin the origin of the explosion
  25043. * @param {number} radius the explosion radius
  25044. * @param {number} strength the explosion strength
  25045. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  25046. * @returns {Nullable<PhysicsForceAndContactPoint>}
  25047. */
  25048. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  25049. /**
  25050. * Disposes the sphere.
  25051. * @param {bolean} force
  25052. */
  25053. dispose(force?: boolean): void;
  25054. /*** Helpers ***/
  25055. private _prepareSphere();
  25056. private _intersectsWithSphere(impostor, origin, radius);
  25057. }
  25058. /***** Gravitational Field *****/
  25059. class PhysicsGravitationalFieldEvent {
  25060. private _physicsHelper;
  25061. private _scene;
  25062. private _origin;
  25063. private _radius;
  25064. private _strength;
  25065. private _falloff;
  25066. private _tickCallback;
  25067. private _sphere;
  25068. private _dataFetched;
  25069. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  25070. /**
  25071. * Returns the data related to the gravitational field event (sphere).
  25072. * @returns {PhysicsGravitationalFieldEventData}
  25073. */
  25074. getData(): PhysicsGravitationalFieldEventData;
  25075. /**
  25076. * Enables the gravitational field.
  25077. */
  25078. enable(): void;
  25079. /**
  25080. * Disables the gravitational field.
  25081. */
  25082. disable(): void;
  25083. /**
  25084. * Disposes the sphere.
  25085. * @param {bolean} force
  25086. */
  25087. dispose(force?: boolean): void;
  25088. private _tick();
  25089. }
  25090. /***** Updraft *****/
  25091. class PhysicsUpdraftEvent {
  25092. private _scene;
  25093. private _origin;
  25094. private _radius;
  25095. private _strength;
  25096. private _height;
  25097. private _updraftMode;
  25098. private _physicsEngine;
  25099. private _originTop;
  25100. private _originDirection;
  25101. private _tickCallback;
  25102. private _cylinder;
  25103. private _cylinderPosition;
  25104. private _dataFetched;
  25105. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  25106. /**
  25107. * Returns the data related to the updraft event (cylinder).
  25108. * @returns {PhysicsUpdraftEventData}
  25109. */
  25110. getData(): PhysicsUpdraftEventData;
  25111. /**
  25112. * Enables the updraft.
  25113. */
  25114. enable(): void;
  25115. /**
  25116. * Disables the cortex.
  25117. */
  25118. disable(): void;
  25119. /**
  25120. * Disposes the sphere.
  25121. * @param {bolean} force
  25122. */
  25123. dispose(force?: boolean): void;
  25124. private getImpostorForceAndContactPoint(impostor);
  25125. private _tick();
  25126. /*** Helpers ***/
  25127. private _prepareCylinder();
  25128. private _intersectsWithCylinder(impostor);
  25129. }
  25130. /***** Vortex *****/
  25131. class PhysicsVortexEvent {
  25132. private _scene;
  25133. private _origin;
  25134. private _radius;
  25135. private _strength;
  25136. private _height;
  25137. private _physicsEngine;
  25138. private _originTop;
  25139. private _centripetalForceThreshold;
  25140. private _updraftMultiplier;
  25141. private _tickCallback;
  25142. private _cylinder;
  25143. private _cylinderPosition;
  25144. private _dataFetched;
  25145. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  25146. /**
  25147. * Returns the data related to the vortex event (cylinder).
  25148. * @returns {PhysicsVortexEventData}
  25149. */
  25150. getData(): PhysicsVortexEventData;
  25151. /**
  25152. * Enables the vortex.
  25153. */
  25154. enable(): void;
  25155. /**
  25156. * Disables the cortex.
  25157. */
  25158. disable(): void;
  25159. =======
  25160. * This represents a particle system in Babylon.
  25161. * 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.
  25162. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25163. * @example https://doc.babylonjs.com/babylon101/particles
  25164. */
  25165. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25166. /**
  25167. * Source color is added to the destination color without alpha affecting the result.
  25168. */
  25169. static BLENDMODE_ONEONE: number;
  25170. /**
  25171. * Blend current color and particle color using particle’s alpha.
  25172. */
  25173. static BLENDMODE_STANDARD: number;
  25174. /**
  25175. * List of animations used by the particle system.
  25176. */
  25177. animations: Animation[];
  25178. /**
  25179. * The id of the Particle system.
  25180. */
  25181. id: string;
  25182. /**
  25183. * The friendly name of the Particle system.
  25184. */
  25185. name: string;
  25186. /**
  25187. * The rendering group used by the Particle system to chose when to render.
  25188. */
  25189. renderingGroupId: number;
  25190. /**
  25191. * The emitter represents the Mesh or position we are attaching the particle system to.
  25192. */
  25193. emitter: Nullable<AbstractMesh | Vector3>;
  25194. /**
  25195. * The maximum number of particles to emit per frame
  25196. */
  25197. emitRate: number;
  25198. /**
  25199. * If you want to launch only a few particles at once, that can be done, as well.
  25200. */
  25201. manualEmitCount: number;
  25202. /**
  25203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25204. */
  25205. updateSpeed: number;
  25206. /**
  25207. * The amount of time the particle system is running (depends of the overall update speed).
  25208. */
  25209. targetStopDuration: number;
  25210. /**
  25211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  25212. */
  25213. disposeOnStop: boolean;
  25214. /**
  25215. * Minimum power of emitting particles.
  25216. */
  25217. minEmitPower: number;
  25218. /**
  25219. * Maximum power of emitting particles.
  25220. */
  25221. maxEmitPower: number;
  25222. /**
  25223. * Minimum life time of emitting particles.
  25224. */
  25225. minLifeTime: number;
  25226. /**
  25227. * Maximum life time of emitting particles.
  25228. */
  25229. maxLifeTime: number;
  25230. /**
  25231. * Minimum Size of emitting particles.
  25232. */
  25233. minSize: number;
  25234. /**
  25235. * Maximum Size of emitting particles.
  25236. */
  25237. maxSize: number;
  25238. /**
  25239. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25240. */
  25241. minAngularSpeed: number;
  25242. /**
  25243. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25244. */
  25245. maxAngularSpeed: number;
  25246. /**
  25247. * The texture used to render each particle. (this can be a spritesheet)
  25248. */
  25249. particleTexture: Nullable<Texture>;
  25250. /**
  25251. * The layer mask we are rendering the particles through.
  25252. */
  25253. layerMask: number;
  25254. /**
  25255. * This can help using your own shader to render the particle system.
  25256. * The according effect will be created
  25257. */
  25258. customShader: any;
  25259. /**
  25260. * By default particle system starts as soon as they are created. This prevents the
  25261. * automatic start to happen and let you decide when to start emitting particles.
  25262. */
  25263. preventAutoStart: boolean;
  25264. /**
  25265. * This function can be defined to provide custom update for active particles.
  25266. * This function will be called instead of regular update (age, position, color, etc.).
  25267. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25268. */
  25269. updateFunction: (particles: Particle[]) => void;
  25270. /**
  25271. * Callback triggered when the particle animation is ending.
  25272. */
  25273. onAnimationEnd: Nullable<() => void>;
  25274. /**
  25275. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  25276. */
  25277. blendMode: number;
  25278. /**
  25279. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25280. * to override the particles.
  25281. */
  25282. forceDepthWrite: boolean;
  25283. /**
  25284. * You can use gravity if you want to give an orientation to your particles.
  25285. */
  25286. gravity: Vector3;
  25287. /**
  25288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25289. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25290. */
  25291. direction1: Vector3;
  25292. /**
  25293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25295. */
  25296. direction2: Vector3;
  25297. /**
  25298. * 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.
  25299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25300. */
  25301. minEmitBox: Vector3;
  25302. /**
  25303. * 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.
  25304. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25305. */
  25306. maxEmitBox: Vector3;
  25307. /**
  25308. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25309. */
  25310. color1: Color4;
  25311. /**
  25312. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25313. */
  25314. color2: Color4;
  25315. /**
  25316. * Color the particle will have at the end of its lifetime.
  25317. */
  25318. colorDead: Color4;
  25319. /**
  25320. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  25321. */
  25322. textureMask: Color4;
  25323. /**
  25324. * The particle emitter type defines the emitter used by the particle system.
  25325. * It can be for example box, sphere, or cone...
  25326. */
  25327. particleEmitterType: IParticleEmitterType;
  25328. /**
  25329. * This function can be defined to specify initial direction for every new particle.
  25330. * It by default use the emitterType defined function.
  25331. */
  25332. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25333. /**
  25334. * This function can be defined to specify initial position for every new particle.
  25335. * It by default use the emitterType defined function.
  25336. */
  25337. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25338. /**
  25339. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  25340. */
  25341. spriteCellLoop: boolean;
  25342. /**
  25343. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  25344. */
  25345. spriteCellChangeSpeed: number;
  25346. /**
  25347. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  25348. */
  25349. startSpriteCellID: number;
  25350. /**
  25351. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  25352. */
  25353. endSpriteCellID: number;
  25354. /**
  25355. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  25356. */
  25357. spriteCellWidth: number;
  25358. /**
  25359. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  25360. */
  25361. spriteCellHeight: number;
  25362. /**
  25363. * An event triggered when the system is disposed.
  25364. */
  25365. onDisposeObservable: Observable<ParticleSystem>;
  25366. private _onDisposeObserver;
  25367. /**
  25368. * Sets a callback that will be triggered when the system is disposed.
  25369. */
  25370. onDispose: () => void;
  25371. /**
  25372. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  25373. */
  25374. readonly isAnimationSheetEnabled: Boolean;
  25375. private _particles;
  25376. private _epsilon;
  25377. private _capacity;
  25378. private _scene;
  25379. private _stockParticles;
  25380. private _newPartsExcess;
  25381. private _vertexData;
  25382. private _vertexBuffer;
  25383. private _vertexBuffers;
  25384. private _indexBuffer;
  25385. private _effect;
  25386. private _customEffect;
  25387. private _cachedDefines;
  25388. private _scaledColorStep;
  25389. private _colorDiff;
  25390. private _scaledDirection;
  25391. private _scaledGravity;
  25392. private _currentRenderId;
  25393. private _alive;
  25394. private _started;
  25395. private _stopped;
  25396. private _actualFrame;
  25397. private _scaledUpdateSpeed;
  25398. private _vertexBufferSize;
  25399. private _isAnimationSheetEnabled;
  25400. /**
  25401. * 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.
  25402. */
  25403. subEmitters: ParticleSystem[];
  25404. /**
  25405. * The current active Sub-systems, this property is used by the root particle system only.
  25406. */
  25407. activeSubSystems: Array<ParticleSystem>;
  25408. private _rootParticleSystem;
  25409. /**
  25410. * Gets the current list of active particles
  25411. */
  25412. readonly particles: Particle[];
  25413. /**
  25414. * Returns the string "ParticleSystem"
  25415. * @returns a string containing the class name
  25416. */
  25417. getClassName(): string;
  25418. /**
  25419. * Instantiates a particle system.
  25420. * 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.
  25421. * @param name The name of the particle system
  25422. * @param capacity The max number of particles alive at the same time
  25423. * @param scene The scene the particle system belongs to
  25424. * @param customEffect a custom effect used to change the way particles are rendered by default
  25425. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25426. * @param epsilon Offset used to render the particles
  25427. */
  25428. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25429. private _createIndexBuffer();
  25430. /**
  25431. * Gets the maximum number of particles active at the same time.
  25432. * @returns The max number of active particles.
  25433. */
  25434. getCapacity(): number;
  25435. /**
  25436. * Gets Wether there are still active particles in the system.
  25437. * @returns True if it is alive, otherwise false.
  25438. */
  25439. isAlive(): boolean;
  25440. /**
  25441. * Gets Wether the system has been started.
  25442. * @returns True if it has been started, otherwise false.
  25443. */
  25444. isStarted(): boolean;
  25445. /**
  25446. * Starts the particle system and begins to emit.
  25447. */
  25448. start(): void;
  25449. /**
  25450. * Stops the particle system.
  25451. * @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.
  25452. */
  25453. stop(stopSubEmitters?: boolean): void;
  25454. /**
  25455. * Remove all active particles
  25456. */
  25457. reset(): void;
  25458. /**
  25459. * @ignore (for internal use only)
  25460. */
  25461. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25462. /**
  25463. * @ignore (for internal use only)
  25464. */
  25465. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25466. /**
  25467. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25468. * Its lifetime will start back at 0.
  25469. */
  25470. recycleParticle: (particle: Particle) => void;
  25471. private _stopSubEmitters();
  25472. private _createParticle;
  25473. private _removeFromRoot();
  25474. private _emitFromParticle;
  25475. private _update(newParticles);
  25476. private _getEffect();
  25477. /**
  25478. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25479. */
  25480. animate(): void;
  25481. private _appendParticleVertexes;
  25482. private _appenedParticleVertexesWithSheet(offset, particle);
  25483. private _appenedParticleVertexesNoSheet(offset, particle);
  25484. /**
  25485. * Rebuilds the particle system.
  25486. */
  25487. rebuild(): void;
  25488. /**
  25489. * Is this system ready to be used/rendered
  25490. * @return true if the system is ready
  25491. */
  25492. isReady(): boolean;
  25493. /**
  25494. * Renders the particle system in its current state.
  25495. * @returns the current number of particles
  25496. */
  25497. render(): number;
  25498. /**
  25499. * Disposes the particle system and free the associated resources
  25500. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25501. */
  25502. dispose(disposeTexture?: boolean): void;
  25503. /**
  25504. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  25505. * @param radius The radius of the sphere to emit from
  25506. * @returns the emitter
  25507. */
  25508. createSphereEmitter(radius?: number): SphereParticleEmitter;
  25509. /**
  25510. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  25511. * @param radius The radius of the sphere to emit from
  25512. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25513. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25514. * @returns the emitter
  25515. */
  25516. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25517. /**
  25518. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  25519. * @param radius The radius of the cone to emit from
  25520. * @param angle The base angle of the cone
  25521. * @returns the emitter
  25522. */
  25523. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25524. /**
  25525. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25528. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25529. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25530. * @returns the emitter
  25531. */
  25532. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25533. /**
  25534. * Clones the particle system.
  25535. * @param name The name of the cloned object
  25536. * @param newEmitter The new emitter to use
  25537. * @returns the cloned particle system
  25538. */
  25539. clone(name: string, newEmitter: any): ParticleSystem;
  25540. /**
  25541. * Serializes the particle system to a JSON object.
  25542. * @returns the JSON object
  25543. */
  25544. serialize(): any;
  25545. /**
  25546. * Parses a JSON object to create a particle system.
  25547. * @param parsedParticleSystem The JSON object to parse
  25548. * @param scene The scene to create the particle system in
  25549. * @param rootUrl The root url to use to load external dependencies like texture
  25550. * @returns the Parsed particle system
  25551. */
  25552. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25553. }
  25554. }
  25555. declare module BABYLON {
  25556. /**
  25557. * Represents one particle of a solid particle system.
  25558. * @see SolidParticleSystem
  25559. */
  25560. class SolidParticle {
  25561. /**
  25562. * particle global index
  25563. */
  25564. idx: number;
  25565. /**
  25566. * The color of the particle
  25567. */
  25568. color: Nullable<Color4>;
  25569. /**
  25570. * The world space position of the particle.
  25571. */
  25572. position: Vector3;
  25573. /**
  25574. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25575. */
  25576. rotation: Vector3;
  25577. /**
  25578. * The world space rotation quaternion of the particle.
  25579. */
  25580. rotationQuaternion: Nullable<Quaternion>;
  25581. /**
  25582. * The scaling of the particle.
  25583. */
  25584. scaling: Vector3;
  25585. /**
  25586. * The uvs of the particle.
  25587. */
  25588. uvs: Vector4;
  25589. /**
  25590. * The current speed of the particle.
  25591. */
  25592. velocity: Vector3;
  25593. /**
  25594. * The pivot point in the particle local space.
  25595. */
  25596. pivot: Vector3;
  25597. /**
  25598. * Must the particle be translated from its pivot point in its local space ?
  25599. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25600. * Default : false
  25601. */
  25602. translateFromPivot: boolean;
  25603. /**
  25604. * Is the particle active or not ?
  25605. */
  25606. alive: boolean;
  25607. /**
  25608. * Is the particle visible or not ?
  25609. */
  25610. isVisible: boolean;
  25611. /**
  25612. * Index of this particle in the global "positions" array (Internal use)
  25613. */
  25614. _pos: number;
  25615. /**
  25616. * Index of this particle in the global "indices" array (Internal use)
  25617. */
  25618. _ind: number;
  25619. /**
  25620. * ModelShape of this particle (Internal use)
  25621. */
  25622. _model: ModelShape;
  25623. /**
  25624. * ModelShape id of this particle
  25625. */
  25626. shapeId: number;
  25627. /**
  25628. * Index of the particle in its shape id (Internal use)
  25629. */
  25630. idxInShape: number;
  25631. /**
  25632. * Reference to the shape model BoundingInfo object (Internal use)
  25633. */
  25634. _modelBoundingInfo: BoundingInfo;
  25635. /**
  25636. * Particle BoundingInfo object (Internal use)
  25637. */
  25638. _boundingInfo: BoundingInfo;
  25639. /**
  25640. * Reference to the SPS what the particle belongs to (Internal use)
  25641. */
  25642. _sps: SolidParticleSystem;
  25643. /**
  25644. * Still set as invisible in order to skip useless computations (Internal use)
  25645. */
  25646. _stillInvisible: boolean;
  25647. /**
  25648. * Last computed particle rotation matrix
  25649. */
  25650. _rotationMatrix: number[];
  25651. /**
  25652. * Parent particle Id, if any.
  25653. * Default null.
  25654. */
  25655. parentId: Nullable<number>;
  25656. /**
  25657. * Internal global position in the SPS.
  25658. */
  25659. _globalPosition: Vector3;
  25660. /**
  25661. * Creates a Solid Particle object.
  25662. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25663. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25664. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25665. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25666. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25667. * @param shapeId (integer) is the model shape identifier in the SPS.
  25668. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25669. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25670. */
  25671. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25672. /**
  25673. * Legacy support, changed scale to scaling
  25674. */
  25675. /**
  25676. * Legacy support, changed scale to scaling
  25677. */
  25678. scale: Vector3;
  25679. /**
  25680. * Legacy support, changed quaternion to rotationQuaternion
  25681. */
  25682. /**
  25683. * Legacy support, changed quaternion to rotationQuaternion
  25684. */
  25685. quaternion: Nullable<Quaternion>;
  25686. /**
  25687. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25688. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25689. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25690. * @returns true if it intersects
  25691. */
  25692. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25693. }
  25694. /**
  25695. * Represents the shape of the model used by one particle of a solid particle system.
  25696. * SPS internal tool, don't use it manually.
  25697. * @see SolidParticleSystem
  25698. */
  25699. class ModelShape {
  25700. /**
  25701. * The shape id.
  25702. */
  25703. shapeID: number;
  25704. /**
  25705. * flat array of model positions (internal use)
  25706. */
  25707. _shape: Vector3[];
  25708. /**
  25709. * flat array of model UVs (internal use)
  25710. */
  25711. _shapeUV: number[];
  25712. /**
  25713. * length of the shape in the model indices array (internal use)
  25714. */
  25715. _indicesLength: number;
  25716. /**
  25717. * Custom position function (internal use)
  25718. */
  25719. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25720. /**
  25721. * Custom vertex function (internal use)
  25722. */
  25723. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25724. /**
  25725. * 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.
  25726. * SPS internal tool, don't use it manually.
  25727. * @ignore
  25728. */
  25729. 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>);
  25730. }
  25731. /**
  25732. * Represents a Depth Sorted Particle in the solid particle system.
  25733. * @see SolidParticleSystem
  25734. */
  25735. class DepthSortedParticle {
  25736. /**
  25737. * Index of the particle in the "indices" array
  25738. */
  25739. ind: number;
  25740. /**
  25741. * Length of the particle shape in the "indices" array
  25742. */
  25743. indicesLength: number;
  25744. /**
  25745. * Squared distance from the particle to the camera
  25746. */
  25747. sqDistance: number;
  25748. }
  25749. }
  25750. declare module BABYLON {
  25751. /**
  25752. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25753. *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.
  25754. * The SPS is also a particle system. It provides some methods to manage the particles.
  25755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25756. *
  25757. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25758. */
  25759. class SolidParticleSystem implements IDisposable {
  25760. /**
  25761. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25762. * Example : var p = SPS.particles[i];
  25763. */
  25764. particles: SolidParticle[];
  25765. /**
  25766. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25767. */
  25768. nbParticles: number;
  25769. /**
  25770. * If the particles must ever face the camera (default false). Useful for planar particles.
  25771. */
  25772. billboard: boolean;
  25773. /**
  25774. * Recompute normals when adding a shape
  25775. */
  25776. recomputeNormals: boolean;
  25777. /**
  25778. * This a counter ofr your own usage. It's not set by any SPS functions.
  25779. */
  25780. counter: number;
  25781. /**
  25782. * The SPS name. This name is also given to the underlying mesh.
  25783. */
  25784. name: string;
  25785. /**
  25786. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25787. */
  25788. mesh: Mesh;
  25789. /**
  25790. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25791. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25792. */
  25793. vars: any;
  25794. /**
  25795. * This array is populated when the SPS is set as 'pickable'.
  25796. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25797. * Each element of this array is an object `{idx: int, faceId: int}`.
  25798. * `idx` is the picked particle index in the `SPS.particles` array
  25799. * `faceId` is the picked face index counted within this particle.
  25800. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25801. */
  25802. pickedParticles: {
  25803. idx: number;
  25804. faceId: number;
  25805. }[];
  25806. /**
  25807. * This array is populated when `enableDepthSort` is set to true.
  25808. * Each element of this array is an instance of the class DepthSortedParticle.
  25809. */
  25810. depthSortedParticles: DepthSortedParticle[];
  25811. /**
  25812. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25813. */
  25814. _bSphereOnly: boolean;
  25815. /**
  25816. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25817. */
  25818. _bSphereRadiusFactor: number;
  25819. private _scene;
  25820. private _positions;
  25821. private _indices;
  25822. private _normals;
  25823. private _colors;
  25824. private _uvs;
  25825. private _indices32;
  25826. private _positions32;
  25827. private _normals32;
  25828. private _fixedNormal32;
  25829. private _colors32;
  25830. private _uvs32;
  25831. private _index;
  25832. private _updatable;
  25833. private _pickable;
  25834. private _isVisibilityBoxLocked;
  25835. private _alwaysVisible;
  25836. private _depthSort;
  25837. private _shapeCounter;
  25838. private _copy;
  25839. private _shape;
  25840. private _shapeUV;
  25841. private _color;
  25842. private _computeParticleColor;
  25843. private _computeParticleTexture;
  25844. private _computeParticleRotation;
  25845. private _computeParticleVertex;
  25846. private _computeBoundingBox;
  25847. private _depthSortParticles;
  25848. private _cam_axisZ;
  25849. private _cam_axisY;
  25850. private _cam_axisX;
  25851. private _axisZ;
  25852. private _camera;
  25853. private _particle;
  25854. private _camDir;
  25855. private _camInvertedPosition;
  25856. private _rotMatrix;
  25857. private _invertMatrix;
  25858. private _rotated;
  25859. private _quaternion;
  25860. private _vertex;
  25861. private _normal;
  25862. private _yaw;
  25863. private _pitch;
  25864. private _roll;
  25865. private _halfroll;
  25866. private _halfpitch;
  25867. private _halfyaw;
  25868. private _sinRoll;
  25869. private _cosRoll;
  25870. private _sinPitch;
  25871. private _cosPitch;
  25872. private _sinYaw;
  25873. private _cosYaw;
  25874. private _mustUnrotateFixedNormals;
  25875. private _minimum;
  25876. private _maximum;
  25877. private _minBbox;
  25878. private _maxBbox;
  25879. private _particlesIntersect;
  25880. private _depthSortFunction;
  25881. private _needs32Bits;
  25882. private _pivotBackTranslation;
  25883. private _scaledPivot;
  25884. private _particleHasParent;
  25885. private _parent;
  25886. /**
  25887. * Creates a SPS (Solid Particle System) object.
  25888. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25889. * @param scene (Scene) is the scene in which the SPS is added.
  25890. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25891. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25892. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25893. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25894. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25895. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25896. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25897. */
  25898. constructor(name: string, scene: Scene, options?: {
  25899. updatable?: boolean;
  25900. isPickable?: boolean;
  25901. enableDepthSort?: boolean;
  25902. particleIntersection?: boolean;
  25903. boundingSphereOnly?: boolean;
  25904. bSphereRadiusFactor?: number;
  25905. });
  25906. /**
  25907. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25908. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25909. * @returns the created mesh
  25910. */
  25911. buildMesh(): Mesh;
  25912. /**
  25913. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25914. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25915. * Thus the particles generated from `digest()` have their property `position` set yet.
  25916. * @param mesh ( Mesh ) is the mesh to be digested
  25917. * @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
  25918. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25919. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25920. * @returns the current SPS
  25921. */
  25922. digest(mesh: Mesh, options?: {
  25923. facetNb?: number;
  25924. number?: number;
  25925. delta?: number;
  25926. }): SolidParticleSystem;
  25927. private _unrotateFixedNormals();
  25928. private _resetCopy();
  25929. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  25930. private _posToShape(positions);
  25931. private _uvsToShapeUV(uvs);
  25932. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  25933. /**
  25934. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25935. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25936. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25937. * @param nb (positive integer) the number of particles to be created from this model
  25938. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25939. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25940. * @returns the number of shapes in the system
  25941. */
  25942. addShape(mesh: Mesh, nb: number, options?: {
  25943. positionFunction?: any;
  25944. vertexFunction?: any;
  25945. }): number;
  25946. private _rebuildParticle(particle);
  25947. /**
  25948. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25949. * @returns the SPS.
  25950. */
  25951. rebuildMesh(): SolidParticleSystem;
  25952. /**
  25953. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25954. * This method calls `updateParticle()` for each particle of the SPS.
  25955. * For an animated SPS, it is usually called within the render loop.
  25956. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25957. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25958. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25959. * @returns the SPS.
  25960. */
  25961. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25962. private _quaternionRotationYPR();
  25963. private _quaternionToRotationMatrix();
  25964. /**
  25965. * Disposes the SPS.
  25966. */
  25967. dispose(): void;
  25968. /**
  25969. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25970. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25971. * @returns the SPS.
  25972. */
  25973. refreshVisibleSize(): SolidParticleSystem;
  25974. /**
  25975. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25976. * @param size the size (float) of the visibility box
  25977. * note : this doesn't lock the SPS mesh bounding box.
  25978. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25979. */
  25980. setVisibilityBox(size: number): void;
  25981. /**
  25982. * Gets whether the SPS as always visible or not
  25983. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25984. */
  25985. /**
  25986. * Sets the SPS as always visible or not
  25987. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25988. */
  25989. isAlwaysVisible: boolean;
  25990. /**
  25991. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25992. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25993. */
  25994. /**
  25995. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25996. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25997. */
  25998. isVisibilityBoxLocked: boolean;
  25999. /**
  26000. * Gets if `setParticles()` computes the particle rotations or not.
  26001. * Default value : true. The SPS is faster when it's set to false.
  26002. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26003. */
  26004. /**
  26005. * Tells to `setParticles()` to compute the particle rotations or not.
  26006. * Default value : true. The SPS is faster when it's set to false.
  26007. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26008. */
  26009. computeParticleRotation: boolean;
  26010. /**
  26011. * Gets if `setParticles()` computes the particle colors or not.
  26012. * Default value : true. The SPS is faster when it's set to false.
  26013. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26014. */
  26015. /**
  26016. * Tells to `setParticles()` to compute the particle colors or not.
  26017. * Default value : true. The SPS is faster when it's set to false.
  26018. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26019. */
  26020. computeParticleColor: boolean;
  26021. /**
  26022. * Gets if `setParticles()` computes the particle textures or not.
  26023. * Default value : true. The SPS is faster when it's set to false.
  26024. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26025. */
  26026. computeParticleTexture: boolean;
  26027. /**
  26028. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26029. * Default value : false. The SPS is faster when it's set to false.
  26030. * Note : the particle custom vertex positions aren't stored values.
  26031. */
  26032. /**
  26033. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26034. * Default value : false. The SPS is faster when it's set to false.
  26035. * Note : the particle custom vertex positions aren't stored values.
  26036. */
  26037. computeParticleVertex: boolean;
  26038. /**
  26039. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26040. */
  26041. /**
  26042. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26043. */
  26044. computeBoundingBox: boolean;
  26045. /**
  26046. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26047. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26048. * Default : `true`
  26049. */
  26050. /**
  26051. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26052. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26053. * Default : `true`
  26054. */
  26055. depthSortParticles: boolean;
  26056. /**
  26057. * This function does nothing. It may be overwritten to set all the particle first values.
  26058. * The SPS doesn't call this function, you may have to call it by your own.
  26059. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26060. */
  26061. initParticles(): void;
  26062. /**
  26063. * This function does nothing. It may be overwritten to recycle a particle.
  26064. * The SPS doesn't call this function, you may have to call it by your own.
  26065. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26066. * @param particle The particle to recycle
  26067. * @returns the recycled particle
  26068. */
  26069. recycleParticle(particle: SolidParticle): SolidParticle;
  26070. /**
  26071. * Updates a particle : this function should be overwritten by the user.
  26072. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26074. * @example : just set a particle position or velocity and recycle conditions
  26075. * @param particle The particle to update
  26076. * @returns the updated particle
  26077. */
  26078. updateParticle(particle: SolidParticle): SolidParticle;
  26079. /**
  26080. * Updates a vertex of a particle : it can be overwritten by the user.
  26081. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26082. * @param particle the current particle
  26083. * @param vertex the current index of the current particle
  26084. * @param pt the index of the current vertex in the particle shape
  26085. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26086. * @example : just set a vertex particle position
  26087. * @returns the updated vertex
  26088. */
  26089. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26090. /**
  26091. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26092. * This does nothing and may be overwritten by the user.
  26093. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26094. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26095. * @param update the boolean update value actually passed to setParticles()
  26096. */
  26097. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26098. /**
  26099. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26100. * This will be passed three parameters.
  26101. * This does nothing and may be overwritten by the user.
  26102. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26103. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26104. * @param update the boolean update value actually passed to setParticles()
  26105. */
  26106. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26107. }
  26108. }
  26109. declare module BABYLON {
  26110. interface PhysicsImpostorJoint {
  26111. mainImpostor: PhysicsImpostor;
  26112. connectedImpostor: PhysicsImpostor;
  26113. joint: PhysicsJoint;
  26114. }
  26115. class PhysicsEngine {
  26116. private _physicsPlugin;
  26117. gravity: Vector3;
  26118. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  26119. setGravity(gravity: Vector3): void;
  26120. /**
  26121. * Set the time step of the physics engine.
  26122. * default is 1/60.
  26123. * To slow it down, enter 1/600 for example.
  26124. * To speed it up, 1/30
  26125. * @param {number} newTimeStep the new timestep to apply to this world.
  26126. */
  26127. setTimeStep(newTimeStep?: number): void;
  26128. /**
  26129. * Get the time step of the physics engine.
  26130. */
  26131. getTimeStep(): number;
  26132. dispose(): void;
  26133. getPhysicsPluginName(): string;
  26134. static Epsilon: number;
  26135. private _impostors;
  26136. private _joints;
  26137. /**
  26138. * Adding a new impostor for the impostor tracking.
  26139. * This will be done by the impostor itself.
  26140. * @param {PhysicsImpostor} impostor the impostor to add
  26141. */
  26142. addImpostor(impostor: PhysicsImpostor): void;
  26143. /**
  26144. * Remove an impostor from the engine.
  26145. * This impostor and its mesh will not longer be updated by the physics engine.
  26146. * @param {PhysicsImpostor} impostor the impostor to remove
  26147. */
  26148. removeImpostor(impostor: PhysicsImpostor): void;
  26149. /**
  26150. * Add a joint to the physics engine
  26151. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  26152. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  26153. * @param {PhysicsJoint} the joint that will connect both impostors.
  26154. */
  26155. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26156. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26157. /**
  26158. * Called by the scene. no need to call it.
  26159. */
  26160. _step(delta: number): void;
  26161. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26162. getImpostors(): Array<PhysicsImpostor>;
  26163. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26164. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26165. }
  26166. interface IPhysicsEnginePlugin {
  26167. world: any;
  26168. name: string;
  26169. setGravity(gravity: Vector3): void;
  26170. setTimeStep(timeStep: number): void;
  26171. getTimeStep(): number;
  26172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26174. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26175. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26176. removePhysicsBody(impostor: PhysicsImpostor): void;
  26177. generateJoint(joint: PhysicsImpostorJoint): void;
  26178. removeJoint(joint: PhysicsImpostorJoint): void;
  26179. isSupported(): boolean;
  26180. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26181. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26182. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26183. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26185. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26187. getBodyMass(impostor: PhysicsImpostor): number;
  26188. getBodyFriction(impostor: PhysicsImpostor): number;
  26189. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26190. getBodyRestitution(impostor: PhysicsImpostor): number;
  26191. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26192. sleepBody(impostor: PhysicsImpostor): void;
  26193. wakeUpBody(impostor: PhysicsImpostor): void;
  26194. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26195. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26197. getRadius(impostor: PhysicsImpostor): number;
  26198. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26199. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26200. dispose(): void;
  26201. }
  26202. }
  26203. declare module BABYLON {
  26204. class PhysicsHelper {
  26205. private _scene;
  26206. private _physicsEngine;
  26207. constructor(scene: Scene);
  26208. /**
  26209. * @param {Vector3} origin the origin of the explosion
  26210. * @param {number} radius the explosion radius
  26211. * @param {number} strength the explosion strength
  26212. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26213. */
  26214. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26215. /**
  26216. * @param {Vector3} origin the origin of the explosion
  26217. * @param {number} radius the explosion radius
  26218. * @param {number} strength the explosion strength
  26219. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26220. */
  26221. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26222. /**
  26223. * @param {Vector3} origin the origin of the explosion
  26224. * @param {number} radius the explosion radius
  26225. * @param {number} strength the explosion strength
  26226. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26227. */
  26228. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  26229. /**
  26230. * @param {Vector3} origin the origin of the updraft
  26231. * @param {number} radius the radius of the updraft
  26232. * @param {number} strength the strength of the updraft
  26233. * @param {number} height the height of the updraft
  26234. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  26235. */
  26236. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  26237. /**
  26238. * @param {Vector3} origin the of the vortex
  26239. * @param {number} radius the radius of the vortex
  26240. * @param {number} strength the strength of the vortex
  26241. * @param {number} height the height of the vortex
  26242. */
  26243. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  26244. }
  26245. /***** Radial explosion *****/
  26246. class PhysicsRadialExplosionEvent {
  26247. private _scene;
  26248. private _sphere;
  26249. private _sphereOptions;
  26250. private _rays;
  26251. private _dataFetched;
  26252. constructor(scene: Scene);
  26253. /**
  26254. * Returns the data related to the radial explosion event (sphere & rays).
  26255. * @returns {PhysicsRadialExplosionEventData}
  26256. */
  26257. getData(): PhysicsRadialExplosionEventData;
  26258. /**
  26259. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26260. * @param impostor
  26261. * @param {Vector3} origin the origin of the explosion
  26262. * @param {number} radius the explosion radius
  26263. * @param {number} strength the explosion strength
  26264. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26265. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26266. */
  26267. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26268. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  26269. /**
  26270. * Disposes the sphere.
  26271. * @param {bolean} force
  26272. */
  26273. dispose(force?: boolean): void;
  26274. <<<<<<< HEAD
  26275. private getImpostorForceAndContactPoint(impostor);
  26276. private _tick();
  26277. /*** Helpers ***/
  26278. private _prepareCylinder();
  26279. private _intersectsWithCylinder(impostor);
  26280. }
  26281. /***** Enums *****/
  26282. /**
  26283. * The strenght of the force in correspondence to the distance of the affected object
  26284. */
  26285. enum PhysicsRadialImpulseFalloff {
  26286. Constant = 0,
  26287. Linear = 1,
  26288. }
  26289. /**
  26290. * The strenght of the force in correspondence to the distance of the affected object
  26291. */
  26292. enum PhysicsUpdraftMode {
  26293. Center = 0,
  26294. Perpendicular = 1,
  26295. }
  26296. /***** Data interfaces *****/
  26297. interface PhysicsForceAndContactPoint {
  26298. force: Vector3;
  26299. contactPoint: Vector3;
  26300. }
  26301. interface PhysicsRadialExplosionEventData {
  26302. sphere: Mesh;
  26303. rays: Array<Ray>;
  26304. }
  26305. interface PhysicsGravitationalFieldEventData {
  26306. sphere: Mesh;
  26307. }
  26308. interface PhysicsUpdraftEventData {
  26309. cylinder: Mesh;
  26310. }
  26311. interface PhysicsVortexEventData {
  26312. cylinder: Mesh;
  26313. }
  26314. }
  26315. declare module BABYLON {
  26316. interface PhysicsImpostorParameters {
  26317. mass: number;
  26318. friction?: number;
  26319. restitution?: number;
  26320. nativeOptions?: any;
  26321. ignoreParent?: boolean;
  26322. disableBidirectionalTransformation?: boolean;
  26323. }
  26324. interface IPhysicsEnabledObject {
  26325. position: Vector3;
  26326. rotationQuaternion: Nullable<Quaternion>;
  26327. scaling: Vector3;
  26328. rotation?: Vector3;
  26329. parent?: any;
  26330. getBoundingInfo(): BoundingInfo;
  26331. computeWorldMatrix(force: boolean): Matrix;
  26332. getWorldMatrix?(): Matrix;
  26333. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26334. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26335. getIndices?(): Nullable<IndicesArray>;
  26336. getScene?(): Scene;
  26337. getAbsolutePosition(): Vector3;
  26338. getAbsolutePivotPoint(): Vector3;
  26339. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26340. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26341. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26342. getClassName(): string;
  26343. }
  26344. class PhysicsImpostor {
  26345. object: IPhysicsEnabledObject;
  26346. type: number;
  26347. private _options;
  26348. private _scene;
  26349. static DEFAULT_OBJECT_SIZE: Vector3;
  26350. static IDENTITY_QUATERNION: Quaternion;
  26351. private _physicsEngine;
  26352. private _physicsBody;
  26353. private _bodyUpdateRequired;
  26354. private _onBeforePhysicsStepCallbacks;
  26355. private _onAfterPhysicsStepCallbacks;
  26356. private _onPhysicsCollideCallbacks;
  26357. private _deltaPosition;
  26358. private _deltaRotation;
  26359. private _deltaRotationConjugated;
  26360. private _parent;
  26361. private _isDisposed;
  26362. private static _tmpVecs;
  26363. private static _tmpQuat;
  26364. readonly isDisposed: boolean;
  26365. mass: number;
  26366. friction: number;
  26367. restitution: number;
  26368. uniqueId: number;
  26369. private _joints;
  26370. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26371. /**
  26372. * This function will completly initialize this impostor.
  26373. * It will create a new body - but only if this mesh has no parent.
  26374. * If it has, this impostor will not be used other than to define the impostor
  26375. * of the child mesh.
  26376. */
  26377. _init(): void;
  26378. private _getPhysicsParent();
  26379. /**
  26380. * Should a new body be generated.
  26381. */
  26382. isBodyInitRequired(): boolean;
  26383. setScalingUpdated(updated: boolean): void;
  26384. /**
  26385. * Force a regeneration of this or the parent's impostor's body.
  26386. * Use under cautious - This will remove all joints already implemented.
  26387. */
  26388. forceUpdate(): void;
  26389. /**
  26390. * Gets the body that holds this impostor. Either its own, or its parent.
  26391. */
  26392. /**
  26393. * Set the physics body. Used mainly by the physics engine/plugin
  26394. */
  26395. physicsBody: any;
  26396. parent: Nullable<PhysicsImpostor>;
  26397. resetUpdateFlags(): void;
  26398. getObjectExtendSize(): Vector3;
  26399. getObjectCenter(): Vector3;
  26400. /**
  26401. * Get a specific parametes from the options parameter.
  26402. */
  26403. getParam(paramName: string): any;
  26404. /**
  26405. * Sets a specific parameter in the options given to the physics plugin
  26406. */
  26407. setParam(paramName: string, value: number): void;
  26408. /**
  26409. * Specifically change the body's mass option. Won't recreate the physics body object
  26410. */
  26411. setMass(mass: number): void;
  26412. getLinearVelocity(): Nullable<Vector3>;
  26413. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26414. getAngularVelocity(): Nullable<Vector3>;
  26415. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26416. /**
  26417. * Execute a function with the physics plugin native code.
  26418. * Provide a function the will have two variables - the world object and the physics body object.
  26419. */
  26420. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26421. /**
  26422. * Register a function that will be executed before the physics world is stepping forward.
  26423. */
  26424. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26425. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26426. /**
  26427. * Register a function that will be executed after the physics step
  26428. */
  26429. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26430. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26431. /**
  26432. * register a function that will be executed when this impostor collides against a different body.
  26433. */
  26434. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26435. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26436. private _tmpQuat;
  26437. private _tmpQuat2;
  26438. getParentsRotation(): Quaternion;
  26439. /**
  26440. * this function is executed by the physics engine.
  26441. */
  26442. beforeStep: () => void;
  26443. /**
  26444. * this function is executed by the physics engine.
  26445. */
  26446. afterStep: () => void;
  26447. /**
  26448. * Legacy collision detection event support
  26449. */
  26450. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26451. onCollide: (e: {
  26452. body: any;
  26453. }) => void;
  26454. /**
  26455. * Apply a force
  26456. */
  26457. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26458. /**
  26459. * Apply an impulse
  26460. */
  26461. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26462. /**
  26463. * A help function to create a joint.
  26464. */
  26465. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26466. /**
  26467. * Add a joint to this impostor with a different impostor.
  26468. */
  26469. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26470. /**
  26471. * Will keep this body still, in a sleep mode.
  26472. */
  26473. sleep(): PhysicsImpostor;
  26474. /**
  26475. * Wake the body up.
  26476. */
  26477. wakeUp(): PhysicsImpostor;
  26478. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26479. dispose(): void;
  26480. setDeltaPosition(position: Vector3): void;
  26481. setDeltaRotation(rotation: Quaternion): void;
  26482. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26483. getRadius(): number;
  26484. /**
  26485. * Sync a bone with this impostor
  26486. * @param bone The bone to sync to the impostor.
  26487. * @param boneMesh The mesh that the bone is influencing.
  26488. * @param jointPivot The pivot of the joint / bone in local space.
  26489. * @param distToJoint Optional distance from the impostor to the joint.
  26490. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26491. */
  26492. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26493. /**
  26494. * Sync impostor to a bone
  26495. * @param bone The bone that the impostor will be synced to.
  26496. * @param boneMesh The mesh that the bone is influencing.
  26497. * @param jointPivot The pivot of the joint / bone in local space.
  26498. * @param distToJoint Optional distance from the impostor to the joint.
  26499. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26500. * @param boneAxis Optional vector3 axis the bone is aligned with
  26501. */
  26502. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  26503. static NoImpostor: number;
  26504. static SphereImpostor: number;
  26505. static BoxImpostor: number;
  26506. static PlaneImpostor: number;
  26507. static MeshImpostor: number;
  26508. static CylinderImpostor: number;
  26509. static ParticleImpostor: number;
  26510. static HeightmapImpostor: number;
  26511. }
  26512. }
  26513. declare module BABYLON {
  26514. interface PhysicsJointData {
  26515. mainPivot?: Vector3;
  26516. connectedPivot?: Vector3;
  26517. mainAxis?: Vector3;
  26518. connectedAxis?: Vector3;
  26519. collision?: boolean;
  26520. nativeParams?: any;
  26521. }
  26522. /**
  26523. * This is a holder class for the physics joint created by the physics plugin.
  26524. * It holds a set of functions to control the underlying joint.
  26525. */
  26526. class PhysicsJoint {
  26527. type: number;
  26528. jointData: PhysicsJointData;
  26529. private _physicsJoint;
  26530. protected _physicsPlugin: IPhysicsEnginePlugin;
  26531. constructor(type: number, jointData: PhysicsJointData);
  26532. physicsJoint: any;
  26533. physicsPlugin: IPhysicsEnginePlugin;
  26534. /**
  26535. * Execute a function that is physics-plugin specific.
  26536. * @param {Function} func the function that will be executed.
  26537. * It accepts two parameters: the physics world and the physics joint.
  26538. */
  26539. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26540. static DistanceJoint: number;
  26541. static HingeJoint: number;
  26542. static BallAndSocketJoint: number;
  26543. static WheelJoint: number;
  26544. static SliderJoint: number;
  26545. static PrismaticJoint: number;
  26546. static UniversalJoint: number;
  26547. static Hinge2Joint: number;
  26548. static PointToPointJoint: number;
  26549. static SpringJoint: number;
  26550. static LockJoint: number;
  26551. }
  26552. /**
  26553. * A class representing a physics distance joint.
  26554. */
  26555. class DistanceJoint extends PhysicsJoint {
  26556. constructor(jointData: DistanceJointData);
  26557. /**
  26558. * Update the predefined distance.
  26559. */
  26560. updateDistance(maxDistance: number, minDistance?: number): void;
  26561. }
  26562. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26563. constructor(type: number, jointData: PhysicsJointData);
  26564. /**
  26565. * Set the motor values.
  26566. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26567. * @param {number} force the force to apply
  26568. * @param {number} maxForce max force for this motor.
  26569. */
  26570. setMotor(force?: number, maxForce?: number): void;
  26571. /**
  26572. * Set the motor's limits.
  26573. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26574. */
  26575. setLimit(upperLimit: number, lowerLimit?: number): void;
  26576. }
  26577. /**
  26578. * This class represents a single hinge physics joint
  26579. */
  26580. class HingeJoint extends MotorEnabledJoint {
  26581. constructor(jointData: PhysicsJointData);
  26582. /**
  26583. * Set the motor values.
  26584. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26585. * @param {number} force the force to apply
  26586. * @param {number} maxForce max force for this motor.
  26587. */
  26588. setMotor(force?: number, maxForce?: number): void;
  26589. /**
  26590. * Set the motor's limits.
  26591. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26592. */
  26593. setLimit(upperLimit: number, lowerLimit?: number): void;
  26594. }
  26595. /**
  26596. * This class represents a dual hinge physics joint (same as wheel joint)
  26597. */
  26598. class Hinge2Joint extends MotorEnabledJoint {
  26599. constructor(jointData: PhysicsJointData);
  26600. /**
  26601. * Set the motor values.
  26602. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26603. * @param {number} force the force to apply
  26604. * @param {number} maxForce max force for this motor.
  26605. * @param {motorIndex} the motor's index, 0 or 1.
  26606. */
  26607. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26608. /**
  26609. * Set the motor limits.
  26610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26611. * @param {number} upperLimit the upper limit
  26612. * @param {number} lowerLimit lower limit
  26613. * @param {motorIndex} the motor's index, 0 or 1.
  26614. */
  26615. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26616. }
  26617. interface IMotorEnabledJoint {
  26618. physicsJoint: any;
  26619. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26620. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26621. }
  26622. interface DistanceJointData extends PhysicsJointData {
  26623. maxDistance: number;
  26624. }
  26625. interface SpringJointData extends PhysicsJointData {
  26626. length: number;
  26627. stiffness: number;
  26628. damping: number;
  26629. }
  26630. }
  26631. declare module BABYLON {
  26632. class AnaglyphPostProcess extends PostProcess {
  26633. private _passedProcess;
  26634. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26635. }
  26636. }
  26637. declare module BABYLON {
  26638. class BlackAndWhitePostProcess extends PostProcess {
  26639. degree: number;
  26640. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26641. }
  26642. }
  26643. declare module BABYLON {
  26644. /**
  26645. * The Blur Post Process which blurs an image based on a kernel and direction.
  26646. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26647. */
  26648. class BlurPostProcess extends PostProcess {
  26649. /** The direction in which to blur the image. */ direction: Vector2;
  26650. private blockCompilation;
  26651. protected _kernel: number;
  26652. protected _idealKernel: number;
  26653. protected _packedFloat: boolean;
  26654. private _staticDefines;
  26655. =======
  26656. /*** Helpers ***/
  26657. private _prepareSphere();
  26658. private _intersectsWithSphere(impostor, origin, radius);
  26659. }
  26660. /***** Gravitational Field *****/
  26661. class PhysicsGravitationalFieldEvent {
  26662. private _physicsHelper;
  26663. private _scene;
  26664. private _origin;
  26665. private _radius;
  26666. private _strength;
  26667. private _falloff;
  26668. private _tickCallback;
  26669. private _sphere;
  26670. private _dataFetched;
  26671. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26672. /**
  26673. * Returns the data related to the gravitational field event (sphere).
  26674. * @returns {PhysicsGravitationalFieldEventData}
  26675. */
  26676. getData(): PhysicsGravitationalFieldEventData;
  26677. /**
  26678. * Enables the gravitational field.
  26679. */
  26680. enable(): void;
  26681. /**
  26682. * Disables the gravitational field.
  26683. */
  26684. disable(): void;
  26685. /**
  26686. * Disposes the sphere.
  26687. * @param {bolean} force
  26688. */
  26689. dispose(force?: boolean): void;
  26690. private _tick();
  26691. }
  26692. /***** Updraft *****/
  26693. class PhysicsUpdraftEvent {
  26694. private _scene;
  26695. private _origin;
  26696. private _radius;
  26697. private _strength;
  26698. private _height;
  26699. private _updraftMode;
  26700. private _physicsEngine;
  26701. private _originTop;
  26702. private _originDirection;
  26703. private _tickCallback;
  26704. private _cylinder;
  26705. private _cylinderPosition;
  26706. private _dataFetched;
  26707. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26708. /**
  26709. * Returns the data related to the updraft event (cylinder).
  26710. * @returns {PhysicsUpdraftEventData}
  26711. */
  26712. getData(): PhysicsUpdraftEventData;
  26713. /**
  26714. * Enables the updraft.
  26715. */
  26716. enable(): void;
  26717. /**
  26718. * Disables the cortex.
  26719. */
  26720. disable(): void;
  26721. /**
  26722. * Disposes the sphere.
  26723. * @param {bolean} force
  26724. */
  26725. dispose(force?: boolean): void;
  26726. private getImpostorForceAndContactPoint(impostor);
  26727. private _tick();
  26728. /*** Helpers ***/
  26729. private _prepareCylinder();
  26730. private _intersectsWithCylinder(impostor);
  26731. }
  26732. /***** Vortex *****/
  26733. class PhysicsVortexEvent {
  26734. private _scene;
  26735. private _origin;
  26736. private _radius;
  26737. private _strength;
  26738. private _height;
  26739. private _physicsEngine;
  26740. private _originTop;
  26741. private _centripetalForceThreshold;
  26742. private _updraftMultiplier;
  26743. private _tickCallback;
  26744. private _cylinder;
  26745. private _cylinderPosition;
  26746. private _dataFetched;
  26747. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26748. /**
  26749. * Returns the data related to the vortex event (cylinder).
  26750. * @returns {PhysicsVortexEventData}
  26751. */
  26752. getData(): PhysicsVortexEventData;
  26753. /**
  26754. * Enables the vortex.
  26755. */
  26756. enable(): void;
  26757. /**
  26758. * Disables the cortex.
  26759. */
  26760. disable(): void;
  26761. /**
  26762. * Disposes the sphere.
  26763. * @param {bolean} force
  26764. */
  26765. dispose(force?: boolean): void;
  26766. private getImpostorForceAndContactPoint(impostor);
  26767. private _tick();
  26768. /*** Helpers ***/
  26769. private _prepareCylinder();
  26770. private _intersectsWithCylinder(impostor);
  26771. }
  26772. /***** Enums *****/
  26773. /**
  26774. * The strenght of the force in correspondence to the distance of the affected object
  26775. */
  26776. enum PhysicsRadialImpulseFalloff {
  26777. Constant = 0,
  26778. Linear = 1,
  26779. }
  26780. /**
  26781. * The strenght of the force in correspondence to the distance of the affected object
  26782. */
  26783. enum PhysicsUpdraftMode {
  26784. Center = 0,
  26785. Perpendicular = 1,
  26786. }
  26787. /***** Data interfaces *****/
  26788. interface PhysicsForceAndContactPoint {
  26789. force: Vector3;
  26790. contactPoint: Vector3;
  26791. }
  26792. interface PhysicsRadialExplosionEventData {
  26793. sphere: Mesh;
  26794. rays: Array<Ray>;
  26795. }
  26796. interface PhysicsGravitationalFieldEventData {
  26797. sphere: Mesh;
  26798. }
  26799. interface PhysicsUpdraftEventData {
  26800. cylinder: Mesh;
  26801. }
  26802. interface PhysicsVortexEventData {
  26803. cylinder: Mesh;
  26804. }
  26805. }
  26806. declare module BABYLON {
  26807. interface PhysicsImpostorParameters {
  26808. mass: number;
  26809. friction?: number;
  26810. restitution?: number;
  26811. nativeOptions?: any;
  26812. ignoreParent?: boolean;
  26813. disableBidirectionalTransformation?: boolean;
  26814. }
  26815. interface IPhysicsEnabledObject {
  26816. position: Vector3;
  26817. rotationQuaternion: Nullable<Quaternion>;
  26818. scaling: Vector3;
  26819. rotation?: Vector3;
  26820. parent?: any;
  26821. getBoundingInfo(): BoundingInfo;
  26822. computeWorldMatrix(force: boolean): Matrix;
  26823. getWorldMatrix?(): Matrix;
  26824. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26825. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26826. getIndices?(): Nullable<IndicesArray>;
  26827. getScene?(): Scene;
  26828. getAbsolutePosition(): Vector3;
  26829. getAbsolutePivotPoint(): Vector3;
  26830. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26831. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26832. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26833. getClassName(): string;
  26834. }
  26835. class PhysicsImpostor {
  26836. object: IPhysicsEnabledObject;
  26837. type: number;
  26838. private _options;
  26839. private _scene;
  26840. static DEFAULT_OBJECT_SIZE: Vector3;
  26841. static IDENTITY_QUATERNION: Quaternion;
  26842. private _physicsEngine;
  26843. private _physicsBody;
  26844. private _bodyUpdateRequired;
  26845. private _onBeforePhysicsStepCallbacks;
  26846. private _onAfterPhysicsStepCallbacks;
  26847. private _onPhysicsCollideCallbacks;
  26848. private _deltaPosition;
  26849. private _deltaRotation;
  26850. private _deltaRotationConjugated;
  26851. private _parent;
  26852. private _isDisposed;
  26853. private static _tmpVecs;
  26854. private static _tmpQuat;
  26855. readonly isDisposed: boolean;
  26856. mass: number;
  26857. friction: number;
  26858. restitution: number;
  26859. uniqueId: number;
  26860. private _joints;
  26861. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26862. /**
  26863. * This function will completly initialize this impostor.
  26864. * It will create a new body - but only if this mesh has no parent.
  26865. * If it has, this impostor will not be used other than to define the impostor
  26866. * of the child mesh.
  26867. */
  26868. _init(): void;
  26869. private _getPhysicsParent();
  26870. /**
  26871. * Should a new body be generated.
  26872. */
  26873. isBodyInitRequired(): boolean;
  26874. setScalingUpdated(updated: boolean): void;
  26875. /**
  26876. * Force a regeneration of this or the parent's impostor's body.
  26877. * Use under cautious - This will remove all joints already implemented.
  26878. */
  26879. forceUpdate(): void;
  26880. /**
  26881. * Gets the body that holds this impostor. Either its own, or its parent.
  26882. */
  26883. /**
  26884. * Set the physics body. Used mainly by the physics engine/plugin
  26885. */
  26886. physicsBody: any;
  26887. parent: Nullable<PhysicsImpostor>;
  26888. resetUpdateFlags(): void;
  26889. getObjectExtendSize(): Vector3;
  26890. getObjectCenter(): Vector3;
  26891. /**
  26892. * Get a specific parametes from the options parameter.
  26893. */
  26894. getParam(paramName: string): any;
  26895. /**
  26896. * Sets a specific parameter in the options given to the physics plugin
  26897. */
  26898. setParam(paramName: string, value: number): void;
  26899. /**
  26900. * Specifically change the body's mass option. Won't recreate the physics body object
  26901. */
  26902. setMass(mass: number): void;
  26903. getLinearVelocity(): Nullable<Vector3>;
  26904. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26905. getAngularVelocity(): Nullable<Vector3>;
  26906. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26907. /**
  26908. * Execute a function with the physics plugin native code.
  26909. * Provide a function the will have two variables - the world object and the physics body object.
  26910. */
  26911. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26912. /**
  26913. * Register a function that will be executed before the physics world is stepping forward.
  26914. */
  26915. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26916. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26917. /**
  26918. * Register a function that will be executed after the physics step
  26919. */
  26920. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26921. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26922. /**
  26923. * register a function that will be executed when this impostor collides against a different body.
  26924. */
  26925. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26926. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26927. private _tmpQuat;
  26928. private _tmpQuat2;
  26929. getParentsRotation(): Quaternion;
  26930. /**
  26931. * this function is executed by the physics engine.
  26932. */
  26933. beforeStep: () => void;
  26934. /**
  26935. * this function is executed by the physics engine.
  26936. */
  26937. afterStep: () => void;
  26938. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  26939. /**
  26940. * Legacy collision detection event support
  26941. */
  26942. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26943. onCollide: (e: {
  26944. body: any;
  26945. }) => void;
  26946. /**
  26947. * Apply a force
  26948. */
  26949. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26950. /**
  26951. * Apply an impulse
  26952. */
  26953. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26954. /**
  26955. * A help function to create a joint.
  26956. */
  26957. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26958. /**
  26959. <<<<<<< HEAD
  26960. * Creates a new instance BlurPostProcess
  26961. * @param name The name of the effect.
  26962. * @param direction The direction in which to blur the image.
  26963. * @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.
  26964. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26965. * @param camera The camera to apply the render pass to.
  26966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26967. * @param engine The engine which the post process will be applied. (default: current engine)
  26968. * @param reusable If the post process can be reused on the same frame. (default: false)
  26969. * @param textureType Type of textures used when performing the post process. (default: 0)
  26970. * @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)
  26971. =======
  26972. * Add a joint to this impostor with a different impostor.
  26973. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  26974. */
  26975. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26976. /**
  26977. * Will keep this body still, in a sleep mode.
  26978. */
  26979. sleep(): PhysicsImpostor;
  26980. /**
  26981. * Wake the body up.
  26982. */
  26983. wakeUp(): PhysicsImpostor;
  26984. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26985. dispose(): void;
  26986. setDeltaPosition(position: Vector3): void;
  26987. setDeltaRotation(rotation: Quaternion): void;
  26988. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26989. getRadius(): number;
  26990. /**
  26991. * Sync a bone with this impostor
  26992. * @param bone The bone to sync to the impostor.
  26993. * @param boneMesh The mesh that the bone is influencing.
  26994. * @param jointPivot The pivot of the joint / bone in local space.
  26995. * @param distToJoint Optional distance from the impostor to the joint.
  26996. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26997. */
  26998. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26999. /**
  27000. * Sync impostor to a bone
  27001. * @param bone The bone that the impostor will be synced to.
  27002. * @param boneMesh The mesh that the bone is influencing.
  27003. * @param jointPivot The pivot of the joint / bone in local space.
  27004. * @param distToJoint Optional distance from the impostor to the joint.
  27005. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27006. * @param boneAxis Optional vector3 axis the bone is aligned with
  27007. */
  27008. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27009. static NoImpostor: number;
  27010. static SphereImpostor: number;
  27011. static BoxImpostor: number;
  27012. static PlaneImpostor: number;
  27013. static MeshImpostor: number;
  27014. static CylinderImpostor: number;
  27015. static ParticleImpostor: number;
  27016. static HeightmapImpostor: number;
  27017. }
  27018. }
  27019. declare module BABYLON {
  27020. interface PhysicsJointData {
  27021. mainPivot?: Vector3;
  27022. connectedPivot?: Vector3;
  27023. mainAxis?: Vector3;
  27024. connectedAxis?: Vector3;
  27025. collision?: boolean;
  27026. nativeParams?: any;
  27027. }
  27028. /**
  27029. * This is a holder class for the physics joint created by the physics plugin.
  27030. * It holds a set of functions to control the underlying joint.
  27031. */
  27032. class PhysicsJoint {
  27033. type: number;
  27034. jointData: PhysicsJointData;
  27035. private _physicsJoint;
  27036. protected _physicsPlugin: IPhysicsEnginePlugin;
  27037. constructor(type: number, jointData: PhysicsJointData);
  27038. physicsJoint: any;
  27039. physicsPlugin: IPhysicsEnginePlugin;
  27040. /**
  27041. * Execute a function that is physics-plugin specific.
  27042. * @param {Function} func the function that will be executed.
  27043. * It accepts two parameters: the physics world and the physics joint.
  27044. */
  27045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27046. static DistanceJoint: number;
  27047. static HingeJoint: number;
  27048. static BallAndSocketJoint: number;
  27049. static WheelJoint: number;
  27050. static SliderJoint: number;
  27051. static PrismaticJoint: number;
  27052. static UniversalJoint: number;
  27053. static Hinge2Joint: number;
  27054. static PointToPointJoint: number;
  27055. static SpringJoint: number;
  27056. static LockJoint: number;
  27057. }
  27058. /**
  27059. * A class representing a physics distance joint.
  27060. */
  27061. class DistanceJoint extends PhysicsJoint {
  27062. constructor(jointData: DistanceJointData);
  27063. /**
  27064. * Update the predefined distance.
  27065. */
  27066. updateDistance(maxDistance: number, minDistance?: number): void;
  27067. }
  27068. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27069. constructor(type: number, jointData: PhysicsJointData);
  27070. /**
  27071. * Set the motor values.
  27072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27073. * @param {number} force the force to apply
  27074. * @param {number} maxForce max force for this motor.
  27075. */
  27076. setMotor(force?: number, maxForce?: number): void;
  27077. /**
  27078. <<<<<<< HEAD
  27079. * Creates a new instance ChromaticAberrationPostProcess
  27080. * @param name The name of the effect.
  27081. * @param screenWidth The width of the screen to apply the effect on.
  27082. * @param screenHeight The height of the screen to apply the effect on.
  27083. * @param options The required width/height ratio to downsize to before computing the render pass.
  27084. * @param camera The camera to apply the render pass to.
  27085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27086. * @param engine The engine which the post process will be applied. (default: current engine)
  27087. * @param reusable If the post process can be reused on the same frame. (default: false)
  27088. * @param textureType Type of textures used when performing the post process. (default: 0)
  27089. * @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)
  27090. =======
  27091. * Set the motor's limits.
  27092. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27093. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27094. */
  27095. setLimit(upperLimit: number, lowerLimit?: number): void;
  27096. }
  27097. /**
  27098. * This class represents a single hinge physics joint
  27099. */
  27100. class HingeJoint extends MotorEnabledJoint {
  27101. constructor(jointData: PhysicsJointData);
  27102. /**
  27103. * Set the motor values.
  27104. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27105. * @param {number} force the force to apply
  27106. * @param {number} maxForce max force for this motor.
  27107. */
  27108. setMotor(force?: number, maxForce?: number): void;
  27109. /**
  27110. * Set the motor's limits.
  27111. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27112. */
  27113. setLimit(upperLimit: number, lowerLimit?: number): void;
  27114. }
  27115. /**
  27116. * This class represents a dual hinge physics joint (same as wheel joint)
  27117. */
  27118. class Hinge2Joint extends MotorEnabledJoint {
  27119. constructor(jointData: PhysicsJointData);
  27120. /**
  27121. * Set the motor values.
  27122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27123. * @param {number} force the force to apply
  27124. * @param {number} maxForce max force for this motor.
  27125. * @param {motorIndex} the motor's index, 0 or 1.
  27126. */
  27127. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27128. /**
  27129. <<<<<<< HEAD
  27130. * Creates a new instance CircleOfConfusionPostProcess
  27131. * @param name The name of the effect.
  27132. * @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.
  27133. * @param options The required width/height ratio to downsize to before computing the render pass.
  27134. * @param camera The camera to apply the render pass to.
  27135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27136. * @param engine The engine which the post process will be applied. (default: current engine)
  27137. * @param reusable If the post process can be reused on the same frame. (default: false)
  27138. * @param textureType Type of textures used when performing the post process. (default: 0)
  27139. * @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)
  27140. =======
  27141. * Set the motor limits.
  27142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27143. * @param {number} upperLimit the upper limit
  27144. * @param {number} lowerLimit lower limit
  27145. * @param {motorIndex} the motor's index, 0 or 1.
  27146. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27147. */
  27148. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27149. }
  27150. interface IMotorEnabledJoint {
  27151. physicsJoint: any;
  27152. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27154. }
  27155. interface DistanceJointData extends PhysicsJointData {
  27156. maxDistance: number;
  27157. }
  27158. interface SpringJointData extends PhysicsJointData {
  27159. length: number;
  27160. stiffness: number;
  27161. damping: number;
  27162. }
  27163. }
  27164. declare module BABYLON {
  27165. class ReflectionProbe {
  27166. name: string;
  27167. private _scene;
  27168. private _renderTargetTexture;
  27169. private _projectionMatrix;
  27170. private _viewMatrix;
  27171. private _target;
  27172. private _add;
  27173. private _attachedMesh;
  27174. private _invertYAxis;
  27175. position: Vector3;
  27176. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  27177. samples: number;
  27178. refreshRate: number;
  27179. getScene(): Scene;
  27180. readonly cubeTexture: RenderTargetTexture;
  27181. readonly renderList: Nullable<AbstractMesh[]>;
  27182. attachToMesh(mesh: AbstractMesh): void;
  27183. /**
  27184. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27185. *
  27186. * @param renderingGroupId The rendering group id corresponding to its index
  27187. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27188. */
  27189. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27190. dispose(): void;
  27191. }
  27192. }
  27193. declare module BABYLON {
  27194. class BoundingBoxRenderer {
  27195. frontColor: Color3;
  27196. backColor: Color3;
  27197. showBackLines: boolean;
  27198. renderList: SmartArray<BoundingBox>;
  27199. private _scene;
  27200. private _colorShader;
  27201. private _vertexBuffers;
  27202. private _indexBuffer;
  27203. constructor(scene: Scene);
  27204. private _prepareRessources();
  27205. private _createIndexBuffer();
  27206. _rebuild(): void;
  27207. reset(): void;
  27208. render(): void;
  27209. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  27210. dispose(): void;
  27211. }
  27212. }
  27213. declare module BABYLON {
  27214. /**
  27215. * This represents a depth renderer in Babylon.
  27216. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  27217. */
  27218. <<<<<<< HEAD
  27219. class ConvolutionPostProcess extends PostProcess {
  27220. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  27221. /**
  27222. * Creates a new instance ConvolutionPostProcess
  27223. * @param name The name of the effect.
  27224. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27225. * @param options The required width/height ratio to downsize to before computing the render pass.
  27226. * @param camera The camera to apply the render pass to.
  27227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27228. * @param engine The engine which the post process will be applied. (default: current engine)
  27229. * @param reusable If the post process can be reused on the same frame. (default: false)
  27230. * @param textureType Type of textures used when performing the post process. (default: 0)
  27231. */
  27232. 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);
  27233. /**
  27234. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27235. */
  27236. static EdgeDetect0Kernel: number[];
  27237. /**
  27238. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27239. */
  27240. static EdgeDetect1Kernel: number[];
  27241. =======
  27242. class DepthRenderer {
  27243. private _scene;
  27244. private _depthMap;
  27245. private _effect;
  27246. private _cachedDefines;
  27247. private _camera;
  27248. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27249. /**
  27250. * Instantiates a depth renderer
  27251. * @param scene The scene the renderer belongs to
  27252. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  27253. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  27254. */
  27255. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  27256. /**
  27257. * Creates the depth rendering effect and checks if the effect is ready.
  27258. * @param subMesh The submesh to be used to render the depth map of
  27259. * @param useInstances If multiple world instances should be used
  27260. * @returns if the depth renderer is ready to render the depth map
  27261. */
  27262. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27263. /**
  27264. * Gets the texture which the depth map will be written to.
  27265. * @returns The depth map texture
  27266. */
  27267. getDepthMap(): RenderTargetTexture;
  27268. /**
  27269. * Disposes of the depth renderer.
  27270. */
  27271. dispose(): void;
  27272. }
  27273. }
  27274. declare module BABYLON {
  27275. <<<<<<< HEAD
  27276. /**
  27277. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27278. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27279. * based on samples that have a large difference in distance than the center pixel.
  27280. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27281. */
  27282. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27283. direction: Vector2;
  27284. /**
  27285. * Creates a new instance CircleOfConfusionPostProcess
  27286. * @param name The name of the effect.
  27287. * @param scene The scene the effect belongs to.
  27288. * @param direction The direction the blur should be applied.
  27289. * @param kernel The size of the kernel used to blur.
  27290. * @param options The required width/height ratio to downsize to before computing the render pass.
  27291. * @param camera The camera to apply the render pass to.
  27292. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27293. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27295. * @param engine The engine which the post process will be applied. (default: current engine)
  27296. * @param reusable If the post process can be reused on the same frame. (default: false)
  27297. * @param textureType Type of textures used when performing the post process. (default: 0)
  27298. * @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)
  27299. */
  27300. 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);
  27301. =======
  27302. class EdgesRenderer {
  27303. edgesWidthScalerForOrthographic: number;
  27304. edgesWidthScalerForPerspective: number;
  27305. private _source;
  27306. private _linesPositions;
  27307. private _linesNormals;
  27308. private _linesIndices;
  27309. private _epsilon;
  27310. private _indicesCount;
  27311. private _lineShader;
  27312. private _ib;
  27313. private _buffers;
  27314. private _checkVerticesInsteadOfIndices;
  27315. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  27316. private _prepareRessources();
  27317. _rebuild(): void;
  27318. dispose(): void;
  27319. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  27320. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  27321. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  27322. _generateEdgesLines(): void;
  27323. render(): void;
  27324. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27325. }
  27326. }
  27327. declare module BABYLON {
  27328. /**
  27329. <<<<<<< HEAD
  27330. * Specifies the level of max blur that should be applied when using the depth of field effect
  27331. */
  27332. enum DepthOfFieldEffectBlurLevel {
  27333. /**
  27334. * Subtle blur
  27335. */
  27336. Low = 0,
  27337. /**
  27338. * Medium blur
  27339. */
  27340. Medium = 1,
  27341. /**
  27342. * Large blur
  27343. */
  27344. High = 2,
  27345. }
  27346. /**
  27347. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27348. */
  27349. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27350. private _circleOfConfusion;
  27351. private _depthOfFieldBlurX;
  27352. private _depthOfFieldBlurY;
  27353. /**
  27354. * Private, last post process of dof
  27355. */
  27356. _depthOfFieldMerge: DepthOfFieldMergePostProcess;
  27357. private _effects;
  27358. /**
  27359. * The focal the length of the camera used in the effect
  27360. */
  27361. focalLength: number;
  27362. /**
  27363. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27364. */
  27365. fStop: number;
  27366. /**
  27367. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27368. */
  27369. focusDistance: number;
  27370. /**
  27371. * 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.
  27372. */
  27373. lensSize: number;
  27374. /**
  27375. * Creates a new instance DepthOfFieldEffect
  27376. * @param scene The scene the effect belongs to.
  27377. * @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.
  27378. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27379. * @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)
  27380. */
  27381. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27382. /**
  27383. * 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.
  27384. */
  27385. depthTexture: RenderTargetTexture;
  27386. /**
  27387. * Disposes each of the internal effects for a given camera.
  27388. * @param camera The camera to dispose the effect on.
  27389. */
  27390. disposeEffects(camera: Camera): void;
  27391. /**
  27392. * Internal
  27393. */
  27394. _updateEffects(): void;
  27395. /**
  27396. * Internal
  27397. * @returns if all the contained post processes are ready.
  27398. */
  27399. _isReady(): boolean;
  27400. }
  27401. }
  27402. declare module BABYLON {
  27403. /**
  27404. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27405. */
  27406. class DepthOfFieldMergePostProcess extends PostProcess {
  27407. private blurSteps;
  27408. /**
  27409. * Creates a new instance CircleOfConfusionPostProcess
  27410. * @param name The name of the effect.
  27411. * @param original The non-blurred image to be modified
  27412. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  27413. * @param blurSteps Incrimental bluring post processes.
  27414. * @param options The required width/height ratio to downsize to before computing the render pass.
  27415. * @param camera The camera to apply the render pass to.
  27416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27417. * @param engine The engine which the post process will be applied. (default: current engine)
  27418. * @param reusable If the post process can be reused on the same frame. (default: false)
  27419. * @param textureType Type of textures used when performing the post process. (default: 0)
  27420. * @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)
  27421. */
  27422. constructor(name: string, original: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27423. /**
  27424. * Updates the effect with the current post process compile time values and recompiles the shader.
  27425. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27426. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27427. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27428. * @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
  27429. * @param onCompiled Called when the shader has been compiled.
  27430. * @param onError Called if there is an error when compiling a shader.
  27431. */
  27432. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27433. }
  27434. }
  27435. declare module BABYLON {
  27436. class DisplayPassPostProcess extends PostProcess {
  27437. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27438. =======
  27439. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27440. */
  27441. class GeometryBufferRenderer {
  27442. private _scene;
  27443. private _multiRenderTarget;
  27444. private _ratio;
  27445. private _enablePosition;
  27446. protected _effect: Effect;
  27447. protected _cachedDefines: string;
  27448. /**
  27449. * Set the render list (meshes to be rendered) used in the G buffer.
  27450. */
  27451. renderList: Mesh[];
  27452. /**
  27453. * Gets wether or not G buffer are supported by the running hardware.
  27454. * This requires draw buffer supports
  27455. */
  27456. readonly isSupported: boolean;
  27457. /**
  27458. * Gets wether or not position are enabled for the G buffer.
  27459. */
  27460. /**
  27461. * Sets wether or not position are enabled for the G buffer.
  27462. */
  27463. enablePosition: boolean;
  27464. /**
  27465. * Gets the scene associated with the buffer.
  27466. */
  27467. readonly scene: Scene;
  27468. /**
  27469. * Gets the ratio used by the buffer during its creation.
  27470. * How big is the buffer related to the main canvas.
  27471. */
  27472. readonly ratio: number;
  27473. /**
  27474. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  27475. * @param scene The scene the buffer belongs to
  27476. * @param ratio How big is the buffer related to the main canvas.
  27477. */
  27478. constructor(scene: Scene, ratio?: number);
  27479. /**
  27480. * Checks wether everything is ready to render a submesh to the G buffer.
  27481. * @param subMesh the submesh to check readiness for
  27482. * @param useInstances is the mesh drawn using instance or not
  27483. * @returns true if ready otherwise false
  27484. */
  27485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27486. /**
  27487. * Gets the current underlying G Buffer.
  27488. * @returns the buffer
  27489. */
  27490. getGBuffer(): MultiRenderTarget;
  27491. /**
  27492. * Gets the number of samples used to render the buffer (anti aliasing).
  27493. */
  27494. /**
  27495. * Sets the number of samples used to render the buffer (anti aliasing).
  27496. */
  27497. samples: number;
  27498. /**
  27499. * Disposes the renderer and frees up associated resources.
  27500. */
  27501. dispose(): void;
  27502. protected _createRenderTargets(): void;
  27503. }
  27504. }
  27505. declare module BABYLON {
  27506. class OutlineRenderer {
  27507. private _scene;
  27508. private _effect;
  27509. private _cachedDefines;
  27510. zOffset: number;
  27511. constructor(scene: Scene);
  27512. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  27513. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27514. }
  27515. }
  27516. declare module BABYLON {
  27517. class RenderingGroup {
  27518. index: number;
  27519. private _scene;
  27520. private _opaqueSubMeshes;
  27521. private _transparentSubMeshes;
  27522. private _alphaTestSubMeshes;
  27523. private _depthOnlySubMeshes;
  27524. private _particleSystems;
  27525. private _spriteManagers;
  27526. private _opaqueSortCompareFn;
  27527. private _alphaTestSortCompareFn;
  27528. private _transparentSortCompareFn;
  27529. private _renderOpaque;
  27530. private _renderAlphaTest;
  27531. private _renderTransparent;
  27532. private _edgesRenderers;
  27533. onBeforeTransparentRendering: () => void;
  27534. /**
  27535. * Set the opaque sort comparison function.
  27536. * If null the sub meshes will be render in the order they were created
  27537. */
  27538. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  27539. /**
  27540. * Set the alpha test sort comparison function.
  27541. * If null the sub meshes will be render in the order they were created
  27542. */
  27543. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  27544. /**
  27545. * Set the transparent sort comparison function.
  27546. * If null the sub meshes will be render in the order they were created
  27547. */
  27548. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  27549. /**
  27550. * Creates a new rendering group.
  27551. * @param index The rendering group index
  27552. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  27553. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  27554. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  27555. */
  27556. 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>);
  27557. /**
  27558. * Render all the sub meshes contained in the group.
  27559. * @param customRenderFunction Used to override the default render behaviour of the group.
  27560. * @returns true if rendered some submeshes.
  27561. */
  27562. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  27563. /**
  27564. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  27565. * @param subMeshes The submeshes to render
  27566. */
  27567. private renderOpaqueSorted(subMeshes);
  27568. /**
  27569. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  27570. * @param subMeshes The submeshes to render
  27571. */
  27572. private renderAlphaTestSorted(subMeshes);
  27573. /**
  27574. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  27575. * @param subMeshes The submeshes to render
  27576. */
  27577. private renderTransparentSorted(subMeshes);
  27578. /**
  27579. * Renders the submeshes in a specified order.
  27580. * @param subMeshes The submeshes to sort before render
  27581. * @param sortCompareFn The comparison function use to sort
  27582. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  27583. * @param transparent Specifies to activate blending if true
  27584. */
  27585. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  27586. /**
  27587. * Renders the submeshes in the order they were dispatched (no sort applied).
  27588. * @param subMeshes The submeshes to render
  27589. */
  27590. private static renderUnsorted(subMeshes);
  27591. /**
  27592. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  27593. * are rendered back to front if in the same alpha index.
  27594. *
  27595. * @param a The first submesh
  27596. * @param b The second submesh
  27597. * @returns The result of the comparison
  27598. */
  27599. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  27600. /**
  27601. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  27602. * are rendered back to front.
  27603. *
  27604. * @param a The first submesh
  27605. * @param b The second submesh
  27606. * @returns The result of the comparison
  27607. */
  27608. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  27609. /**
  27610. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  27611. * are rendered front to back (prevent overdraw).
  27612. *
  27613. * @param a The first submesh
  27614. * @param b The second submesh
  27615. * @returns The result of the comparison
  27616. */
  27617. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  27618. /**
  27619. * Resets the different lists of submeshes to prepare a new frame.
  27620. */
  27621. prepare(): void;
  27622. dispose(): void;
  27623. /**
  27624. * Inserts the submesh in its correct queue depending on its material.
  27625. * @param subMesh The submesh to dispatch
  27626. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  27627. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  27628. */
  27629. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  27630. dispatchSprites(spriteManager: SpriteManager): void;
  27631. dispatchParticles(particleSystem: IParticleSystem): void;
  27632. private _renderParticles(activeMeshes);
  27633. private _renderSprites();
  27634. }
  27635. }
  27636. declare module BABYLON {
  27637. class RenderingManager {
  27638. /**
  27639. * The max id used for rendering groups (not included)
  27640. */
  27641. static MAX_RENDERINGGROUPS: number;
  27642. /**
  27643. * The min id used for rendering groups (included)
  27644. */
  27645. static MIN_RENDERINGGROUPS: number;
  27646. /**
  27647. * Used to globally prevent autoclearing scenes.
  27648. */
  27649. static AUTOCLEAR: boolean;
  27650. private _scene;
  27651. private _renderingGroups;
  27652. private _depthStencilBufferAlreadyCleaned;
  27653. private _autoClearDepthStencil;
  27654. private _customOpaqueSortCompareFn;
  27655. private _customAlphaTestSortCompareFn;
  27656. private _customTransparentSortCompareFn;
  27657. private _renderinGroupInfo;
  27658. constructor(scene: Scene);
  27659. private _clearDepthStencilBuffer(depth?, stencil?);
  27660. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  27661. reset(): void;
  27662. dispose(): void;
  27663. /**
  27664. * Clear the info related to rendering groups preventing retention points during dispose.
  27665. */
  27666. freeRenderingGroups(): void;
  27667. private _prepareRenderingGroup(renderingGroupId);
  27668. dispatchSprites(spriteManager: SpriteManager): void;
  27669. dispatchParticles(particleSystem: IParticleSystem): void;
  27670. /**
  27671. * @param subMesh The submesh to dispatch
  27672. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  27673. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  27674. */
  27675. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  27676. /**
  27677. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  27678. * This allowed control for front to back rendering or reversly depending of the special needs.
  27679. *
  27680. * @param renderingGroupId The rendering group id corresponding to its index
  27681. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  27682. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  27683. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  27684. */
  27685. 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;
  27686. /**
  27687. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27688. *
  27689. * @param renderingGroupId The rendering group id corresponding to its index
  27690. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27691. * @param depth Automatically clears depth between groups if true and autoClear is true.
  27692. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  27693. */
  27694. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  27695. }
  27696. }
  27697. declare module BABYLON {
  27698. class AnaglyphPostProcess extends PostProcess {
  27699. private _passedProcess;
  27700. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27701. }
  27702. }
  27703. declare module BABYLON {
  27704. class BlackAndWhitePostProcess extends PostProcess {
  27705. degree: number;
  27706. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27707. }
  27708. }
  27709. declare module BABYLON {
  27710. /**
  27711. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27712. */
  27713. class BloomEffect extends PostProcessRenderEffect {
  27714. private bloomScale;
  27715. /**
  27716. * Internal
  27717. */
  27718. _effects: Array<PostProcess>;
  27719. /**
  27720. * Internal
  27721. */
  27722. _downscale: ExtractHighlightsPostProcess;
  27723. private _blurX;
  27724. private _blurY;
  27725. private _upscale;
  27726. private _merge;
  27727. /**
  27728. * The luminance threshold to find bright areas of the image to bloom.
  27729. */
  27730. threshold: number;
  27731. /**
  27732. * The strength of the bloom.
  27733. */
  27734. weight: number;
  27735. /**
  27736. * Specifies the size of the bloom blur kernel, relative to the final output size
  27737. */
  27738. kernel: number;
  27739. /**
  27740. * Creates a new instance of @see BloomEffect
  27741. * @param scene The scene the effect belongs to.
  27742. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27743. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27744. * @param bloomWeight The the strength of bloom.
  27745. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27746. * @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)
  27747. */
  27748. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27749. /**
  27750. * Disposes each of the internal effects for a given camera.
  27751. * @param camera The camera to dispose the effect on.
  27752. */
  27753. disposeEffects(camera: Camera): void;
  27754. /**
  27755. * Internal
  27756. */
  27757. _updateEffects(): void;
  27758. /**
  27759. * Internal
  27760. * @returns if all the contained post processes are ready.
  27761. */
  27762. _isReady(): boolean;
  27763. }
  27764. }
  27765. declare module BABYLON {
  27766. /**
  27767. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27768. */
  27769. class BloomMergePostProcess extends PostProcess {
  27770. /** Weight of the bloom to be added to the original input. */ weight: number;
  27771. /**
  27772. * Creates a new instance of @see BloomMergePostProcess
  27773. * @param name The name of the effect.
  27774. * @param originalFromInput Post process which's input will be used for the merge.
  27775. * @param blurred Blurred highlights post process which's output will be used.
  27776. * @param weight Weight of the bloom to be added to the original input.
  27777. * @param options The required width/height ratio to downsize to before computing the render pass.
  27778. * @param camera The camera to apply the render pass to.
  27779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27780. * @param engine The engine which the post process will be applied. (default: current engine)
  27781. * @param reusable If the post process can be reused on the same frame. (default: false)
  27782. * @param textureType Type of textures used when performing the post process. (default: 0)
  27783. * @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)
  27784. */
  27785. 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);
  27786. }
  27787. }
  27788. declare module BABYLON {
  27789. /**
  27790. * The Blur Post Process which blurs an image based on a kernel and direction.
  27791. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27792. */
  27793. class BlurPostProcess extends PostProcess {
  27794. /** The direction in which to blur the image. */ direction: Vector2;
  27795. private blockCompilation;
  27796. protected _kernel: number;
  27797. protected _idealKernel: number;
  27798. protected _packedFloat: boolean;
  27799. private _staticDefines;
  27800. /**
  27801. * Gets the length in pixels of the blur sample region
  27802. */
  27803. /**
  27804. * Sets the length in pixels of the blur sample region
  27805. */
  27806. kernel: number;
  27807. /**
  27808. * Gets wether or not the blur is unpacking/repacking floats
  27809. */
  27810. /**
  27811. * Sets wether or not the blur needs to unpack/repack floats
  27812. */
  27813. packedFloat: boolean;
  27814. /**
  27815. * Creates a new instance of @see BlurPostProcess
  27816. * @param name The name of the effect.
  27817. * @param direction The direction in which to blur the image.
  27818. * @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.
  27819. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27820. * @param camera The camera to apply the render pass to.
  27821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27822. * @param engine The engine which the post process will be applied. (default: current engine)
  27823. * @param reusable If the post process can be reused on the same frame. (default: false)
  27824. * @param textureType Type of textures used when performing the post process. (default: 0)
  27825. * @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)
  27826. */
  27827. 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);
  27828. /**
  27829. * Updates the effect with the current post process compile time values and recompiles the shader.
  27830. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27831. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27832. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27833. * @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
  27834. * @param onCompiled Called when the shader has been compiled.
  27835. * @param onError Called if there is an error when compiling a shader.
  27836. */
  27837. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27838. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27839. /**
  27840. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27841. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27842. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27843. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27844. * The gaps between physical kernels are compensated for in the weighting of the samples
  27845. * @param idealKernel Ideal blur kernel.
  27846. * @return Nearest best kernel.
  27847. */
  27848. protected _nearestBestKernel(idealKernel: number): number;
  27849. /**
  27850. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27851. * @param x The point on the Gaussian distribution to sample.
  27852. * @return the value of the Gaussian function at x.
  27853. */
  27854. protected _gaussianWeight(x: number): number;
  27855. /**
  27856. * Generates a string that can be used as a floating point number in GLSL.
  27857. * @param x Value to print.
  27858. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27859. * @return GLSL float string.
  27860. */
  27861. protected _glslFloat(x: number, decimalFigures?: number): string;
  27862. }
  27863. }
  27864. declare module BABYLON {
  27865. /**
  27866. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27867. */
  27868. class ChromaticAberrationPostProcess extends PostProcess {
  27869. /**
  27870. * The amount of seperation of rgb channels (default: 30)
  27871. */
  27872. aberrationAmount: number;
  27873. /**
  27874. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27875. */
  27876. radialIntensity: number;
  27877. /**
  27878. * 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))
  27879. */
  27880. direction: Vector2;
  27881. /**
  27882. * 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))
  27883. */
  27884. centerPosition: Vector2;
  27885. /**
  27886. * Creates a new instance of @see ChromaticAberrationPostProcess
  27887. * @param name The name of the effect.
  27888. * @param screenWidth The width of the screen to apply the effect on.
  27889. * @param screenHeight The height of the screen to apply the effect on.
  27890. * @param options The required width/height ratio to downsize to before computing the render pass.
  27891. * @param camera The camera to apply the render pass to.
  27892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27893. * @param engine The engine which the post process will be applied. (default: current engine)
  27894. * @param reusable If the post process can be reused on the same frame. (default: false)
  27895. * @param textureType Type of textures used when performing the post process. (default: 0)
  27896. * @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)
  27897. */
  27898. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27899. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27900. }
  27901. }
  27902. declare module BABYLON {
  27903. <<<<<<< HEAD
  27904. class FilterPostProcess extends PostProcess {
  27905. kernelMatrix: Matrix;
  27906. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27907. =======
  27908. /**
  27909. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27910. */
  27911. class CircleOfConfusionPostProcess extends PostProcess {
  27912. /**
  27913. * 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.
  27914. */
  27915. lensSize: number;
  27916. /**
  27917. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27918. */
  27919. fStop: number;
  27920. /**
  27921. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27922. */
  27923. focusDistance: number;
  27924. /**
  27925. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27926. */
  27927. focalLength: number;
  27928. private _depthTexture;
  27929. /**
  27930. * Creates a new instance of @see CircleOfConfusionPostProcess
  27931. * @param name The name of the effect.
  27932. * @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.
  27933. * @param options The required width/height ratio to downsize to before computing the render pass.
  27934. * @param camera The camera to apply the render pass to.
  27935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27936. * @param engine The engine which the post process will be applied. (default: current engine)
  27937. * @param reusable If the post process can be reused on the same frame. (default: false)
  27938. * @param textureType Type of textures used when performing the post process. (default: 0)
  27939. * @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)
  27940. */
  27941. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27942. /**
  27943. * 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.
  27944. */
  27945. depthTexture: RenderTargetTexture;
  27946. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27947. }
  27948. }
  27949. declare module BABYLON {
  27950. <<<<<<< HEAD
  27951. class FxaaPostProcess extends PostProcess {
  27952. texelWidth: number;
  27953. texelHeight: number;
  27954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27955. =======
  27956. class ColorCorrectionPostProcess extends PostProcess {
  27957. private _colorTableTexture;
  27958. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27959. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  27960. }
  27961. }
  27962. declare module BABYLON {
  27963. <<<<<<< HEAD
  27964. class HighlightsPostProcess extends PostProcess {
  27965. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27966. }
  27967. }
  27968. declare module BABYLON {
  27969. class ImageProcessingPostProcess extends PostProcess {
  27970. /**
  27971. * Default configuration related to image processing available in the PBR Material.
  27972. */
  27973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27974. /**
  27975. * Gets the image processing configuration used either in this material.
  27976. */
  27977. /**
  27978. * Sets the Default image processing configuration used either in the this material.
  27979. *
  27980. * If sets to null, the scene one is in use.
  27981. */
  27982. imageProcessingConfiguration: ImageProcessingConfiguration;
  27983. /**
  27984. * Keep track of the image processing observer to allow dispose and replace.
  27985. */
  27986. private _imageProcessingObserver;
  27987. /**
  27988. * Attaches a new image processing configuration to the PBR Material.
  27989. * @param configuration
  27990. */
  27991. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27992. /**
  27993. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27994. */
  27995. /**
  27996. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27997. */
  27998. colorCurves: Nullable<ColorCurves>;
  27999. /**
  28000. * Gets wether the color curves effect is enabled.
  28001. */
  28002. /**
  28003. * Sets wether the color curves effect is enabled.
  28004. */
  28005. colorCurvesEnabled: boolean;
  28006. /**
  28007. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28008. */
  28009. /**
  28010. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28011. */
  28012. colorGradingTexture: Nullable<BaseTexture>;
  28013. /**
  28014. * Gets wether the color grading effect is enabled.
  28015. */
  28016. /**
  28017. * Gets wether the color grading effect is enabled.
  28018. */
  28019. colorGradingEnabled: boolean;
  28020. /**
  28021. * Gets exposure used in the effect.
  28022. */
  28023. /**
  28024. * Sets exposure used in the effect.
  28025. */
  28026. exposure: number;
  28027. /**
  28028. * Gets wether tonemapping is enabled or not.
  28029. */
  28030. /**
  28031. * Sets wether tonemapping is enabled or not
  28032. */
  28033. toneMappingEnabled: boolean;
  28034. /**
  28035. * Gets contrast used in the effect.
  28036. */
  28037. /**
  28038. * Sets contrast used in the effect.
  28039. */
  28040. contrast: number;
  28041. /**
  28042. * Gets Vignette stretch size.
  28043. */
  28044. /**
  28045. * Sets Vignette stretch size.
  28046. */
  28047. vignetteStretch: number;
  28048. /**
  28049. * Gets Vignette centre X Offset.
  28050. */
  28051. /**
  28052. * Sets Vignette centre X Offset.
  28053. */
  28054. vignetteCentreX: number;
  28055. /**
  28056. * Gets Vignette centre Y Offset.
  28057. */
  28058. /**
  28059. * Sets Vignette centre Y Offset.
  28060. */
  28061. vignetteCentreY: number;
  28062. /**
  28063. * Gets Vignette weight or intensity of the vignette effect.
  28064. */
  28065. /**
  28066. * Sets Vignette weight or intensity of the vignette effect.
  28067. */
  28068. vignetteWeight: number;
  28069. /**
  28070. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28071. * if vignetteEnabled is set to true.
  28072. */
  28073. /**
  28074. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28075. * if vignetteEnabled is set to true.
  28076. */
  28077. vignetteColor: Color4;
  28078. /**
  28079. * Gets Camera field of view used by the Vignette effect.
  28080. */
  28081. /**
  28082. * Sets Camera field of view used by the Vignette effect.
  28083. */
  28084. vignetteCameraFov: number;
  28085. /**
  28086. * Gets the vignette blend mode allowing different kind of effect.
  28087. */
  28088. /**
  28089. * Sets the vignette blend mode allowing different kind of effect.
  28090. */
  28091. vignetteBlendMode: number;
  28092. /**
  28093. * Gets wether the vignette effect is enabled.
  28094. */
  28095. /**
  28096. * Sets wether the vignette effect is enabled.
  28097. */
  28098. vignetteEnabled: boolean;
  28099. /**
  28100. * Gets wether the grain effect is enabled.
  28101. */
  28102. /**
  28103. * Sets wether the grain effect is enabled.
  28104. */
  28105. grainEnabled: boolean;
  28106. /**
  28107. * Gets the grain effect's intensity.
  28108. */
  28109. /**
  28110. * Sets the grain effect's intensity.
  28111. */
  28112. grainIntensity: number;
  28113. /**
  28114. * Gets wether the grain effect is animated.
  28115. */
  28116. /**
  28117. * Sets wether the grain effect is animated.
  28118. */
  28119. grainAnimated: boolean;
  28120. =======
  28121. /**
  28122. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  28123. * input texture to perform effects such as edge detection or sharpening
  28124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28125. */
  28126. class ConvolutionPostProcess extends PostProcess {
  28127. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  28128. /**
  28129. * Creates a new instance of @see ConvolutionPostProcess
  28130. * @param name The name of the effect.
  28131. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  28132. * @param options The required width/height ratio to downsize to before computing the render pass.
  28133. * @param camera The camera to apply the render pass to.
  28134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28135. * @param engine The engine which the post process will be applied. (default: current engine)
  28136. * @param reusable If the post process can be reused on the same frame. (default: false)
  28137. * @param textureType Type of textures used when performing the post process. (default: 0)
  28138. */
  28139. 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);
  28140. /**
  28141. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28142. */
  28143. static EdgeDetect0Kernel: number[];
  28144. /**
  28145. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28146. */
  28147. static EdgeDetect1Kernel: number[];
  28148. /**
  28149. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28150. */
  28151. static EdgeDetect2Kernel: number[];
  28152. /**
  28153. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28154. */
  28155. static SharpenKernel: number[];
  28156. /**
  28157. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28158. */
  28159. static EmbossKernel: number[];
  28160. /**
  28161. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28162. */
  28163. static GaussianKernel: number[];
  28164. }
  28165. }
  28166. declare module BABYLON {
  28167. /**
  28168. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  28169. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  28170. * based on samples that have a large difference in distance than the center pixel.
  28171. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  28172. */
  28173. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  28174. direction: Vector2;
  28175. /**
  28176. * Creates a new instance of @see CircleOfConfusionPostProcess
  28177. * @param name The name of the effect.
  28178. * @param scene The scene the effect belongs to.
  28179. * @param direction The direction the blur should be applied.
  28180. * @param kernel The size of the kernel used to blur.
  28181. * @param options The required width/height ratio to downsize to before computing the render pass.
  28182. * @param camera The camera to apply the render pass to.
  28183. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  28184. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  28185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28186. * @param engine The engine which the post process will be applied. (default: current engine)
  28187. * @param reusable If the post process can be reused on the same frame. (default: false)
  28188. * @param textureType Type of textures used when performing the post process. (default: 0)
  28189. * @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)
  28190. */
  28191. 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);
  28192. }
  28193. }
  28194. declare module BABYLON {
  28195. /**
  28196. * Specifies the level of max blur that should be applied when using the depth of field effect
  28197. */
  28198. enum DepthOfFieldEffectBlurLevel {
  28199. /**
  28200. * Subtle blur
  28201. */
  28202. Low = 0,
  28203. /**
  28204. * Medium blur
  28205. */
  28206. Medium = 1,
  28207. /**
  28208. * Large blur
  28209. */
  28210. High = 2,
  28211. }
  28212. /**
  28213. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  28214. */
  28215. class DepthOfFieldEffect extends PostProcessRenderEffect {
  28216. private _circleOfConfusion;
  28217. /**
  28218. * Internal, blurs from high to low
  28219. */
  28220. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  28221. private _depthOfFieldBlurY;
  28222. private _dofMerge;
  28223. /**
  28224. * Internal post processes in depth of field effect
  28225. */
  28226. _effects: Array<PostProcess>;
  28227. /**
  28228. * The focal the length of the camera used in the effect
  28229. */
  28230. focalLength: number;
  28231. /**
  28232. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  28233. */
  28234. fStop: number;
  28235. /**
  28236. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  28237. */
  28238. focusDistance: number;
  28239. /**
  28240. * 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.
  28241. */
  28242. lensSize: number;
  28243. /**
  28244. * Creates a new instance of @see DepthOfFieldEffect
  28245. * @param scene The scene the effect belongs to.
  28246. * @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.
  28247. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  28248. * @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)
  28249. */
  28250. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  28251. /**
  28252. * 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.
  28253. */
  28254. depthTexture: RenderTargetTexture;
  28255. /**
  28256. * Disposes each of the internal effects for a given camera.
  28257. * @param camera The camera to dispose the effect on.
  28258. */
  28259. disposeEffects(camera: Camera): void;
  28260. /**
  28261. * Internal
  28262. */
  28263. _updateEffects(): void;
  28264. /**
  28265. * Internal
  28266. * @returns if all the contained post processes are ready.
  28267. */
  28268. _isReady(): boolean;
  28269. }
  28270. }
  28271. declare module BABYLON {
  28272. /**
  28273. * Options to be set when merging outputs from the default pipeline.
  28274. */
  28275. class DepthOfFieldMergePostProcessOptions {
  28276. /**
  28277. * The original image to merge on top of
  28278. */
  28279. originalFromInput: PostProcess;
  28280. /**
  28281. * Parameters to perform the merge of the depth of field effect
  28282. */
  28283. depthOfField?: {
  28284. circleOfConfusion: PostProcess;
  28285. blurSteps: Array<PostProcess>;
  28286. };
  28287. /**
  28288. * Parameters to perform the merge of bloom effect
  28289. */
  28290. bloom?: {
  28291. blurred: PostProcess;
  28292. weight: number;
  28293. };
  28294. }
  28295. /**
  28296. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  28297. */
  28298. class DepthOfFieldMergePostProcess extends PostProcess {
  28299. private blurSteps;
  28300. /**
  28301. * Creates a new instance of @see DepthOfFieldMergePostProcess
  28302. * @param name The name of the effect.
  28303. * @param originalFromInput Post process which's input will be used for the merge.
  28304. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  28305. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  28306. * @param options The required width/height ratio to downsize to before computing the render pass.
  28307. * @param camera The camera to apply the render pass to.
  28308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28309. * @param engine The engine which the post process will be applied. (default: current engine)
  28310. * @param reusable If the post process can be reused on the same frame. (default: false)
  28311. * @param textureType Type of textures used when performing the post process. (default: 0)
  28312. * @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)
  28313. */
  28314. 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);
  28315. /**
  28316. * Updates the effect with the current post process compile time values and recompiles the shader.
  28317. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28318. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28319. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28320. * @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
  28321. * @param onCompiled Called when the shader has been compiled.
  28322. * @param onError Called if there is an error when compiling a shader.
  28323. */
  28324. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28325. }
  28326. }
  28327. declare module BABYLON {
  28328. class DisplayPassPostProcess extends PostProcess {
  28329. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28330. }
  28331. }
  28332. declare module BABYLON {
  28333. /**
  28334. * 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.
  28335. */
  28336. class ExtractHighlightsPostProcess extends PostProcess {
  28337. /**
  28338. * The luminance threshold, pixels below this value will be set to black.
  28339. */
  28340. threshold: number;
  28341. /**
  28342. * Internal
  28343. */
  28344. _exposure: number;
  28345. /**
  28346. * Post process which has the input texture to be used when performing highlight extraction
  28347. */
  28348. _inputPostProcess: Nullable<PostProcess>;
  28349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28350. }
  28351. }
  28352. declare module BABYLON {
  28353. class FilterPostProcess extends PostProcess {
  28354. kernelMatrix: Matrix;
  28355. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28356. }
  28357. }
  28358. declare module BABYLON {
  28359. class FxaaPostProcess extends PostProcess {
  28360. texelWidth: number;
  28361. texelHeight: number;
  28362. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28363. }
  28364. }
  28365. declare module BABYLON {
  28366. /**
  28367. * The GrainPostProcess adds noise to the image at mid luminance levels
  28368. */
  28369. class GrainPostProcess extends PostProcess {
  28370. /**
  28371. * The intensity of the grain added (default: 30)
  28372. */
  28373. intensity: number;
  28374. /**
  28375. * If the grain should be randomized on every frame
  28376. */
  28377. animated: boolean;
  28378. /**
  28379. * Creates a new instance of @see GrainPostProcess
  28380. * @param name The name of the effect.
  28381. * @param options The required width/height ratio to downsize to before computing the render pass.
  28382. * @param camera The camera to apply the render pass to.
  28383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28384. * @param engine The engine which the post process will be applied. (default: current engine)
  28385. * @param reusable If the post process can be reused on the same frame. (default: false)
  28386. * @param textureType Type of textures used when performing the post process. (default: 0)
  28387. * @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)
  28388. */
  28389. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28390. }
  28391. }
  28392. declare module BABYLON {
  28393. class HighlightsPostProcess extends PostProcess {
  28394. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28395. }
  28396. }
  28397. declare module BABYLON {
  28398. class ImageProcessingPostProcess extends PostProcess {
  28399. /**
  28400. * Default configuration related to image processing available in the PBR Material.
  28401. */
  28402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28403. /**
  28404. * Gets the image processing configuration used either in this material.
  28405. */
  28406. /**
  28407. * Sets the Default image processing configuration used either in the this material.
  28408. *
  28409. * If sets to null, the scene one is in use.
  28410. */
  28411. imageProcessingConfiguration: ImageProcessingConfiguration;
  28412. /**
  28413. * Keep track of the image processing observer to allow dispose and replace.
  28414. */
  28415. private _imageProcessingObserver;
  28416. /**
  28417. * Attaches a new image processing configuration to the PBR Material.
  28418. * @param configuration
  28419. */
  28420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  28421. /**
  28422. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28423. */
  28424. /**
  28425. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28426. */
  28427. colorCurves: Nullable<ColorCurves>;
  28428. /**
  28429. * Gets wether the color curves effect is enabled.
  28430. */
  28431. /**
  28432. * Sets wether the color curves effect is enabled.
  28433. */
  28434. colorCurvesEnabled: boolean;
  28435. /**
  28436. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28437. */
  28438. /**
  28439. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28440. */
  28441. colorGradingTexture: Nullable<BaseTexture>;
  28442. /**
  28443. * Gets wether the color grading effect is enabled.
  28444. */
  28445. /**
  28446. * Gets wether the color grading effect is enabled.
  28447. */
  28448. colorGradingEnabled: boolean;
  28449. /**
  28450. * Gets exposure used in the effect.
  28451. */
  28452. /**
  28453. * Sets exposure used in the effect.
  28454. */
  28455. exposure: number;
  28456. /**
  28457. * Gets wether tonemapping is enabled or not.
  28458. */
  28459. /**
  28460. * Sets wether tonemapping is enabled or not
  28461. */
  28462. toneMappingEnabled: boolean;
  28463. /**
  28464. * Gets contrast used in the effect.
  28465. */
  28466. /**
  28467. * Sets contrast used in the effect.
  28468. */
  28469. contrast: number;
  28470. /**
  28471. * Gets Vignette stretch size.
  28472. */
  28473. /**
  28474. * Sets Vignette stretch size.
  28475. */
  28476. vignetteStretch: number;
  28477. /**
  28478. * Gets Vignette centre X Offset.
  28479. */
  28480. /**
  28481. * Sets Vignette centre X Offset.
  28482. */
  28483. vignetteCentreX: number;
  28484. /**
  28485. * Gets Vignette centre Y Offset.
  28486. */
  28487. /**
  28488. * Sets Vignette centre Y Offset.
  28489. */
  28490. vignetteCentreY: number;
  28491. /**
  28492. * Gets Vignette weight or intensity of the vignette effect.
  28493. */
  28494. /**
  28495. * Sets Vignette weight or intensity of the vignette effect.
  28496. */
  28497. vignetteWeight: number;
  28498. /**
  28499. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28500. * if vignetteEnabled is set to true.
  28501. */
  28502. /**
  28503. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28504. * if vignetteEnabled is set to true.
  28505. */
  28506. vignetteColor: Color4;
  28507. /**
  28508. * Gets Camera field of view used by the Vignette effect.
  28509. */
  28510. /**
  28511. * Sets Camera field of view used by the Vignette effect.
  28512. */
  28513. vignetteCameraFov: number;
  28514. /**
  28515. * Gets the vignette blend mode allowing different kind of effect.
  28516. */
  28517. /**
  28518. * Sets the vignette blend mode allowing different kind of effect.
  28519. */
  28520. vignetteBlendMode: number;
  28521. /**
  28522. * Gets wether the vignette effect is enabled.
  28523. */
  28524. /**
  28525. * Sets wether the vignette effect is enabled.
  28526. */
  28527. vignetteEnabled: boolean;
  28528. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  28529. private _fromLinearSpace;
  28530. /**
  28531. * Gets wether the input of the processing is in Gamma or Linear Space.
  28532. */
  28533. /**
  28534. * Sets wether the input of the processing is in Gamma or Linear Space.
  28535. */
  28536. fromLinearSpace: boolean;
  28537. /**
  28538. * Defines cache preventing GC.
  28539. */
  28540. private _defines;
  28541. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  28542. getClassName(): string;
  28543. protected _updateParameters(): void;
  28544. dispose(camera?: Camera): void;
  28545. }
  28546. }
  28547. declare module BABYLON {
  28548. class PassPostProcess extends PostProcess {
  28549. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28550. }
  28551. }
  28552. declare module BABYLON {
  28553. type PostProcessOptions = {
  28554. width: number;
  28555. height: number;
  28556. };
  28557. /**
  28558. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28559. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28560. */
  28561. class PostProcess {
  28562. /** Name of the PostProcess. */ name: string;
  28563. <<<<<<< HEAD
  28564. /**
  28565. * Width of the texture to apply the post process on
  28566. */
  28567. width: number;
  28568. /**
  28569. * Height of the texture to apply the post process on
  28570. */
  28571. height: number;
  28572. /**
  28573. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28574. */
  28575. _outputTexture: Nullable<InternalTexture>;
  28576. /**
  28577. * Sampling mode used by the shader
  28578. * See https://doc.babylonjs.com/classes/3.1/texture
  28579. */
  28580. renderTargetSamplingMode: number;
  28581. /**
  28582. * Clear color to use when screen clearing
  28583. */
  28584. clearColor: Color4;
  28585. /**
  28586. * If the buffer needs to be cleared before applying the post process. (default: true)
  28587. * Should be set to false if shader will overwrite all previous pixels.
  28588. */
  28589. autoClear: boolean;
  28590. /**
  28591. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28592. */
  28593. alphaMode: number;
  28594. /**
  28595. * Sets the setAlphaBlendConstants of the babylon engine
  28596. */
  28597. alphaConstants: Color4;
  28598. /**
  28599. * Animations to be used for the post processing
  28600. */
  28601. animations: Animation[];
  28602. /**
  28603. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28604. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28605. */
  28606. enablePixelPerfectMode: boolean;
  28607. /**
  28608. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28609. */
  28610. scaleMode: number;
  28611. /**
  28612. * Force textures to be a power of two (default: false)
  28613. */
  28614. alwaysForcePOT: boolean;
  28615. /**
  28616. * Number of sample textures (default: 1)
  28617. */
  28618. samples: number;
  28619. /**
  28620. * Modify the scale of the post process to be the same as the viewport (default: false)
  28621. */
  28622. adaptScaleToCurrentViewport: boolean;
  28623. private _camera;
  28624. private _scene;
  28625. private _engine;
  28626. private _options;
  28627. private _reusable;
  28628. private _textureType;
  28629. /**
  28630. * Smart array of input and output textures for the post process.
  28631. */
  28632. _textures: SmartArray<InternalTexture>;
  28633. /**
  28634. * The index in _textures that corresponds to the output texture.
  28635. */
  28636. _currentRenderTextureInd: number;
  28637. private _effect;
  28638. private _samplers;
  28639. private _fragmentUrl;
  28640. private _vertexUrl;
  28641. private _parameters;
  28642. private _scaleRatio;
  28643. protected _indexParameters: any;
  28644. private _shareOutputWithPostProcess;
  28645. private _texelSize;
  28646. private _forcedOutputTexture;
  28647. /**
  28648. * An event triggered when the postprocess is activated.
  28649. * @type {BABYLON.Observable}
  28650. */
  28651. onActivateObservable: Observable<Camera>;
  28652. private _onActivateObserver;
  28653. /**
  28654. * A function that is added to the onActivateObservable
  28655. */
  28656. onActivate: Nullable<(camera: Camera) => void>;
  28657. /**
  28658. * An event triggered when the postprocess changes its size.
  28659. * @type {BABYLON.Observable}
  28660. */
  28661. onSizeChangedObservable: Observable<PostProcess>;
  28662. private _onSizeChangedObserver;
  28663. /**
  28664. * A function that is added to the onSizeChangedObservable
  28665. */
  28666. onSizeChanged: (postProcess: PostProcess) => void;
  28667. /**
  28668. * An event triggered when the postprocess applies its effect.
  28669. * @type {BABYLON.Observable}
  28670. */
  28671. onApplyObservable: Observable<Effect>;
  28672. private _onApplyObserver;
  28673. /**
  28674. * A function that is added to the onApplyObservable
  28675. */
  28676. onApply: (effect: Effect) => void;
  28677. /**
  28678. * An event triggered before rendering the postprocess
  28679. * @type {BABYLON.Observable}
  28680. */
  28681. onBeforeRenderObservable: Observable<Effect>;
  28682. private _onBeforeRenderObserver;
  28683. /**
  28684. * A function that is added to the onBeforeRenderObservable
  28685. */
  28686. onBeforeRender: (effect: Effect) => void;
  28687. /**
  28688. * An event triggered after rendering the postprocess
  28689. * @type {BABYLON.Observable}
  28690. */
  28691. onAfterRenderObservable: Observable<Effect>;
  28692. private _onAfterRenderObserver;
  28693. /**
  28694. * A function that is added to the onAfterRenderObservable
  28695. */
  28696. onAfterRender: (efect: Effect) => void;
  28697. /**
  28698. * 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
  28699. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28700. */
  28701. inputTexture: InternalTexture;
  28702. /**
  28703. * Gets the camera which post process is applied to.
  28704. * @returns The camera the post process is applied to.
  28705. */
  28706. getCamera(): Camera;
  28707. /**
  28708. * Gets the texel size of the postprocess.
  28709. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28710. */
  28711. readonly texelSize: Vector2;
  28712. /**
  28713. * Creates a new instance PostProcess
  28714. * @param name The name of the PostProcess.
  28715. * @param fragmentUrl The url of the fragment shader to be used.
  28716. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28717. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28718. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28719. * @param camera The camera to apply the render pass to.
  28720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28721. * @param engine The engine which the post process will be applied. (default: current engine)
  28722. * @param reusable If the post process can be reused on the same frame. (default: false)
  28723. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28724. * @param textureType Type of textures used when performing the post process. (default: 0)
  28725. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28726. * @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
  28727. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28728. */
  28729. 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);
  28730. /**
  28731. * Gets the engine which this post process belongs to.
  28732. * @returns The engine the post process was enabled with.
  28733. */
  28734. getEngine(): Engine;
  28735. /**
  28736. * The effect that is created when initializing the post process.
  28737. * @returns The created effect corrisponding the the postprocess.
  28738. */
  28739. getEffect(): Effect;
  28740. /**
  28741. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28742. * @param postProcess The post process to share the output with.
  28743. * @returns This post process.
  28744. */
  28745. shareOutputWith(postProcess: PostProcess): PostProcess;
  28746. /**
  28747. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28748. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28749. */
  28750. useOwnOutput(): void;
  28751. /**
  28752. * Updates the effect with the current post process compile time values and recompiles the shader.
  28753. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28754. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28755. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28756. * @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
  28757. * @param onCompiled Called when the shader has been compiled.
  28758. * @param onError Called if there is an error when compiling a shader.
  28759. */
  28760. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28761. /**
  28762. * The post process is reusable if it can be used multiple times within one frame.
  28763. * @returns If the post process is reusable
  28764. */
  28765. isReusable(): boolean;
  28766. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28767. markTextureDirty(): void;
  28768. /**
  28769. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28770. * 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.
  28771. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28772. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28773. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28774. * @returns The target texture that was bound to be written to.
  28775. */
  28776. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28777. /**
  28778. * If the post process is supported.
  28779. */
  28780. readonly isSupported: boolean;
  28781. /**
  28782. * The aspect ratio of the output texture.
  28783. */
  28784. readonly aspectRatio: number;
  28785. /**
  28786. * Get a value indicating if the post-process is ready to be used
  28787. * @returns true if the post-process is ready (shader is compiled)
  28788. */
  28789. isReady(): boolean;
  28790. /**
  28791. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28792. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28793. */
  28794. apply(): Nullable<Effect>;
  28795. private _disposeTextures();
  28796. /**
  28797. * Disposes the post process.
  28798. * @param camera The camera to dispose the post process on.
  28799. */
  28800. =======
  28801. /**
  28802. * Width of the texture to apply the post process on
  28803. */
  28804. width: number;
  28805. /**
  28806. * Height of the texture to apply the post process on
  28807. */
  28808. height: number;
  28809. /**
  28810. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28811. */
  28812. _outputTexture: Nullable<InternalTexture>;
  28813. /**
  28814. * Sampling mode used by the shader
  28815. * See https://doc.babylonjs.com/classes/3.1/texture
  28816. */
  28817. renderTargetSamplingMode: number;
  28818. /**
  28819. * Clear color to use when screen clearing
  28820. */
  28821. clearColor: Color4;
  28822. /**
  28823. * If the buffer needs to be cleared before applying the post process. (default: true)
  28824. * Should be set to false if shader will overwrite all previous pixels.
  28825. */
  28826. autoClear: boolean;
  28827. /**
  28828. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28829. */
  28830. alphaMode: number;
  28831. /**
  28832. * Sets the setAlphaBlendConstants of the babylon engine
  28833. */
  28834. alphaConstants: Color4;
  28835. /**
  28836. * Animations to be used for the post processing
  28837. */
  28838. animations: Animation[];
  28839. /**
  28840. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28841. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28842. */
  28843. enablePixelPerfectMode: boolean;
  28844. /**
  28845. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28846. */
  28847. scaleMode: number;
  28848. /**
  28849. * Force textures to be a power of two (default: false)
  28850. */
  28851. alwaysForcePOT: boolean;
  28852. /**
  28853. * Number of sample textures (default: 1)
  28854. */
  28855. samples: number;
  28856. /**
  28857. * Modify the scale of the post process to be the same as the viewport (default: false)
  28858. */
  28859. adaptScaleToCurrentViewport: boolean;
  28860. private _camera;
  28861. private _scene;
  28862. private _engine;
  28863. private _options;
  28864. private _reusable;
  28865. private _textureType;
  28866. /**
  28867. * Smart array of input and output textures for the post process.
  28868. */
  28869. _textures: SmartArray<InternalTexture>;
  28870. /**
  28871. * The index in _textures that corresponds to the output texture.
  28872. */
  28873. _currentRenderTextureInd: number;
  28874. private _effect;
  28875. private _samplers;
  28876. private _fragmentUrl;
  28877. private _vertexUrl;
  28878. private _parameters;
  28879. private _scaleRatio;
  28880. protected _indexParameters: any;
  28881. private _shareOutputWithPostProcess;
  28882. private _texelSize;
  28883. private _forcedOutputTexture;
  28884. /**
  28885. * An event triggered when the postprocess is activated.
  28886. * @type {BABYLON.Observable}
  28887. */
  28888. onActivateObservable: Observable<Camera>;
  28889. private _onActivateObserver;
  28890. /**
  28891. * A function that is added to the onActivateObservable
  28892. */
  28893. onActivate: Nullable<(camera: Camera) => void>;
  28894. /**
  28895. * An event triggered when the postprocess changes its size.
  28896. * @type {BABYLON.Observable}
  28897. */
  28898. onSizeChangedObservable: Observable<PostProcess>;
  28899. private _onSizeChangedObserver;
  28900. /**
  28901. * A function that is added to the onSizeChangedObservable
  28902. */
  28903. onSizeChanged: (postProcess: PostProcess) => void;
  28904. /**
  28905. * An event triggered when the postprocess applies its effect.
  28906. * @type {BABYLON.Observable}
  28907. */
  28908. onApplyObservable: Observable<Effect>;
  28909. private _onApplyObserver;
  28910. /**
  28911. * A function that is added to the onApplyObservable
  28912. */
  28913. onApply: (effect: Effect) => void;
  28914. /**
  28915. * An event triggered before rendering the postprocess
  28916. * @type {BABYLON.Observable}
  28917. */
  28918. onBeforeRenderObservable: Observable<Effect>;
  28919. private _onBeforeRenderObserver;
  28920. /**
  28921. * A function that is added to the onBeforeRenderObservable
  28922. */
  28923. onBeforeRender: (effect: Effect) => void;
  28924. /**
  28925. * An event triggered after rendering the postprocess
  28926. * @type {BABYLON.Observable}
  28927. */
  28928. onAfterRenderObservable: Observable<Effect>;
  28929. private _onAfterRenderObserver;
  28930. /**
  28931. * A function that is added to the onAfterRenderObservable
  28932. */
  28933. onAfterRender: (efect: Effect) => void;
  28934. /**
  28935. * 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
  28936. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28937. */
  28938. inputTexture: InternalTexture;
  28939. /**
  28940. * Gets the camera which post process is applied to.
  28941. * @returns The camera the post process is applied to.
  28942. */
  28943. getCamera(): Camera;
  28944. /**
  28945. * Gets the texel size of the postprocess.
  28946. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28947. */
  28948. readonly texelSize: Vector2;
  28949. /**
  28950. * Creates a new instance of @see PostProcess
  28951. * @param name The name of the PostProcess.
  28952. * @param fragmentUrl The url of the fragment shader to be used.
  28953. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28954. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28955. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28956. * @param camera The camera to apply the render pass to.
  28957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28958. * @param engine The engine which the post process will be applied. (default: current engine)
  28959. * @param reusable If the post process can be reused on the same frame. (default: false)
  28960. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28961. * @param textureType Type of textures used when performing the post process. (default: 0)
  28962. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28963. * @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
  28964. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28965. */
  28966. 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);
  28967. /**
  28968. * Gets the engine which this post process belongs to.
  28969. * @returns The engine the post process was enabled with.
  28970. */
  28971. getEngine(): Engine;
  28972. /**
  28973. * The effect that is created when initializing the post process.
  28974. * @returns The created effect corrisponding the the postprocess.
  28975. */
  28976. getEffect(): Effect;
  28977. /**
  28978. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28979. * @param postProcess The post process to share the output with.
  28980. * @returns This post process.
  28981. */
  28982. shareOutputWith(postProcess: PostProcess): PostProcess;
  28983. /**
  28984. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28985. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28986. */
  28987. useOwnOutput(): void;
  28988. /**
  28989. * Updates the effect with the current post process compile time values and recompiles the shader.
  28990. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28991. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28992. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28993. * @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
  28994. * @param onCompiled Called when the shader has been compiled.
  28995. * @param onError Called if there is an error when compiling a shader.
  28996. */
  28997. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28998. /**
  28999. * The post process is reusable if it can be used multiple times within one frame.
  29000. * @returns If the post process is reusable
  29001. */
  29002. isReusable(): boolean;
  29003. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  29004. markTextureDirty(): void;
  29005. /**
  29006. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  29007. * 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.
  29008. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  29009. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  29010. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  29011. * @returns The target texture that was bound to be written to.
  29012. */
  29013. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  29014. /**
  29015. * If the post process is supported.
  29016. */
  29017. readonly isSupported: boolean;
  29018. /**
  29019. * The aspect ratio of the output texture.
  29020. */
  29021. readonly aspectRatio: number;
  29022. /**
  29023. * Get a value indicating if the post-process is ready to be used
  29024. * @returns true if the post-process is ready (shader is compiled)
  29025. */
  29026. isReady(): boolean;
  29027. /**
  29028. * Binds all textures and uniforms to the shader, this will be run on every pass.
  29029. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  29030. */
  29031. apply(): Nullable<Effect>;
  29032. private _disposeTextures();
  29033. /**
  29034. * Disposes the post process.
  29035. * @param camera The camera to dispose the post process on.
  29036. */
  29037. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  29038. dispose(camera?: Camera): void;
  29039. }
  29040. }
  29041. declare module BABYLON {
  29042. /**
  29043. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29044. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29045. */
  29046. class PostProcessManager {
  29047. private _scene;
  29048. private _indexBuffer;
  29049. private _vertexBuffers;
  29050. /**
  29051. <<<<<<< HEAD
  29052. * Creates a new instance PostProcess
  29053. =======
  29054. * Creates a new instance of @see PostProcess
  29055. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  29056. * @param scene The scene that the post process is associated with.
  29057. */
  29058. constructor(scene: Scene);
  29059. private _prepareBuffers();
  29060. private _buildIndexBuffer();
  29061. /**
  29062. * Rebuilds the vertex buffers of the manager.
  29063. */
  29064. _rebuild(): void;
  29065. /**
  29066. * Prepares a frame to be run through a post process.
  29067. * @param sourceTexture The input texture to the post procesess. (default: null)
  29068. * @param postProcesses An array of post processes to be run. (default: null)
  29069. * @returns True if the post processes were able to be run.
  29070. */
  29071. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29072. /**
  29073. * Manually render a set of post processes to a texture.
  29074. * @param postProcesses An array of post processes to be run.
  29075. * @param targetTexture The target texture to render to.
  29076. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29077. */
  29078. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  29079. /**
  29080. * Finalize the result of the output of the postprocesses.
  29081. * @param doNotPresent If true the result will not be displayed to the screen.
  29082. * @param targetTexture The target texture to render to.
  29083. * @param faceIndex The index of the face to bind the target texture to.
  29084. * @param postProcesses The array of post processes to render.
  29085. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29086. */
  29087. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29088. /**
  29089. * Disposes of the post process manager.
  29090. */
  29091. dispose(): void;
  29092. }
  29093. }
  29094. declare module BABYLON {
  29095. class RefractionPostProcess extends PostProcess {
  29096. color: Color3;
  29097. depth: number;
  29098. colorLevel: number;
  29099. private _refTexture;
  29100. private _ownRefractionTexture;
  29101. /**
  29102. * Gets or sets the refraction texture
  29103. * Please note that you are responsible for disposing the texture if you set it manually
  29104. */
  29105. refractionTexture: Texture;
  29106. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  29107. dispose(camera: Camera): void;
  29108. }
  29109. }
  29110. declare module BABYLON {
  29111. /**
  29112. * The SharpenPostProcess applies a sharpen kernel to every pixel
  29113. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  29114. */
  29115. class SharpenPostProcess extends PostProcess {
  29116. <<<<<<< HEAD
  29117. /**
  29118. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  29119. */
  29120. colorAmount: number;
  29121. /**
  29122. * How much sharpness should be applied (default: 0.3)
  29123. */
  29124. edgeAmount: number;
  29125. /**
  29126. * Creates a new instance ConvolutionPostProcess
  29127. * @param name The name of the effect.
  29128. * @param options The required width/height ratio to downsize to before computing the render pass.
  29129. * @param camera The camera to apply the render pass to.
  29130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29131. * @param engine The engine which the post process will be applied. (default: current engine)
  29132. * @param reusable If the post process can be reused on the same frame. (default: false)
  29133. * @param textureType Type of textures used when performing the post process. (default: 0)
  29134. * @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)
  29135. */
  29136. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  29137. }
  29138. }
  29139. declare module BABYLON {
  29140. class StereoscopicInterlacePostProcess extends PostProcess {
  29141. private _stepSize;
  29142. private _passedProcess;
  29143. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  29144. }
  29145. }
  29146. declare module BABYLON {
  29147. enum TonemappingOperator {
  29148. Hable = 0,
  29149. Reinhard = 1,
  29150. HejiDawson = 2,
  29151. Photographic = 3,
  29152. }
  29153. class TonemapPostProcess extends PostProcess {
  29154. private _operator;
  29155. exposureAdjustment: number;
  29156. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  29157. }
  29158. }
  29159. declare module BABYLON {
  29160. class VolumetricLightScatteringPostProcess extends PostProcess {
  29161. private _volumetricLightScatteringPass;
  29162. private _volumetricLightScatteringRTT;
  29163. private _viewPort;
  29164. private _screenCoordinates;
  29165. private _cachedDefines;
  29166. /**
  29167. * If not undefined, the mesh position is computed from the attached node position
  29168. * @type {{position: Vector3}}
  29169. */
  29170. attachedNode: {
  29171. position: Vector3;
  29172. };
  29173. /**
  29174. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  29175. * @type {Vector3}
  29176. */
  29177. customMeshPosition: Vector3;
  29178. /**
  29179. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  29180. * @type {boolean}
  29181. */
  29182. useCustomMeshPosition: boolean;
  29183. /**
  29184. * If the post-process should inverse the light scattering direction
  29185. * @type {boolean}
  29186. */
  29187. invert: boolean;
  29188. /**
  29189. * The internal mesh used by the post-process
  29190. * @type {boolean}
  29191. */
  29192. mesh: Mesh;
  29193. useDiffuseColor: boolean;
  29194. /**
  29195. * Array containing the excluded meshes not rendered in the internal pass
  29196. */
  29197. excludedMeshes: AbstractMesh[];
  29198. /**
  29199. * Controls the overall intensity of the post-process
  29200. * @type {number}
  29201. */
  29202. exposure: number;
  29203. /**
  29204. * Dissipates each sample's contribution in range [0, 1]
  29205. * @type {number}
  29206. */
  29207. decay: number;
  29208. /**
  29209. * Controls the overall intensity of each sample
  29210. * @type {number}
  29211. */
  29212. weight: number;
  29213. /**
  29214. * Controls the density of each sample
  29215. * @type {number}
  29216. */
  29217. density: number;
  29218. /**
  29219. * @constructor
  29220. * @param {string} name - The post-process name
  29221. * @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)
  29222. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  29223. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  29224. * @param {number} samples - The post-process quality, default 100
  29225. * @param {number} samplingMode - The post-process filtering mode
  29226. * @param {BABYLON.Engine} engine - The babylon engine
  29227. * @param {boolean} reusable - If the post-process is reusable
  29228. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  29229. */
  29230. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  29231. getClassName(): string;
  29232. private _isReady(subMesh, useInstances);
  29233. /**
  29234. * Sets the new light position for light scattering effect
  29235. * @param {BABYLON.Vector3} The new custom light position
  29236. */
  29237. setCustomMeshPosition(position: Vector3): void;
  29238. /**
  29239. * Returns the light position for light scattering effect
  29240. * @return {BABYLON.Vector3} The custom light position
  29241. */
  29242. getCustomMeshPosition(): Vector3;
  29243. =======
  29244. /**
  29245. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  29246. */
  29247. colorAmount: number;
  29248. /**
  29249. * How much sharpness should be applied (default: 0.3)
  29250. */
  29251. edgeAmount: number;
  29252. /**
  29253. * Creates a new instance of @see ConvolutionPostProcess
  29254. * @param name The name of the effect.
  29255. * @param options The required width/height ratio to downsize to before computing the render pass.
  29256. * @param camera The camera to apply the render pass to.
  29257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29258. * @param engine The engine which the post process will be applied. (default: current engine)
  29259. * @param reusable If the post process can be reused on the same frame. (default: false)
  29260. * @param textureType Type of textures used when performing the post process. (default: 0)
  29261. * @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)
  29262. */
  29263. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  29264. }
  29265. }
  29266. declare module BABYLON {
  29267. class StereoscopicInterlacePostProcess extends PostProcess {
  29268. private _stepSize;
  29269. private _passedProcess;
  29270. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  29271. }
  29272. }
  29273. declare module BABYLON {
  29274. enum TonemappingOperator {
  29275. Hable = 0,
  29276. Reinhard = 1,
  29277. HejiDawson = 2,
  29278. Photographic = 3,
  29279. }
  29280. class TonemapPostProcess extends PostProcess {
  29281. private _operator;
  29282. exposureAdjustment: number;
  29283. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  29284. }
  29285. }
  29286. declare module BABYLON {
  29287. class VolumetricLightScatteringPostProcess extends PostProcess {
  29288. private _volumetricLightScatteringPass;
  29289. private _volumetricLightScatteringRTT;
  29290. private _viewPort;
  29291. private _screenCoordinates;
  29292. private _cachedDefines;
  29293. /**
  29294. * If not undefined, the mesh position is computed from the attached node position
  29295. * @type {{position: Vector3}}
  29296. */
  29297. attachedNode: {
  29298. position: Vector3;
  29299. };
  29300. /**
  29301. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  29302. * @type {Vector3}
  29303. */
  29304. customMeshPosition: Vector3;
  29305. /**
  29306. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  29307. * @type {boolean}
  29308. */
  29309. useCustomMeshPosition: boolean;
  29310. /**
  29311. * If the post-process should inverse the light scattering direction
  29312. * @type {boolean}
  29313. */
  29314. invert: boolean;
  29315. /**
  29316. * The internal mesh used by the post-process
  29317. * @type {boolean}
  29318. */
  29319. mesh: Mesh;
  29320. useDiffuseColor: boolean;
  29321. /**
  29322. * Array containing the excluded meshes not rendered in the internal pass
  29323. */
  29324. excludedMeshes: AbstractMesh[];
  29325. /**
  29326. * Controls the overall intensity of the post-process
  29327. * @type {number}
  29328. */
  29329. exposure: number;
  29330. /**
  29331. * Dissipates each sample's contribution in range [0, 1]
  29332. * @type {number}
  29333. */
  29334. decay: number;
  29335. /**
  29336. * Controls the overall intensity of each sample
  29337. * @type {number}
  29338. */
  29339. weight: number;
  29340. /**
  29341. * Controls the density of each sample
  29342. * @type {number}
  29343. */
  29344. density: number;
  29345. /**
  29346. * @constructor
  29347. * @param {string} name - The post-process name
  29348. * @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)
  29349. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  29350. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  29351. * @param {number} samples - The post-process quality, default 100
  29352. * @param {number} samplingMode - The post-process filtering mode
  29353. * @param {BABYLON.Engine} engine - The babylon engine
  29354. * @param {boolean} reusable - If the post-process is reusable
  29355. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  29356. */
  29357. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  29358. getClassName(): string;
  29359. private _isReady(subMesh, useInstances);
  29360. /**
  29361. * Sets the new light position for light scattering effect
  29362. * @param {BABYLON.Vector3} The new custom light position
  29363. */
  29364. setCustomMeshPosition(position: Vector3): void;
  29365. /**
  29366. * Returns the light position for light scattering effect
  29367. * @return {BABYLON.Vector3} The custom light position
  29368. */
  29369. getCustomMeshPosition(): Vector3;
  29370. /**
  29371. * Disposes the internal assets and detaches the post-process from the camera
  29372. */
  29373. dispose(camera: Camera): void;
  29374. /**
  29375. * Returns the render target texture used by the post-process
  29376. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  29377. */
  29378. getPass(): RenderTargetTexture;
  29379. private _meshExcluded(mesh);
  29380. private _createPass(scene, ratio);
  29381. private _updateMeshScreenCoordinates(scene);
  29382. /**
  29383. * Creates a default mesh for the Volumeric Light Scattering post-process
  29384. * @param {string} The mesh name
  29385. * @param {BABYLON.Scene} The scene where to create the mesh
  29386. * @return {BABYLON.Mesh} the default mesh
  29387. */
  29388. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  29389. }
  29390. }
  29391. declare module BABYLON {
  29392. class VRDistortionCorrectionPostProcess extends PostProcess {
  29393. private _isRightEye;
  29394. private _distortionFactors;
  29395. private _postProcessScaleFactor;
  29396. private _lensCenterOffset;
  29397. private _scaleIn;
  29398. private _scaleFactor;
  29399. private _lensCenter;
  29400. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  29401. }
  29402. }
  29403. declare module BABYLON {
  29404. class Sprite {
  29405. name: string;
  29406. position: Vector3;
  29407. color: Color4;
  29408. width: number;
  29409. height: number;
  29410. angle: number;
  29411. cellIndex: number;
  29412. invertU: number;
  29413. invertV: number;
  29414. disposeWhenFinishedAnimating: boolean;
  29415. animations: Animation[];
  29416. isPickable: boolean;
  29417. actionManager: ActionManager;
  29418. private _animationStarted;
  29419. private _loopAnimation;
  29420. private _fromIndex;
  29421. private _toIndex;
  29422. private _delay;
  29423. private _direction;
  29424. private _manager;
  29425. private _time;
  29426. private _onAnimationEnd;
  29427. size: number;
  29428. constructor(name: string, manager: SpriteManager);
  29429. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29430. stopAnimation(): void;
  29431. _animate(deltaTime: number): void;
  29432. dispose(): void;
  29433. }
  29434. }
  29435. declare module BABYLON {
  29436. class SpriteManager {
  29437. name: string;
  29438. sprites: Sprite[];
  29439. renderingGroupId: number;
  29440. layerMask: number;
  29441. fogEnabled: boolean;
  29442. isPickable: boolean;
  29443. cellWidth: number;
  29444. cellHeight: number;
  29445. /**
  29446. * An event triggered when the manager is disposed.
  29447. * @type {BABYLON.Observable}
  29448. */
  29449. onDisposeObservable: Observable<SpriteManager>;
  29450. private _onDisposeObserver;
  29451. onDispose: () => void;
  29452. private _capacity;
  29453. private _spriteTexture;
  29454. private _epsilon;
  29455. private _scene;
  29456. private _vertexData;
  29457. private _buffer;
  29458. private _vertexBuffers;
  29459. private _indexBuffer;
  29460. private _effectBase;
  29461. private _effectFog;
  29462. texture: Texture;
  29463. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29464. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  29465. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29466. render(): void;
  29467. dispose(): void;
  29468. }
  29469. }
  29470. declare module BABYLON {
  29471. class _AlphaState {
  29472. private _isAlphaBlendDirty;
  29473. private _isBlendFunctionParametersDirty;
  29474. private _isBlendEquationParametersDirty;
  29475. private _isBlendConstantsDirty;
  29476. private _alphaBlend;
  29477. private _blendFunctionParameters;
  29478. private _blendEquationParameters;
  29479. private _blendConstants;
  29480. /**
  29481. * Initializes the state.
  29482. */
  29483. constructor();
  29484. readonly isDirty: boolean;
  29485. alphaBlend: boolean;
  29486. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29487. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29488. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29489. reset(): void;
  29490. apply(gl: WebGLRenderingContext): void;
  29491. }
  29492. }
  29493. declare module BABYLON {
  29494. class _DepthCullingState {
  29495. private _isDepthTestDirty;
  29496. private _isDepthMaskDirty;
  29497. private _isDepthFuncDirty;
  29498. private _isCullFaceDirty;
  29499. private _isCullDirty;
  29500. private _isZOffsetDirty;
  29501. private _isFrontFaceDirty;
  29502. private _depthTest;
  29503. private _depthMask;
  29504. private _depthFunc;
  29505. private _cull;
  29506. private _cullFace;
  29507. private _zOffset;
  29508. private _frontFace;
  29509. /**
  29510. * Initializes the state.
  29511. */
  29512. constructor();
  29513. readonly isDirty: boolean;
  29514. zOffset: number;
  29515. cullFace: Nullable<number>;
  29516. cull: Nullable<boolean>;
  29517. depthFunc: Nullable<number>;
  29518. depthMask: boolean;
  29519. depthTest: boolean;
  29520. frontFace: Nullable<number>;
  29521. reset(): void;
  29522. apply(gl: WebGLRenderingContext): void;
  29523. }
  29524. }
  29525. declare module BABYLON {
  29526. class _StencilState {
  29527. private _isStencilTestDirty;
  29528. private _isStencilMaskDirty;
  29529. private _isStencilFuncDirty;
  29530. private _isStencilOpDirty;
  29531. private _stencilTest;
  29532. private _stencilMask;
  29533. private _stencilFunc;
  29534. private _stencilFuncRef;
  29535. private _stencilFuncMask;
  29536. private _stencilOpStencilFail;
  29537. private _stencilOpDepthFail;
  29538. private _stencilOpStencilDepthPass;
  29539. readonly isDirty: boolean;
  29540. stencilFunc: number;
  29541. stencilFuncRef: number;
  29542. stencilFuncMask: number;
  29543. stencilOpStencilFail: number;
  29544. stencilOpDepthFail: number;
  29545. stencilOpStencilDepthPass: number;
  29546. stencilMask: number;
  29547. stencilTest: boolean;
  29548. constructor();
  29549. reset(): void;
  29550. apply(gl: WebGLRenderingContext): void;
  29551. }
  29552. }
  29553. declare module BABYLON {
  29554. class AndOrNotEvaluator {
  29555. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29556. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  29557. private static _SimplifyNegation(booleanString);
  29558. }
  29559. }
  29560. declare module BABYLON {
  29561. /**
  29562. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29563. */
  29564. enum AssetTaskState {
  29565. /**
  29566. * Initialization
  29567. */
  29568. INIT = 0,
  29569. /**
  29570. * Running
  29571. */
  29572. RUNNING = 1,
  29573. /**
  29574. * Done
  29575. */
  29576. DONE = 2,
  29577. /**
  29578. * Error
  29579. */
  29580. ERROR = 3,
  29581. }
  29582. /**
  29583. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29584. */
  29585. abstract class AbstractAssetTask {
  29586. /**
  29587. * Task name
  29588. */ name: string;
  29589. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  29590. /**
  29591. * Disposes the internal assets and detaches the post-process from the camera
  29592. */
  29593. <<<<<<< HEAD
  29594. dispose(camera: Camera): void;
  29595. /**
  29596. * Returns the render target texture used by the post-process
  29597. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  29598. */
  29599. getPass(): RenderTargetTexture;
  29600. private _meshExcluded(mesh);
  29601. private _createPass(scene, ratio);
  29602. private _updateMeshScreenCoordinates(scene);
  29603. /**
  29604. * Creates a default mesh for the Volumeric Light Scattering post-process
  29605. * @param {string} The mesh name
  29606. * @param {BABYLON.Scene} The scene where to create the mesh
  29607. * @return {BABYLON.Mesh} the default mesh
  29608. */
  29609. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  29610. }
  29611. }
  29612. declare module BABYLON {
  29613. class VRDistortionCorrectionPostProcess extends PostProcess {
  29614. private _isRightEye;
  29615. private _distortionFactors;
  29616. private _postProcessScaleFactor;
  29617. private _lensCenterOffset;
  29618. private _scaleIn;
  29619. private _scaleFactor;
  29620. private _lensCenter;
  29621. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  29622. }
  29623. }
  29624. declare module BABYLON {
  29625. class ReflectionProbe {
  29626. name: string;
  29627. private _scene;
  29628. private _renderTargetTexture;
  29629. private _projectionMatrix;
  29630. private _viewMatrix;
  29631. private _target;
  29632. private _add;
  29633. private _attachedMesh;
  29634. private _invertYAxis;
  29635. position: Vector3;
  29636. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  29637. samples: number;
  29638. refreshRate: number;
  29639. getScene(): Scene;
  29640. readonly cubeTexture: RenderTargetTexture;
  29641. readonly renderList: Nullable<AbstractMesh[]>;
  29642. attachToMesh(mesh: AbstractMesh): void;
  29643. /**
  29644. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29645. *
  29646. * @param renderingGroupId The rendering group id corresponding to its index
  29647. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29648. */
  29649. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29650. dispose(): void;
  29651. }
  29652. }
  29653. declare module BABYLON {
  29654. class BoundingBoxRenderer {
  29655. frontColor: Color3;
  29656. backColor: Color3;
  29657. showBackLines: boolean;
  29658. renderList: SmartArray<BoundingBox>;
  29659. private _scene;
  29660. private _colorShader;
  29661. private _vertexBuffers;
  29662. private _indexBuffer;
  29663. constructor(scene: Scene);
  29664. private _prepareRessources();
  29665. private _createIndexBuffer();
  29666. _rebuild(): void;
  29667. reset(): void;
  29668. render(): void;
  29669. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  29670. dispose(): void;
  29671. }
  29672. }
  29673. declare module BABYLON {
  29674. /**
  29675. * This represents a depth renderer in Babylon.
  29676. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  29677. */
  29678. class DepthRenderer {
  29679. private _scene;
  29680. private _depthMap;
  29681. private _effect;
  29682. private _cachedDefines;
  29683. private _camera;
  29684. /**
  29685. * Instantiates a depth renderer
  29686. * @param scene The scene the renderer belongs to
  29687. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  29688. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  29689. */
  29690. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  29691. /**
  29692. * Creates the depth rendering effect and checks if the effect is ready.
  29693. * @param subMesh The submesh to be used to render the depth map of
  29694. * @param useInstances If multiple world instances should be used
  29695. * @returns if the depth renderer is ready to render the depth map
  29696. */
  29697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29698. /**
  29699. * Gets the texture which the depth map will be written to.
  29700. * @returns The depth map texture
  29701. */
  29702. getDepthMap(): RenderTargetTexture;
  29703. =======
  29704. onSuccess: (task: any) => void;
  29705. /**
  29706. * Callback called when the task is not successful
  29707. */
  29708. onError: (task: any, message?: string, exception?: any) => void;
  29709. /**
  29710. * Creates a new {BABYLON.AssetsManager}
  29711. * @param name defines the name of the task
  29712. */
  29713. constructor(
  29714. /**
  29715. * Task name
  29716. */ name: string);
  29717. private _isCompleted;
  29718. private _taskState;
  29719. private _errorObject;
  29720. /**
  29721. * Get if the task is completed
  29722. */
  29723. readonly isCompleted: boolean;
  29724. /**
  29725. * Gets the current state of the task
  29726. */
  29727. readonly taskState: AssetTaskState;
  29728. /**
  29729. * Gets the current error object (if task is in error)
  29730. */
  29731. readonly errorObject: {
  29732. message?: string;
  29733. exception?: any;
  29734. };
  29735. /**
  29736. * Internal only
  29737. * @ignore
  29738. */
  29739. _setErrorObject(message?: string, exception?: any): void;
  29740. /**
  29741. * Execute the current task
  29742. * @param scene defines the scene where you want your assets to be loaded
  29743. * @param onSuccess is a callback called when the task is successfully executed
  29744. * @param onError is a callback called if an error occurs
  29745. */
  29746. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29747. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  29748. /**
  29749. * Disposes of the depth renderer.
  29750. */
  29751. <<<<<<< HEAD
  29752. dispose(): void;
  29753. }
  29754. }
  29755. declare module BABYLON {
  29756. class EdgesRenderer {
  29757. edgesWidthScalerForOrthographic: number;
  29758. edgesWidthScalerForPerspective: number;
  29759. private _source;
  29760. private _linesPositions;
  29761. private _linesNormals;
  29762. private _linesIndices;
  29763. private _epsilon;
  29764. private _indicesCount;
  29765. private _lineShader;
  29766. private _ib;
  29767. private _buffers;
  29768. private _checkVerticesInsteadOfIndices;
  29769. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29770. private _prepareRessources();
  29771. _rebuild(): void;
  29772. dispose(): void;
  29773. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  29774. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  29775. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  29776. _generateEdgesLines(): void;
  29777. render(): void;
  29778. =======
  29779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29780. private onErrorCallback(onError, message?, exception?);
  29781. private onDoneCallback(onSuccess, onError);
  29782. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  29783. }
  29784. }
  29785. declare module BABYLON {
  29786. /**
  29787. <<<<<<< HEAD
  29788. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  29789. */
  29790. class GeometryBufferRenderer {
  29791. private _scene;
  29792. private _multiRenderTarget;
  29793. private _ratio;
  29794. private _enablePosition;
  29795. protected _effect: Effect;
  29796. protected _cachedDefines: string;
  29797. /**
  29798. * Set the render list (meshes to be rendered) used in the G buffer.
  29799. */
  29800. renderList: Mesh[];
  29801. /**
  29802. * Gets wether or not G buffer are supported by the running hardware.
  29803. * This requires draw buffer supports
  29804. */
  29805. readonly isSupported: boolean;
  29806. /**
  29807. * Gets wether or not position are enabled for the G buffer.
  29808. */
  29809. /**
  29810. * Sets wether or not position are enabled for the G buffer.
  29811. */
  29812. enablePosition: boolean;
  29813. /**
  29814. * Gets the scene associated with the buffer.
  29815. */
  29816. readonly scene: Scene;
  29817. /**
  29818. * Gets the ratio used by the buffer during its creation.
  29819. * How big is the buffer related to the main canvas.
  29820. */
  29821. readonly ratio: number;
  29822. /**
  29823. * Creates a new G Buffer for the scene
  29824. * @param scene The scene the buffer belongs to
  29825. * @param ratio How big is the buffer related to the main canvas.
  29826. */
  29827. constructor(scene: Scene, ratio?: number);
  29828. /**
  29829. * Checks wether everything is ready to render a submesh to the G buffer.
  29830. * @param subMesh the submesh to check readiness for
  29831. * @param useInstances is the mesh drawn using instance or not
  29832. * @returns true if ready otherwise false
  29833. */
  29834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29835. /**
  29836. * Gets the current underlying G Buffer.
  29837. * @returns the buffer
  29838. */
  29839. getGBuffer(): MultiRenderTarget;
  29840. /**
  29841. * Gets the number of samples used to render the buffer (anti aliasing).
  29842. */
  29843. /**
  29844. * Sets the number of samples used to render the buffer (anti aliasing).
  29845. */
  29846. samples: number;
  29847. /**
  29848. * Disposes the renderer and frees up associated resources.
  29849. */
  29850. dispose(): void;
  29851. protected _createRenderTargets(): void;
  29852. }
  29853. }
  29854. declare module BABYLON {
  29855. class OutlineRenderer {
  29856. private _scene;
  29857. private _effect;
  29858. private _cachedDefines;
  29859. zOffset: number;
  29860. constructor(scene: Scene);
  29861. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  29862. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29863. }
  29864. }
  29865. declare module BABYLON {
  29866. class RenderingGroup {
  29867. index: number;
  29868. private _scene;
  29869. private _opaqueSubMeshes;
  29870. private _transparentSubMeshes;
  29871. private _alphaTestSubMeshes;
  29872. private _depthOnlySubMeshes;
  29873. private _particleSystems;
  29874. private _spriteManagers;
  29875. private _opaqueSortCompareFn;
  29876. private _alphaTestSortCompareFn;
  29877. private _transparentSortCompareFn;
  29878. private _renderOpaque;
  29879. private _renderAlphaTest;
  29880. private _renderTransparent;
  29881. private _edgesRenderers;
  29882. onBeforeTransparentRendering: () => void;
  29883. /**
  29884. * Set the opaque sort comparison function.
  29885. * If null the sub meshes will be render in the order they were created
  29886. */
  29887. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29888. /**
  29889. * Set the alpha test sort comparison function.
  29890. * If null the sub meshes will be render in the order they were created
  29891. */
  29892. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29893. /**
  29894. * Set the transparent sort comparison function.
  29895. * If null the sub meshes will be render in the order they were created
  29896. */
  29897. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29898. /**
  29899. * Creates a new rendering group.
  29900. * @param index The rendering group index
  29901. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29902. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29903. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29904. */
  29905. 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>);
  29906. /**
  29907. * Render all the sub meshes contained in the group.
  29908. * @param customRenderFunction Used to override the default render behaviour of the group.
  29909. * @returns true if rendered some submeshes.
  29910. */
  29911. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29912. /**
  29913. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29914. * @param subMeshes The submeshes to render
  29915. */
  29916. private renderOpaqueSorted(subMeshes);
  29917. /**
  29918. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29919. * @param subMeshes The submeshes to render
  29920. */
  29921. private renderAlphaTestSorted(subMeshes);
  29922. /**
  29923. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29924. * @param subMeshes The submeshes to render
  29925. */
  29926. private renderTransparentSorted(subMeshes);
  29927. /**
  29928. * Renders the submeshes in a specified order.
  29929. * @param subMeshes The submeshes to sort before render
  29930. * @param sortCompareFn The comparison function use to sort
  29931. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29932. * @param transparent Specifies to activate blending if true
  29933. */
  29934. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  29935. /**
  29936. * Renders the submeshes in the order they were dispatched (no sort applied).
  29937. * @param subMeshes The submeshes to render
  29938. */
  29939. private static renderUnsorted(subMeshes);
  29940. /**
  29941. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29942. * are rendered back to front if in the same alpha index.
  29943. *
  29944. * @param a The first submesh
  29945. * @param b The second submesh
  29946. * @returns The result of the comparison
  29947. */
  29948. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29949. /**
  29950. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29951. * are rendered back to front.
  29952. *
  29953. * @param a The first submesh
  29954. * @param b The second submesh
  29955. * @returns The result of the comparison
  29956. */
  29957. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29958. /**
  29959. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29960. * are rendered front to back (prevent overdraw).
  29961. *
  29962. * @param a The first submesh
  29963. * @param b The second submesh
  29964. * @returns The result of the comparison
  29965. */
  29966. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29967. /**
  29968. * Resets the different lists of submeshes to prepare a new frame.
  29969. */
  29970. prepare(): void;
  29971. dispose(): void;
  29972. /**
  29973. * Inserts the submesh in its correct queue depending on its material.
  29974. * @param subMesh The submesh to dispatch
  29975. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29976. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29977. */
  29978. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29979. dispatchSprites(spriteManager: SpriteManager): void;
  29980. dispatchParticles(particleSystem: IParticleSystem): void;
  29981. private _renderParticles(activeMeshes);
  29982. private _renderSprites();
  29983. }
  29984. }
  29985. declare module BABYLON {
  29986. class RenderingManager {
  29987. /**
  29988. * The max id used for rendering groups (not included)
  29989. */
  29990. static MAX_RENDERINGGROUPS: number;
  29991. /**
  29992. * The min id used for rendering groups (included)
  29993. */
  29994. static MIN_RENDERINGGROUPS: number;
  29995. /**
  29996. * Used to globally prevent autoclearing scenes.
  29997. */
  29998. static AUTOCLEAR: boolean;
  29999. private _scene;
  30000. private _renderingGroups;
  30001. private _depthStencilBufferAlreadyCleaned;
  30002. private _autoClearDepthStencil;
  30003. private _customOpaqueSortCompareFn;
  30004. private _customAlphaTestSortCompareFn;
  30005. private _customTransparentSortCompareFn;
  30006. private _renderinGroupInfo;
  30007. constructor(scene: Scene);
  30008. private _clearDepthStencilBuffer(depth?, stencil?);
  30009. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  30010. reset(): void;
  30011. dispose(): void;
  30012. /**
  30013. * Clear the info related to rendering groups preventing retention points during dispose.
  30014. */
  30015. freeRenderingGroups(): void;
  30016. private _prepareRenderingGroup(renderingGroupId);
  30017. dispatchSprites(spriteManager: SpriteManager): void;
  30018. dispatchParticles(particleSystem: IParticleSystem): void;
  30019. /**
  30020. * @param subMesh The submesh to dispatch
  30021. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30022. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30023. */
  30024. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30025. /**
  30026. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30027. * This allowed control for front to back rendering or reversly depending of the special needs.
  30028. *
  30029. * @param renderingGroupId The rendering group id corresponding to its index
  30030. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30031. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30032. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30033. */
  30034. 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;
  30035. /**
  30036. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30037. *
  30038. * @param renderingGroupId The rendering group id corresponding to its index
  30039. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30040. * @param depth Automatically clears depth between groups if true and autoClear is true.
  30041. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  30042. */
  30043. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  30044. }
  30045. }
  30046. declare module BABYLON {
  30047. class _AlphaState {
  30048. private _isAlphaBlendDirty;
  30049. private _isBlendFunctionParametersDirty;
  30050. private _isBlendEquationParametersDirty;
  30051. private _isBlendConstantsDirty;
  30052. private _alphaBlend;
  30053. private _blendFunctionParameters;
  30054. private _blendEquationParameters;
  30055. private _blendConstants;
  30056. /**
  30057. * Initializes the state.
  30058. */
  30059. constructor();
  30060. readonly isDirty: boolean;
  30061. alphaBlend: boolean;
  30062. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30063. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30064. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30065. reset(): void;
  30066. apply(gl: WebGLRenderingContext): void;
  30067. }
  30068. }
  30069. declare module BABYLON {
  30070. class _DepthCullingState {
  30071. private _isDepthTestDirty;
  30072. private _isDepthMaskDirty;
  30073. private _isDepthFuncDirty;
  30074. private _isCullFaceDirty;
  30075. private _isCullDirty;
  30076. private _isZOffsetDirty;
  30077. private _isFrontFaceDirty;
  30078. private _depthTest;
  30079. private _depthMask;
  30080. private _depthFunc;
  30081. private _cull;
  30082. private _cullFace;
  30083. private _zOffset;
  30084. private _frontFace;
  30085. /**
  30086. * Initializes the state.
  30087. */
  30088. constructor();
  30089. readonly isDirty: boolean;
  30090. zOffset: number;
  30091. cullFace: Nullable<number>;
  30092. cull: Nullable<boolean>;
  30093. depthFunc: Nullable<number>;
  30094. depthMask: boolean;
  30095. depthTest: boolean;
  30096. frontFace: Nullable<number>;
  30097. reset(): void;
  30098. apply(gl: WebGLRenderingContext): void;
  30099. }
  30100. }
  30101. declare module BABYLON {
  30102. class _StencilState {
  30103. private _isStencilTestDirty;
  30104. private _isStencilMaskDirty;
  30105. private _isStencilFuncDirty;
  30106. private _isStencilOpDirty;
  30107. private _stencilTest;
  30108. private _stencilMask;
  30109. private _stencilFunc;
  30110. private _stencilFuncRef;
  30111. private _stencilFuncMask;
  30112. private _stencilOpStencilFail;
  30113. private _stencilOpDepthFail;
  30114. private _stencilOpStencilDepthPass;
  30115. readonly isDirty: boolean;
  30116. stencilFunc: number;
  30117. stencilFuncRef: number;
  30118. stencilFuncMask: number;
  30119. stencilOpStencilFail: number;
  30120. stencilOpDepthFail: number;
  30121. stencilOpStencilDepthPass: number;
  30122. stencilMask: number;
  30123. stencilTest: boolean;
  30124. constructor();
  30125. reset(): void;
  30126. apply(gl: WebGLRenderingContext): void;
  30127. }
  30128. }
  30129. declare module BABYLON {
  30130. class Sprite {
  30131. name: string;
  30132. position: Vector3;
  30133. color: Color4;
  30134. width: number;
  30135. height: number;
  30136. angle: number;
  30137. cellIndex: number;
  30138. invertU: number;
  30139. invertV: number;
  30140. disposeWhenFinishedAnimating: boolean;
  30141. animations: Animation[];
  30142. isPickable: boolean;
  30143. actionManager: ActionManager;
  30144. private _animationStarted;
  30145. private _loopAnimation;
  30146. private _fromIndex;
  30147. private _toIndex;
  30148. private _delay;
  30149. private _direction;
  30150. private _manager;
  30151. private _time;
  30152. private _onAnimationEnd;
  30153. size: number;
  30154. constructor(name: string, manager: SpriteManager);
  30155. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  30156. stopAnimation(): void;
  30157. _animate(deltaTime: number): void;
  30158. dispose(): void;
  30159. }
  30160. }
  30161. declare module BABYLON {
  30162. class SpriteManager {
  30163. name: string;
  30164. sprites: Sprite[];
  30165. renderingGroupId: number;
  30166. layerMask: number;
  30167. fogEnabled: boolean;
  30168. isPickable: boolean;
  30169. cellWidth: number;
  30170. cellHeight: number;
  30171. /**
  30172. * An event triggered when the manager is disposed.
  30173. * @type {BABYLON.Observable}
  30174. */
  30175. onDisposeObservable: Observable<SpriteManager>;
  30176. private _onDisposeObserver;
  30177. onDispose: () => void;
  30178. private _capacity;
  30179. private _spriteTexture;
  30180. private _epsilon;
  30181. private _scene;
  30182. private _vertexData;
  30183. private _buffer;
  30184. private _vertexBuffers;
  30185. private _indexBuffer;
  30186. private _effectBase;
  30187. private _effectFog;
  30188. texture: Texture;
  30189. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  30190. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  30191. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  30192. render(): void;
  30193. dispose(): void;
  30194. }
  30195. }
  30196. declare module BABYLON {
  30197. class AndOrNotEvaluator {
  30198. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  30199. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  30200. private static _SimplifyNegation(booleanString);
  30201. =======
  30202. * Define the interface used by progress events raised during assets loading
  30203. */
  30204. interface IAssetsProgressEvent {
  30205. /**
  30206. * Defines the number of remaining tasks to process
  30207. */
  30208. remainingCount: number;
  30209. /**
  30210. * Defines the total number of tasks
  30211. */
  30212. totalCount: number;
  30213. /**
  30214. * Defines the task that was just processed
  30215. */
  30216. task: AbstractAssetTask;
  30217. }
  30218. /**
  30219. * Class used to share progress information about assets loading
  30220. */
  30221. class AssetsProgressEvent implements IAssetsProgressEvent {
  30222. /**
  30223. * Defines the number of remaining tasks to process
  30224. */
  30225. remainingCount: number;
  30226. /**
  30227. * Defines the total number of tasks
  30228. */
  30229. totalCount: number;
  30230. /**
  30231. * Defines the task that was just processed
  30232. */
  30233. task: AbstractAssetTask;
  30234. /**
  30235. * Creates a {BABYLON.AssetsProgressEvent}
  30236. * @param remainingCount defines the number of remaining tasks to process
  30237. * @param totalCount defines the total number of tasks
  30238. * @param task defines the task that was just processed
  30239. */
  30240. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  30241. }
  30242. /**
  30243. * Define a task used by {BABYLON.AssetsManager} to load meshes
  30244. */
  30245. class MeshAssetTask extends AbstractAssetTask {
  30246. /**
  30247. * Defines the name of the task
  30248. */
  30249. name: string;
  30250. /**
  30251. * Defines the list of mesh's names you want to load
  30252. */
  30253. meshesNames: any;
  30254. /**
  30255. * Defines the root url to use as a base to load your meshes and associated resources
  30256. */
  30257. rootUrl: string;
  30258. /**
  30259. * Defines the filename of the scene to load from
  30260. */
  30261. sceneFilename: string;
  30262. /**
  30263. * Gets the list of loaded meshes
  30264. */
  30265. loadedMeshes: Array<AbstractMesh>;
  30266. /**
  30267. * Gets the list of loaded particle systems
  30268. */
  30269. loadedParticleSystems: Array<ParticleSystem>;
  30270. /**
  30271. * Gets the list of loaded skeletons
  30272. */
  30273. loadedSkeletons: Array<Skeleton>;
  30274. /**
  30275. * Callback called when the task is successful
  30276. */
  30277. onSuccess: (task: MeshAssetTask) => void;
  30278. /**
  30279. * Callback called when the task is successful
  30280. */
  30281. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  30282. /**
  30283. * Creates a new {BABYLON.MeshAssetTask}
  30284. * @param name defines the name of the task
  30285. * @param meshesNames defines the list of mesh's names you want to load
  30286. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  30287. * @param sceneFilename defines the filename of the scene to load from
  30288. */
  30289. constructor(
  30290. /**
  30291. * Defines the name of the task
  30292. */
  30293. name: string,
  30294. /**
  30295. * Defines the list of mesh's names you want to load
  30296. */
  30297. meshesNames: any,
  30298. /**
  30299. * Defines the root url to use as a base to load your meshes and associated resources
  30300. */
  30301. rootUrl: string,
  30302. /**
  30303. * Defines the filename of the scene to load from
  30304. */
  30305. sceneFilename: string);
  30306. /**
  30307. * Execute the current task
  30308. * @param scene defines the scene where you want your assets to be loaded
  30309. * @param onSuccess is a callback called when the task is successfully executed
  30310. * @param onError is a callback called if an error occurs
  30311. */
  30312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30313. }
  30314. /**
  30315. * Define a task used by {BABYLON.AssetsManager} to load text content
  30316. */
  30317. class TextFileAssetTask extends AbstractAssetTask {
  30318. /**
  30319. * Defines the name of the task
  30320. */
  30321. name: string;
  30322. /**
  30323. * Defines the location of the file to load
  30324. */
  30325. url: string;
  30326. /**
  30327. * Gets the loaded text string
  30328. */
  30329. text: string;
  30330. /**
  30331. * Callback called when the task is successful
  30332. */
  30333. onSuccess: (task: TextFileAssetTask) => void;
  30334. /**
  30335. * Callback called when the task is successful
  30336. */
  30337. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  30338. /**
  30339. * Creates a new TextFileAssetTask object
  30340. * @param name defines the name of the task
  30341. * @param url defines the location of the file to load
  30342. */
  30343. constructor(
  30344. /**
  30345. * Defines the name of the task
  30346. */
  30347. name: string,
  30348. /**
  30349. * Defines the location of the file to load
  30350. */
  30351. url: string);
  30352. /**
  30353. * Execute the current task
  30354. * @param scene defines the scene where you want your assets to be loaded
  30355. * @param onSuccess is a callback called when the task is successfully executed
  30356. * @param onError is a callback called if an error occurs
  30357. */
  30358. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30359. }
  30360. /**
  30361. * Define a task used by {BABYLON.AssetsManager} to load binary data
  30362. */
  30363. class BinaryFileAssetTask extends AbstractAssetTask {
  30364. /**
  30365. * Defines the name of the task
  30366. */
  30367. name: string;
  30368. /**
  30369. * Defines the location of the file to load
  30370. */
  30371. url: string;
  30372. /**
  30373. * Gets the lodaded data (as an array buffer)
  30374. */
  30375. data: ArrayBuffer;
  30376. /**
  30377. * Callback called when the task is successful
  30378. */
  30379. onSuccess: (task: BinaryFileAssetTask) => void;
  30380. /**
  30381. * Callback called when the task is successful
  30382. */
  30383. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  30384. /**
  30385. * Creates a new BinaryFileAssetTask object
  30386. * @param name defines the name of the new task
  30387. * @param url defines the location of the file to load
  30388. */
  30389. constructor(
  30390. /**
  30391. * Defines the name of the task
  30392. */
  30393. name: string,
  30394. /**
  30395. * Defines the location of the file to load
  30396. */
  30397. url: string);
  30398. /**
  30399. * Execute the current task
  30400. * @param scene defines the scene where you want your assets to be loaded
  30401. * @param onSuccess is a callback called when the task is successfully executed
  30402. * @param onError is a callback called if an error occurs
  30403. */
  30404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30405. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  30406. }
  30407. /**
  30408. <<<<<<< HEAD
  30409. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  30410. */
  30411. enum AssetTaskState {
  30412. /**
  30413. * Initialization
  30414. */
  30415. INIT = 0,
  30416. /**
  30417. * Running
  30418. */
  30419. RUNNING = 1,
  30420. /**
  30421. * Done
  30422. */
  30423. DONE = 2,
  30424. /**
  30425. * Error
  30426. */
  30427. ERROR = 3,
  30428. }
  30429. /**
  30430. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  30431. */
  30432. abstract class AbstractAssetTask {
  30433. /**
  30434. * Task name
  30435. */ name: string;
  30436. /**
  30437. * Callback called when the task is successful
  30438. */
  30439. onSuccess: (task: any) => void;
  30440. /**
  30441. * Callback called when the task is not successful
  30442. */
  30443. onError: (task: any, message?: string, exception?: any) => void;
  30444. /**
  30445. * Creates a new {BABYLON.AssetsManager}
  30446. * @param name defines the name of the task
  30447. */
  30448. constructor(
  30449. /**
  30450. * Task name
  30451. */ name: string);
  30452. private _isCompleted;
  30453. private _taskState;
  30454. private _errorObject;
  30455. /**
  30456. * Get if the task is completed
  30457. */
  30458. readonly isCompleted: boolean;
  30459. /**
  30460. * Gets the current state of the task
  30461. */
  30462. readonly taskState: AssetTaskState;
  30463. /**
  30464. * Gets the current error object (if task is in error)
  30465. */
  30466. readonly errorObject: {
  30467. message?: string;
  30468. exception?: any;
  30469. };
  30470. /**
  30471. * Internal only
  30472. * @ignore
  30473. */
  30474. _setErrorObject(message?: string, exception?: any): void;
  30475. /**
  30476. * Execute the current task
  30477. * @param scene defines the scene where you want your assets to be loaded
  30478. * @param onSuccess is a callback called when the task is successfully executed
  30479. * @param onError is a callback called if an error occurs
  30480. */
  30481. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30482. /**
  30483. * Execute the current task
  30484. * @param scene defines the scene where you want your assets to be loaded
  30485. * @param onSuccess is a callback called when the task is successfully executed
  30486. * @param onError is a callback called if an error occurs
  30487. */
  30488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30489. private onErrorCallback(onError, message?, exception?);
  30490. private onDoneCallback(onSuccess, onError);
  30491. }
  30492. /**
  30493. * Define the interface used by progress events raised during assets loading
  30494. */
  30495. interface IAssetsProgressEvent {
  30496. /**
  30497. * Defines the number of remaining tasks to process
  30498. */
  30499. remainingCount: number;
  30500. /**
  30501. * Defines the total number of tasks
  30502. */
  30503. totalCount: number;
  30504. /**
  30505. * Defines the task that was just processed
  30506. */
  30507. task: AbstractAssetTask;
  30508. }
  30509. /**
  30510. * Class used to share progress information about assets loading
  30511. */
  30512. class AssetsProgressEvent implements IAssetsProgressEvent {
  30513. /**
  30514. * Defines the number of remaining tasks to process
  30515. */
  30516. remainingCount: number;
  30517. /**
  30518. * Defines the total number of tasks
  30519. */
  30520. totalCount: number;
  30521. /**
  30522. * Defines the task that was just processed
  30523. */
  30524. task: AbstractAssetTask;
  30525. /**
  30526. * Creates a {BABYLON.AssetsProgressEvent}
  30527. * @param remainingCount defines the number of remaining tasks to process
  30528. * @param totalCount defines the total number of tasks
  30529. * @param task defines the task that was just processed
  30530. */
  30531. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  30532. }
  30533. /**
  30534. * Define a task used by {BABYLON.AssetsManager} to load meshes
  30535. */
  30536. class MeshAssetTask extends AbstractAssetTask {
  30537. /**
  30538. * Defines the name of the task
  30539. */
  30540. name: string;
  30541. /**
  30542. * Defines the list of mesh's names you want to load
  30543. */
  30544. meshesNames: any;
  30545. /**
  30546. * Defines the root url to use as a base to load your meshes and associated resources
  30547. */
  30548. rootUrl: string;
  30549. /**
  30550. * Defines the filename of the scene to load from
  30551. */
  30552. sceneFilename: string;
  30553. /**
  30554. * Gets the list of loaded meshes
  30555. */
  30556. loadedMeshes: Array<AbstractMesh>;
  30557. /**
  30558. * Gets the list of loaded particle systems
  30559. */
  30560. loadedParticleSystems: Array<ParticleSystem>;
  30561. /**
  30562. * Gets the list of loaded skeletons
  30563. */
  30564. loadedSkeletons: Array<Skeleton>;
  30565. /**
  30566. * Callback called when the task is successful
  30567. */
  30568. onSuccess: (task: MeshAssetTask) => void;
  30569. /**
  30570. * Callback called when the task is successful
  30571. */
  30572. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  30573. /**
  30574. * Creates a new {BABYLON.MeshAssetTask}
  30575. * @param name defines the name of the task
  30576. * @param meshesNames defines the list of mesh's names you want to load
  30577. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  30578. * @param sceneFilename defines the filename of the scene to load from
  30579. */
  30580. constructor(
  30581. /**
  30582. * Defines the name of the task
  30583. */
  30584. name: string,
  30585. /**
  30586. * Defines the list of mesh's names you want to load
  30587. */
  30588. meshesNames: any,
  30589. /**
  30590. * Defines the root url to use as a base to load your meshes and associated resources
  30591. */
  30592. rootUrl: string,
  30593. /**
  30594. * Defines the filename of the scene to load from
  30595. */
  30596. sceneFilename: string);
  30597. /**
  30598. * Execute the current task
  30599. * @param scene defines the scene where you want your assets to be loaded
  30600. * @param onSuccess is a callback called when the task is successfully executed
  30601. * @param onError is a callback called if an error occurs
  30602. */
  30603. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30604. }
  30605. /**
  30606. * Define a task used by {BABYLON.AssetsManager} to load text content
  30607. */
  30608. class TextFileAssetTask extends AbstractAssetTask {
  30609. /**
  30610. * Defines the name of the task
  30611. */
  30612. name: string;
  30613. /**
  30614. * Defines the location of the file to load
  30615. */
  30616. url: string;
  30617. /**
  30618. * Gets the loaded text string
  30619. */
  30620. text: string;
  30621. /**
  30622. * Callback called when the task is successful
  30623. */
  30624. onSuccess: (task: TextFileAssetTask) => void;
  30625. /**
  30626. * Callback called when the task is successful
  30627. */
  30628. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  30629. /**
  30630. * Creates a new TextFileAssetTask object
  30631. * @param name defines the name of the task
  30632. * @param url defines the location of the file to load
  30633. */
  30634. constructor(
  30635. /**
  30636. * Defines the name of the task
  30637. */
  30638. name: string,
  30639. /**
  30640. * Defines the location of the file to load
  30641. */
  30642. url: string);
  30643. /**
  30644. * Execute the current task
  30645. * @param scene defines the scene where you want your assets to be loaded
  30646. * @param onSuccess is a callback called when the task is successfully executed
  30647. * @param onError is a callback called if an error occurs
  30648. */
  30649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30650. =======
  30651. * Define a task used by {BABYLON.AssetsManager} to load images
  30652. */
  30653. class ImageAssetTask extends AbstractAssetTask {
  30654. /**
  30655. * Defines the name of the task
  30656. */
  30657. name: string;
  30658. /**
  30659. * Defines the location of the image to load
  30660. */
  30661. url: string;
  30662. /**
  30663. * Gets the loaded images
  30664. */
  30665. image: HTMLImageElement;
  30666. /**
  30667. * Callback called when the task is successful
  30668. */
  30669. onSuccess: (task: ImageAssetTask) => void;
  30670. /**
  30671. * Callback called when the task is successful
  30672. */
  30673. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  30674. /**
  30675. * Creates a new ImageAssetTask
  30676. * @param name defines the name of the task
  30677. * @param url defines the location of the image to load
  30678. */
  30679. constructor(
  30680. /**
  30681. * Defines the name of the task
  30682. */
  30683. name: string,
  30684. /**
  30685. * Defines the location of the image to load
  30686. */
  30687. url: string);
  30688. /**
  30689. * Execute the current task
  30690. * @param scene defines the scene where you want your assets to be loaded
  30691. * @param onSuccess is a callback called when the task is successfully executed
  30692. * @param onError is a callback called if an error occurs
  30693. */
  30694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30695. }
  30696. /**
  30697. * Defines the interface used by texture loading tasks
  30698. */
  30699. interface ITextureAssetTask<TEX extends BaseTexture> {
  30700. /**
  30701. * Gets the loaded texture
  30702. */
  30703. texture: TEX;
  30704. }
  30705. /**
  30706. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  30707. */
  30708. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  30709. /**
  30710. * Defines the name of the task
  30711. */
  30712. name: string;
  30713. /**
  30714. * Defines the location of the file to load
  30715. */
  30716. url: string;
  30717. /**
  30718. * Defines if mipmap should not be generated (default is false)
  30719. */
  30720. noMipmap: boolean | undefined;
  30721. /**
  30722. * Defines if texture must be inverted on Y axis (default is false)
  30723. */
  30724. invertY: boolean | undefined;
  30725. /**
  30726. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30727. */
  30728. samplingMode: number;
  30729. /**
  30730. * Gets the loaded texture
  30731. */
  30732. texture: Texture;
  30733. /**
  30734. * Callback called when the task is successful
  30735. */
  30736. onSuccess: (task: TextureAssetTask) => void;
  30737. /**
  30738. * Callback called when the task is successful
  30739. */
  30740. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  30741. /**
  30742. * Creates a new TextureAssetTask object
  30743. * @param name defines the name of the task
  30744. * @param url defines the location of the file to load
  30745. * @param noMipmap defines if mipmap should not be generated (default is false)
  30746. * @param invertY defines if texture must be inverted on Y axis (default is false)
  30747. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30748. */
  30749. constructor(
  30750. /**
  30751. * Defines the name of the task
  30752. */
  30753. name: string,
  30754. /**
  30755. * Defines the location of the file to load
  30756. */
  30757. url: string,
  30758. /**
  30759. * Defines if mipmap should not be generated (default is false)
  30760. */
  30761. noMipmap?: boolean | undefined,
  30762. /**
  30763. * Defines if texture must be inverted on Y axis (default is false)
  30764. */
  30765. invertY?: boolean | undefined,
  30766. /**
  30767. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30768. */
  30769. samplingMode?: number);
  30770. /**
  30771. * Execute the current task
  30772. * @param scene defines the scene where you want your assets to be loaded
  30773. * @param onSuccess is a callback called when the task is successfully executed
  30774. * @param onError is a callback called if an error occurs
  30775. */
  30776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30777. }
  30778. /**
  30779. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  30780. */
  30781. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  30782. /**
  30783. * Defines the name of the task
  30784. */
  30785. name: string;
  30786. /**
  30787. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30788. */
  30789. url: string;
  30790. /**
  30791. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30792. */
  30793. extensions: string[] | undefined;
  30794. /**
  30795. * Defines if mipmaps should not be generated (default is false)
  30796. */
  30797. noMipmap: boolean | undefined;
  30798. /**
  30799. * Defines the explicit list of files (undefined by default)
  30800. */
  30801. files: string[] | undefined;
  30802. /**
  30803. * Gets the loaded texture
  30804. */
  30805. texture: CubeTexture;
  30806. /**
  30807. * Callback called when the task is successful
  30808. */
  30809. onSuccess: (task: CubeTextureAssetTask) => void;
  30810. /**
  30811. * Callback called when the task is successful
  30812. */
  30813. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  30814. /**
  30815. * Creates a new CubeTextureAssetTask
  30816. * @param name defines the name of the task
  30817. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30818. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30819. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30820. * @param files defines the explicit list of files (undefined by default)
  30821. */
  30822. constructor(
  30823. /**
  30824. * Defines the name of the task
  30825. */
  30826. name: string,
  30827. /**
  30828. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30829. */
  30830. url: string,
  30831. /**
  30832. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30833. */
  30834. extensions?: string[] | undefined,
  30835. /**
  30836. * Defines if mipmaps should not be generated (default is false)
  30837. */
  30838. noMipmap?: boolean | undefined,
  30839. /**
  30840. * Defines the explicit list of files (undefined by default)
  30841. */
  30842. files?: string[] | undefined);
  30843. /**
  30844. * Execute the current task
  30845. * @param scene defines the scene where you want your assets to be loaded
  30846. * @param onSuccess is a callback called when the task is successfully executed
  30847. * @param onError is a callback called if an error occurs
  30848. */
  30849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30850. }
  30851. /**
  30852. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  30853. */
  30854. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  30855. /**
  30856. * Defines the name of the task
  30857. */
  30858. name: string;
  30859. /**
  30860. * Defines the location of the file to load
  30861. */
  30862. url: string;
  30863. /**
  30864. * 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.
  30865. */
  30866. size: number | undefined;
  30867. /**
  30868. * Defines if mipmaps should not be generated (default is false)
  30869. */
  30870. noMipmap: boolean;
  30871. /**
  30872. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30873. */
  30874. generateHarmonics: boolean;
  30875. /**
  30876. * 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)
  30877. */
  30878. useInGammaSpace: boolean;
  30879. /**
  30880. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  30881. */
  30882. usePMREMGenerator: boolean;
  30883. /**
  30884. * Gets the loaded texture
  30885. */
  30886. texture: HDRCubeTexture;
  30887. /**
  30888. * Callback called when the task is successful
  30889. */
  30890. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  30891. /**
  30892. * Callback called when the task is successful
  30893. */
  30894. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  30895. /**
  30896. * Creates a new HDRCubeTextureAssetTask object
  30897. * @param name defines the name of the task
  30898. * @param url defines the location of the file to load
  30899. * @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.
  30900. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30901. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30902. * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  30903. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  30904. */
  30905. constructor(
  30906. /**
  30907. * Defines the name of the task
  30908. */
  30909. name: string,
  30910. /**
  30911. * Defines the location of the file to load
  30912. */
  30913. url: string,
  30914. /**
  30915. * 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.
  30916. */
  30917. size?: number | undefined,
  30918. /**
  30919. * Defines if mipmaps should not be generated (default is false)
  30920. */
  30921. noMipmap?: boolean,
  30922. /**
  30923. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30924. */
  30925. generateHarmonics?: boolean,
  30926. /**
  30927. * 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)
  30928. */
  30929. useInGammaSpace?: boolean,
  30930. /**
  30931. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  30932. */
  30933. usePMREMGenerator?: boolean);
  30934. /**
  30935. * Execute the current task
  30936. * @param scene defines the scene where you want your assets to be loaded
  30937. * @param onSuccess is a callback called when the task is successfully executed
  30938. * @param onError is a callback called if an error occurs
  30939. */
  30940. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30941. }
  30942. /**
  30943. * This class can be used to easily import assets into a scene
  30944. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  30945. */
  30946. class AssetsManager {
  30947. private _scene;
  30948. private _isLoading;
  30949. protected _tasks: AbstractAssetTask[];
  30950. protected _waitingTasksCount: number;
  30951. protected _totalTasksCount: number;
  30952. /**
  30953. * Callback called when all tasks are processed
  30954. */
  30955. onFinish: (tasks: AbstractAssetTask[]) => void;
  30956. /**
  30957. * Callback called when a task is successful
  30958. */
  30959. onTaskSuccess: (task: AbstractAssetTask) => void;
  30960. /**
  30961. * Callback called when a task had an error
  30962. */
  30963. onTaskError: (task: AbstractAssetTask) => void;
  30964. /**
  30965. * Callback called when a task is done (whatever the result is)
  30966. */
  30967. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  30968. /**
  30969. * Observable called when all tasks are processed
  30970. */
  30971. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  30972. /**
  30973. * Observable called when a task had an error
  30974. */
  30975. onTaskErrorObservable: Observable<AbstractAssetTask>;
  30976. /**
  30977. * Observable called when a task is successful
  30978. */
  30979. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  30980. /**
  30981. * Observable called when a task is done (whatever the result is)
  30982. */
  30983. onProgressObservable: Observable<IAssetsProgressEvent>;
  30984. /**
  30985. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  30986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30987. */
  30988. useDefaultLoadingScreen: boolean;
  30989. /**
  30990. * Creates a new AssetsManager
  30991. * @param scene defines the scene to work on
  30992. */
  30993. constructor(scene: Scene);
  30994. /**
  30995. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  30996. * @param taskName defines the name of the new task
  30997. * @param meshesNames defines the name of meshes to load
  30998. * @param rootUrl defines the root url to use to locate files
  30999. * @param sceneFilename defines the filename of the scene file
  31000. * @returns a new {BABYLON.MeshAssetTask} object
  31001. */
  31002. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  31003. /**
  31004. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  31005. * @param taskName defines the name of the new task
  31006. * @param url defines the url of the file to load
  31007. * @returns a new {BABYLON.TextFileAssetTask} object
  31008. */
  31009. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  31010. /**
  31011. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  31012. * @param taskName defines the name of the new task
  31013. * @param url defines the url of the file to load
  31014. * @returns a new {BABYLON.BinaryFileAssetTask} object
  31015. */
  31016. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  31017. /**
  31018. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  31019. * @param taskName defines the name of the new task
  31020. * @param url defines the url of the file to load
  31021. * @returns a new {BABYLON.ImageAssetTask} object
  31022. */
  31023. addImageTask(taskName: string, url: string): ImageAssetTask;
  31024. /**
  31025. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  31026. * @param taskName defines the name of the new task
  31027. * @param url defines the url of the file to load
  31028. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  31029. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  31030. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  31031. * @returns a new {BABYLON.TextureAssetTask} object
  31032. */
  31033. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  31034. /**
  31035. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  31036. * @param taskName defines the name of the new task
  31037. * @param url defines the url of the file to load
  31038. * @param extensions defines the extension to use to load the cube map (can be null)
  31039. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  31040. * @param files defines the list of files to load (can be null)
  31041. * @returns a new {BABYLON.CubeTextureAssetTask} object
  31042. */
  31043. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  31044. /**
  31045. *
  31046. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  31047. * @param taskName defines the name of the new task
  31048. * @param url defines the url of the file to load
  31049. * @param size defines the size you want for the cubemap (can be null)
  31050. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  31051. * @param generateHarmonics defines if you want to automatically generate (true by default)
  31052. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  31053. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  31054. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  31055. */
  31056. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  31057. private _decreaseWaitingTasksCount(task);
  31058. private _runTask(task);
  31059. /**
  31060. * Reset the {BABYLON.AssetsManager} and remove all tasks
  31061. * @return the current instance of the {BABYLON.AssetsManager}
  31062. */
  31063. reset(): AssetsManager;
  31064. /**
  31065. * Start the loading process
  31066. * @return the current instance of the {BABYLON.AssetsManager}
  31067. */
  31068. load(): AssetsManager;
  31069. }
  31070. }
  31071. declare module BABYLON {
  31072. class Database {
  31073. private callbackManifestChecked;
  31074. private currentSceneUrl;
  31075. private db;
  31076. private _enableSceneOffline;
  31077. private _enableTexturesOffline;
  31078. private manifestVersionFound;
  31079. private mustUpdateRessources;
  31080. private hasReachedQuota;
  31081. private isSupported;
  31082. private idbFactory;
  31083. static IsUASupportingBlobStorage: boolean;
  31084. static IDBStorageEnabled: boolean;
  31085. readonly enableSceneOffline: boolean;
  31086. readonly enableTexturesOffline: boolean;
  31087. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  31088. static parseURL: (url: string) => string;
  31089. static ReturnFullUrlLocation: (url: string) => string;
  31090. checkManifestFile(): void;
  31091. openAsync(successCallback: () => void, errorCallback: () => void): void;
  31092. loadImageFromDB(url: string, image: HTMLImageElement): void;
  31093. private _loadImageFromDBAsync(url, image, notInDBCallback);
  31094. private _saveImageIntoDBAsync(url, image);
  31095. private _checkVersionFromDB(url, versionLoaded);
  31096. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  31097. private _saveVersionIntoDBAsync(url, callback);
  31098. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  31099. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  31100. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  31101. }
  31102. }
  31103. declare module BABYLON {
  31104. interface DDSInfo {
  31105. width: number;
  31106. height: number;
  31107. mipmapCount: number;
  31108. isFourCC: boolean;
  31109. isRGB: boolean;
  31110. isLuminance: boolean;
  31111. isCube: boolean;
  31112. isCompressed: boolean;
  31113. dxgiFormat: number;
  31114. textureType: number;
  31115. }
  31116. class DDSTools {
  31117. static StoreLODInAlphaChannel: boolean;
  31118. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  31119. private static _FloatView;
  31120. private static _Int32View;
  31121. private static _ToHalfFloat(value);
  31122. private static _FromHalfFloat(value);
  31123. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31124. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31125. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31126. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31127. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31128. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  31129. private static _ExtractLongWordOrder(value);
  31130. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  31131. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  31132. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  31133. }
  31134. }
  31135. declare module BABYLON {
  31136. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31137. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31138. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31139. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31140. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31141. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31142. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31143. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31144. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31145. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31146. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31147. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31148. class SerializationHelper {
  31149. static Serialize<T>(entity: T, serializationObject?: any): any;
  31150. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31151. static Clone<T>(creationFunction: () => T, source: T): T;
  31152. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31153. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  31154. }
  31155. }
  31156. declare module BABYLON {
  31157. /**
  31158. <<<<<<< HEAD
  31159. * Define a task used by {BABYLON.AssetsManager} to load binary data
  31160. */
  31161. class BinaryFileAssetTask extends AbstractAssetTask {
  31162. /**
  31163. * Defines the name of the task
  31164. */
  31165. name: string;
  31166. /**
  31167. * Defines the location of the file to load
  31168. */
  31169. url: string;
  31170. /**
  31171. * Gets the lodaded data (as an array buffer)
  31172. */
  31173. data: ArrayBuffer;
  31174. /**
  31175. * Callback called when the task is successful
  31176. */
  31177. onSuccess: (task: BinaryFileAssetTask) => void;
  31178. /**
  31179. * Callback called when the task is successful
  31180. */
  31181. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  31182. /**
  31183. * Creates a new BinaryFileAssetTask object
  31184. * @param name defines the name of the new task
  31185. * @param url defines the location of the file to load
  31186. */
  31187. constructor(
  31188. /**
  31189. * Defines the name of the task
  31190. */
  31191. name: string,
  31192. /**
  31193. * Defines the location of the file to load
  31194. */
  31195. url: string);
  31196. /**
  31197. * Execute the current task
  31198. * @param scene defines the scene where you want your assets to be loaded
  31199. * @param onSuccess is a callback called when the task is successfully executed
  31200. * @param onError is a callback called if an error occurs
  31201. */
  31202. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  31203. =======
  31204. * Wrapper class for promise with external resolve and reject.
  31205. */
  31206. class Deferred<T> {
  31207. /**
  31208. * The promise associated with this deferred object.
  31209. */
  31210. readonly promise: Promise<T>;
  31211. private _resolve;
  31212. private _reject;
  31213. /**
  31214. * The resolve method of the promise associated with this deferred object.
  31215. */
  31216. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  31217. /**
  31218. * The reject method of the promise associated with this deferred object.
  31219. */
  31220. readonly reject: (reason?: any) => void;
  31221. /**
  31222. * Constructor for this deferred object.
  31223. */
  31224. constructor();
  31225. }
  31226. }
  31227. declare module Earcut {
  31228. /**
  31229. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  31230. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  31231. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  31232. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  31233. */
  31234. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  31235. /**
  31236. * return a percentage difference between the polygon area and its triangulation area;
  31237. * used to verify correctness of triangulation
  31238. */
  31239. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  31240. /**
  31241. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  31242. */
  31243. function flatten(data: number[][][]): {
  31244. vertices: number[];
  31245. holes: number[];
  31246. dimensions: number;
  31247. };
  31248. }
  31249. declare module BABYLON {
  31250. class FilesInput {
  31251. static FilesToLoad: {
  31252. [key: string]: File;
  31253. };
  31254. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  31255. private _engine;
  31256. private _currentScene;
  31257. private _sceneLoadedCallback;
  31258. private _progressCallback;
  31259. private _additionalRenderLoopLogicCallback;
  31260. private _textureLoadingCallback;
  31261. private _startingProcessingFilesCallback;
  31262. private _onReloadCallback;
  31263. private _errorCallback;
  31264. private _elementToMonitor;
  31265. private _sceneFileToLoad;
  31266. private _filesToLoad;
  31267. 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);
  31268. private _dragEnterHandler;
  31269. private _dragOverHandler;
  31270. private _dropHandler;
  31271. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  31272. dispose(): void;
  31273. private renderFunction();
  31274. private drag(e);
  31275. private drop(eventDrop);
  31276. private _traverseFolder(folder, files, remaining, callback);
  31277. private _processFiles(files);
  31278. loadFiles(event: any): void;
  31279. private _processReload();
  31280. reload(): void;
  31281. }
  31282. }
  31283. declare module BABYLON {
  31284. /**
  31285. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31286. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31287. */
  31288. class KhronosTextureContainer {
  31289. arrayBuffer: any;
  31290. static HEADER_LEN: number;
  31291. static COMPRESSED_2D: number;
  31292. static COMPRESSED_3D: number;
  31293. static TEX_2D: number;
  31294. static TEX_3D: number;
  31295. glType: number;
  31296. glTypeSize: number;
  31297. glFormat: number;
  31298. glInternalFormat: number;
  31299. glBaseInternalFormat: number;
  31300. pixelWidth: number;
  31301. pixelHeight: number;
  31302. pixelDepth: number;
  31303. numberOfArrayElements: number;
  31304. numberOfFaces: number;
  31305. numberOfMipmapLevels: number;
  31306. bytesOfKeyValueData: number;
  31307. loadType: number;
  31308. /**
  31309. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  31310. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  31311. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  31312. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  31313. */
  31314. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  31315. switchEndainness(val: number): number;
  31316. /**
  31317. * It is assumed that the texture has already been created & is currently bound
  31318. */
  31319. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  31320. private _upload2DCompressedLevels(gl, loadMipmaps);
  31321. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  31322. }
  31323. }
  31324. declare module BABYLON {
  31325. /**
  31326. <<<<<<< HEAD
  31327. * Define a task used by {BABYLON.AssetsManager} to load images
  31328. */
  31329. class ImageAssetTask extends AbstractAssetTask {
  31330. /**
  31331. * Defines the name of the task
  31332. */
  31333. name: string;
  31334. /**
  31335. * Defines the location of the image to load
  31336. */
  31337. url: string;
  31338. /**
  31339. * Gets the loaded images
  31340. */
  31341. image: HTMLImageElement;
  31342. /**
  31343. * Callback called when the task is successful
  31344. */
  31345. onSuccess: (task: ImageAssetTask) => void;
  31346. /**
  31347. * Callback called when the task is successful
  31348. */
  31349. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  31350. /**
  31351. * Creates a new ImageAssetTask
  31352. * @param name defines the name of the task
  31353. * @param url defines the location of the image to load
  31354. */
  31355. constructor(
  31356. /**
  31357. * Defines the name of the task
  31358. */
  31359. name: string,
  31360. /**
  31361. * Defines the location of the image to load
  31362. */
  31363. url: string);
  31364. /**
  31365. * Execute the current task
  31366. * @param scene defines the scene where you want your assets to be loaded
  31367. * @param onSuccess is a callback called when the task is successfully executed
  31368. * @param onError is a callback called if an error occurs
  31369. */
  31370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  31371. }
  31372. /**
  31373. * Defines the interface used by texture loading tasks
  31374. */
  31375. interface ITextureAssetTask<TEX extends BaseTexture> {
  31376. /**
  31377. * Gets the loaded texture
  31378. */
  31379. texture: TEX;
  31380. }
  31381. /**
  31382. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  31383. */
  31384. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  31385. /**
  31386. * Defines the name of the task
  31387. */
  31388. name: string;
  31389. /**
  31390. * Defines the location of the file to load
  31391. */
  31392. url: string;
  31393. /**
  31394. * Defines if mipmap should not be generated (default is false)
  31395. */
  31396. noMipmap: boolean | undefined;
  31397. /**
  31398. * Defines if texture must be inverted on Y axis (default is false)
  31399. */
  31400. invertY: boolean | undefined;
  31401. /**
  31402. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  31403. */
  31404. samplingMode: number;
  31405. /**
  31406. * Gets the loaded texture
  31407. */
  31408. texture: Texture;
  31409. /**
  31410. * Callback called when the task is successful
  31411. */
  31412. onSuccess: (task: TextureAssetTask) => void;
  31413. /**
  31414. * Callback called when the task is successful
  31415. */
  31416. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  31417. /**
  31418. * Creates a new TextureAssetTask object
  31419. * @param name defines the name of the task
  31420. * @param url defines the location of the file to load
  31421. * @param noMipmap defines if mipmap should not be generated (default is false)
  31422. * @param invertY defines if texture must be inverted on Y axis (default is false)
  31423. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  31424. */
  31425. constructor(
  31426. /**
  31427. * Defines the name of the task
  31428. */
  31429. name: string,
  31430. /**
  31431. * Defines the location of the file to load
  31432. */
  31433. url: string,
  31434. /**
  31435. * Defines if mipmap should not be generated (default is false)
  31436. */
  31437. noMipmap?: boolean | undefined,
  31438. /**
  31439. * Defines if texture must be inverted on Y axis (default is false)
  31440. */
  31441. invertY?: boolean | undefined,
  31442. /**
  31443. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  31444. */
  31445. samplingMode?: number);
  31446. /**
  31447. * Execute the current task
  31448. * @param scene defines the scene where you want your assets to be loaded
  31449. * @param onSuccess is a callback called when the task is successfully executed
  31450. * @param onError is a callback called if an error occurs
  31451. */
  31452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  31453. }
  31454. /**
  31455. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  31456. */
  31457. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  31458. /**
  31459. * Defines the name of the task
  31460. */
  31461. name: string;
  31462. /**
  31463. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  31464. */
  31465. url: string;
  31466. /**
  31467. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  31468. */
  31469. extensions: string[] | undefined;
  31470. /**
  31471. * Defines if mipmaps should not be generated (default is false)
  31472. */
  31473. noMipmap: boolean | undefined;
  31474. /**
  31475. * Defines the explicit list of files (undefined by default)
  31476. */
  31477. files: string[] | undefined;
  31478. /**
  31479. * Gets the loaded texture
  31480. */
  31481. texture: CubeTexture;
  31482. /**
  31483. * Callback called when the task is successful
  31484. */
  31485. onSuccess: (task: CubeTextureAssetTask) => void;
  31486. /**
  31487. * Callback called when the task is successful
  31488. */
  31489. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  31490. /**
  31491. * Creates a new CubeTextureAssetTask
  31492. * @param name defines the name of the task
  31493. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  31494. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  31495. * @param noMipmap defines if mipmaps should not be generated (default is false)
  31496. * @param files defines the explicit list of files (undefined by default)
  31497. */
  31498. constructor(
  31499. /**
  31500. * Defines the name of the task
  31501. */
  31502. name: string,
  31503. /**
  31504. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  31505. */
  31506. url: string,
  31507. /**
  31508. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  31509. */
  31510. extensions?: string[] | undefined,
  31511. /**
  31512. * Defines if mipmaps should not be generated (default is false)
  31513. */
  31514. noMipmap?: boolean | undefined,
  31515. /**
  31516. * Defines the explicit list of files (undefined by default)
  31517. */
  31518. files?: string[] | undefined);
  31519. /**
  31520. * Execute the current task
  31521. * @param scene defines the scene where you want your assets to be loaded
  31522. * @param onSuccess is a callback called when the task is successfully executed
  31523. * @param onError is a callback called if an error occurs
  31524. */
  31525. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  31526. }
  31527. /**
  31528. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  31529. */
  31530. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  31531. /**
  31532. * Defines the name of the task
  31533. */
  31534. name: string;
  31535. /**
  31536. * Defines the location of the file to load
  31537. */
  31538. url: string;
  31539. /**
  31540. * 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.
  31541. */
  31542. size: number | undefined;
  31543. /**
  31544. * Defines if mipmaps should not be generated (default is false)
  31545. */
  31546. noMipmap: boolean;
  31547. /**
  31548. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  31549. */
  31550. generateHarmonics: boolean;
  31551. /**
  31552. * 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)
  31553. */
  31554. useInGammaSpace: boolean;
  31555. /**
  31556. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  31557. */
  31558. usePMREMGenerator: boolean;
  31559. /**
  31560. * Gets the loaded texture
  31561. */
  31562. texture: HDRCubeTexture;
  31563. /**
  31564. * Callback called when the task is successful
  31565. */
  31566. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  31567. /**
  31568. * Callback called when the task is successful
  31569. */
  31570. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  31571. /**
  31572. * Creates a new HDRCubeTextureAssetTask object
  31573. * @param name defines the name of the task
  31574. * @param url defines the location of the file to load
  31575. * @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.
  31576. * @param noMipmap defines if mipmaps should not be generated (default is false)
  31577. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  31578. * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  31579. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  31580. */
  31581. constructor(
  31582. /**
  31583. * Defines the name of the task
  31584. */
  31585. name: string,
  31586. /**
  31587. * Defines the location of the file to load
  31588. */
  31589. url: string,
  31590. /**
  31591. * 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.
  31592. */
  31593. size?: number | undefined,
  31594. /**
  31595. * Defines if mipmaps should not be generated (default is false)
  31596. */
  31597. noMipmap?: boolean,
  31598. /**
  31599. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  31600. */
  31601. generateHarmonics?: boolean,
  31602. /**
  31603. * 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)
  31604. */
  31605. useInGammaSpace?: boolean,
  31606. /**
  31607. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  31608. */
  31609. usePMREMGenerator?: boolean);
  31610. /**
  31611. * Execute the current task
  31612. * @param scene defines the scene where you want your assets to be loaded
  31613. * @param onSuccess is a callback called when the task is successfully executed
  31614. * @param onError is a callback called if an error occurs
  31615. */
  31616. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  31617. }
  31618. /**
  31619. * This class can be used to easily import assets into a scene
  31620. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  31621. */
  31622. class AssetsManager {
  31623. private _scene;
  31624. private _isLoading;
  31625. protected _tasks: AbstractAssetTask[];
  31626. protected _waitingTasksCount: number;
  31627. protected _totalTasksCount: number;
  31628. /**
  31629. * Callback called when all tasks are processed
  31630. */
  31631. onFinish: (tasks: AbstractAssetTask[]) => void;
  31632. /**
  31633. * Callback called when a task is successful
  31634. */
  31635. onTaskSuccess: (task: AbstractAssetTask) => void;
  31636. /**
  31637. * Callback called when a task had an error
  31638. */
  31639. onTaskError: (task: AbstractAssetTask) => void;
  31640. /**
  31641. * Callback called when a task is done (whatever the result is)
  31642. */
  31643. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  31644. /**
  31645. * Observable called when all tasks are processed
  31646. */
  31647. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  31648. /**
  31649. * Observable called when a task had an error
  31650. */
  31651. onTaskErrorObservable: Observable<AbstractAssetTask>;
  31652. /**
  31653. * Observable called when a task is successful
  31654. */
  31655. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  31656. /**
  31657. * Observable called when a task is done (whatever the result is)
  31658. */
  31659. onProgressObservable: Observable<IAssetsProgressEvent>;
  31660. /**
  31661. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  31662. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31663. */
  31664. useDefaultLoadingScreen: boolean;
  31665. /**
  31666. * Creates a new AssetsManager
  31667. * @param scene defines the scene to work on
  31668. */
  31669. constructor(scene: Scene);
  31670. /**
  31671. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  31672. * @param taskName defines the name of the new task
  31673. * @param meshesNames defines the name of meshes to load
  31674. * @param rootUrl defines the root url to use to locate files
  31675. * @param sceneFilename defines the filename of the scene file
  31676. * @returns a new {BABYLON.MeshAssetTask} object
  31677. */
  31678. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  31679. /**
  31680. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  31681. * @param taskName defines the name of the new task
  31682. * @param url defines the url of the file to load
  31683. * @returns a new {BABYLON.TextFileAssetTask} object
  31684. */
  31685. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  31686. /**
  31687. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  31688. * @param taskName defines the name of the new task
  31689. * @param url defines the url of the file to load
  31690. * @returns a new {BABYLON.BinaryFileAssetTask} object
  31691. */
  31692. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  31693. /**
  31694. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  31695. * @param taskName defines the name of the new task
  31696. * @param url defines the url of the file to load
  31697. * @returns a new {BABYLON.ImageAssetTask} object
  31698. */
  31699. addImageTask(taskName: string, url: string): ImageAssetTask;
  31700. /**
  31701. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  31702. * @param taskName defines the name of the new task
  31703. * @param url defines the url of the file to load
  31704. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  31705. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  31706. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  31707. * @returns a new {BABYLON.TextureAssetTask} object
  31708. */
  31709. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  31710. /**
  31711. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  31712. * @param taskName defines the name of the new task
  31713. * @param url defines the url of the file to load
  31714. * @param extensions defines the extension to use to load the cube map (can be null)
  31715. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  31716. * @param files defines the list of files to load (can be null)
  31717. * @returns a new {BABYLON.CubeTextureAssetTask} object
  31718. */
  31719. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  31720. /**
  31721. *
  31722. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  31723. * @param taskName defines the name of the new task
  31724. * @param url defines the url of the file to load
  31725. * @param size defines the size you want for the cubemap (can be null)
  31726. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  31727. * @param generateHarmonics defines if you want to automatically generate (true by default)
  31728. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  31729. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  31730. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  31731. */
  31732. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  31733. private _decreaseWaitingTasksCount(task);
  31734. private _runTask(task);
  31735. /**
  31736. * Reset the {BABYLON.AssetsManager} and remove all tasks
  31737. * @return the current instance of the {BABYLON.AssetsManager}
  31738. */
  31739. reset(): AssetsManager;
  31740. /**
  31741. * Start the loading process
  31742. * @return the current instance of the {BABYLON.AssetsManager}
  31743. */
  31744. load(): AssetsManager;
  31745. }
  31746. }
  31747. declare module BABYLON {
  31748. class Database {
  31749. private callbackManifestChecked;
  31750. private currentSceneUrl;
  31751. private db;
  31752. private _enableSceneOffline;
  31753. private _enableTexturesOffline;
  31754. private manifestVersionFound;
  31755. private mustUpdateRessources;
  31756. private hasReachedQuota;
  31757. private isSupported;
  31758. private idbFactory;
  31759. static IsUASupportingBlobStorage: boolean;
  31760. static IDBStorageEnabled: boolean;
  31761. readonly enableSceneOffline: boolean;
  31762. readonly enableTexturesOffline: boolean;
  31763. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  31764. static parseURL: (url: string) => string;
  31765. static ReturnFullUrlLocation: (url: string) => string;
  31766. checkManifestFile(): void;
  31767. openAsync(successCallback: () => void, errorCallback: () => void): void;
  31768. loadImageFromDB(url: string, image: HTMLImageElement): void;
  31769. private _loadImageFromDBAsync(url, image, notInDBCallback);
  31770. private _saveImageIntoDBAsync(url, image);
  31771. private _checkVersionFromDB(url, versionLoaded);
  31772. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  31773. private _saveVersionIntoDBAsync(url, callback);
  31774. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  31775. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  31776. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  31777. }
  31778. }
  31779. declare module BABYLON {
  31780. interface DDSInfo {
  31781. width: number;
  31782. height: number;
  31783. mipmapCount: number;
  31784. isFourCC: boolean;
  31785. isRGB: boolean;
  31786. isLuminance: boolean;
  31787. isCube: boolean;
  31788. isCompressed: boolean;
  31789. dxgiFormat: number;
  31790. textureType: number;
  31791. }
  31792. class DDSTools {
  31793. static StoreLODInAlphaChannel: boolean;
  31794. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  31795. private static _FloatView;
  31796. private static _Int32View;
  31797. private static _ToHalfFloat(value);
  31798. private static _FromHalfFloat(value);
  31799. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31800. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31801. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31802. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31803. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  31804. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  31805. private static _ExtractLongWordOrder(value);
  31806. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  31807. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  31808. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  31809. }
  31810. }
  31811. declare module BABYLON {
  31812. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31813. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31814. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31815. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31816. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31817. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31818. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31819. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31820. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31821. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31822. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31823. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31824. class SerializationHelper {
  31825. static Serialize<T>(entity: T, serializationObject?: any): any;
  31826. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31827. static Clone<T>(creationFunction: () => T, source: T): T;
  31828. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31829. }
  31830. }
  31831. declare module BABYLON {
  31832. /**
  31833. * Wrapper class for promise with external resolve and reject.
  31834. */
  31835. class Deferred<T> {
  31836. /**
  31837. * The promise associated with this deferred object.
  31838. */
  31839. readonly promise: Promise<T>;
  31840. private _resolve;
  31841. private _reject;
  31842. /**
  31843. * The resolve method of the promise associated with this deferred object.
  31844. */
  31845. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  31846. /**
  31847. * The reject method of the promise associated with this deferred object.
  31848. */
  31849. readonly reject: (reason?: any) => void;
  31850. /**
  31851. * Constructor for this deferred object.
  31852. */
  31853. constructor();
  31854. }
  31855. }
  31856. declare module Earcut {
  31857. /**
  31858. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  31859. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  31860. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  31861. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  31862. */
  31863. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  31864. /**
  31865. * return a percentage difference between the polygon area and its triangulation area;
  31866. * used to verify correctness of triangulation
  31867. */
  31868. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  31869. /**
  31870. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  31871. */
  31872. function flatten(data: number[][][]): {
  31873. vertices: number[];
  31874. holes: number[];
  31875. dimensions: number;
  31876. };
  31877. }
  31878. declare module BABYLON {
  31879. class FilesInput {
  31880. static FilesToLoad: {
  31881. [key: string]: File;
  31882. };
  31883. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  31884. private _engine;
  31885. private _currentScene;
  31886. private _sceneLoadedCallback;
  31887. private _progressCallback;
  31888. private _additionalRenderLoopLogicCallback;
  31889. private _textureLoadingCallback;
  31890. private _startingProcessingFilesCallback;
  31891. private _onReloadCallback;
  31892. private _errorCallback;
  31893. private _elementToMonitor;
  31894. private _sceneFileToLoad;
  31895. private _filesToLoad;
  31896. 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);
  31897. private _dragEnterHandler;
  31898. private _dragOverHandler;
  31899. private _dropHandler;
  31900. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  31901. dispose(): void;
  31902. private renderFunction();
  31903. private drag(e);
  31904. private drop(eventDrop);
  31905. private _traverseFolder(folder, files, remaining, callback);
  31906. private _processFiles(files);
  31907. loadFiles(event: any): void;
  31908. private _processReload();
  31909. reload(): void;
  31910. }
  31911. }
  31912. declare module BABYLON {
  31913. /**
  31914. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31915. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31916. */
  31917. class KhronosTextureContainer {
  31918. arrayBuffer: any;
  31919. static HEADER_LEN: number;
  31920. static COMPRESSED_2D: number;
  31921. static COMPRESSED_3D: number;
  31922. static TEX_2D: number;
  31923. static TEX_3D: number;
  31924. glType: number;
  31925. glTypeSize: number;
  31926. glFormat: number;
  31927. glInternalFormat: number;
  31928. glBaseInternalFormat: number;
  31929. pixelWidth: number;
  31930. pixelHeight: number;
  31931. pixelDepth: number;
  31932. numberOfArrayElements: number;
  31933. numberOfFaces: number;
  31934. numberOfMipmapLevels: number;
  31935. bytesOfKeyValueData: number;
  31936. loadType: number;
  31937. /**
  31938. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  31939. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  31940. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  31941. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  31942. */
  31943. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  31944. switchEndainness(val: number): number;
  31945. /**
  31946. * It is assumed that the texture has already been created & is currently bound
  31947. */
  31948. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  31949. private _upload2DCompressedLevels(gl, loadMipmaps);
  31950. }
  31951. }
  31952. declare module BABYLON {
  31953. /**
  31954. * A class serves as a medium between the observable and its observers
  31955. */
  31956. class EventState {
  31957. /**
  31958. * Create a new EventState
  31959. * @param mask defines the mask associated with this state
  31960. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  31961. * @param target defines the original target of the state
  31962. * @param currentTarget defines the current target of the state
  31963. */
  31964. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  31965. /**
  31966. * Initialize the current event state
  31967. * @param mask defines the mask associated with this state
  31968. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  31969. * @param target defines the original target of the state
  31970. * @param currentTarget defines the current target of the state
  31971. * @returns the current event state
  31972. */
  31973. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  31974. /**
  31975. * An Observer can set this property to true to prevent subsequent observers of being notified
  31976. */
  31977. skipNextObservers: boolean;
  31978. /**
  31979. * Get the mask value that were used to trigger the event corresponding to this EventState object
  31980. */
  31981. mask: number;
  31982. /**
  31983. * The object that originally notified the event
  31984. */
  31985. target?: any;
  31986. /**
  31987. * The current object in the bubbling phase
  31988. */
  31989. currentTarget?: any;
  31990. /**
  31991. * This will be populated with the return value of the last function that was executed.
  31992. * If it is the first function in the callback chain it will be the event data.
  31993. */
  31994. lastReturnValue?: any;
  31995. }
  31996. /**
  31997. * Represent an Observer registered to a given Observable object.
  31998. */
  31999. class Observer<T> {
  32000. /**
  32001. * Defines the callback to call when the observer is notified
  32002. */
  32003. callback: (eventData: T, eventState: EventState) => void;
  32004. /**
  32005. * Defines the mask of the observer (used to filter notifications)
  32006. */
  32007. mask: number;
  32008. /**
  32009. * Defines the current scope used to restore the JS context
  32010. */
  32011. scope: any;
  32012. /** @ignore */
  32013. _willBeUnregistered: boolean;
  32014. /**
  32015. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  32016. */
  32017. unregisterOnNextCall: boolean;
  32018. /**
  32019. * Creates a new observer
  32020. * @param callback defines the callback to call when the observer is notified
  32021. * @param mask defines the mask of the observer (used to filter notifications)
  32022. * @param scope defines the current scope used to restore the JS context
  32023. */
  32024. constructor(
  32025. /**
  32026. * Defines the callback to call when the observer is notified
  32027. */
  32028. callback: (eventData: T, eventState: EventState) => void,
  32029. /**
  32030. * Defines the mask of the observer (used to filter notifications)
  32031. */
  32032. mask: number,
  32033. /**
  32034. * Defines the current scope used to restore the JS context
  32035. */
  32036. scope?: any);
  32037. }
  32038. /**
  32039. * Represent a list of observers registered to multiple Observables object.
  32040. */
  32041. class MultiObserver<T> {
  32042. private _observers;
  32043. private _observables;
  32044. /**
  32045. * Release associated resources
  32046. */
  32047. dispose(): void;
  32048. /**
  32049. * Raise a callback when one of the observable will notify
  32050. * @param observables defines a list of observables to watch
  32051. * @param callback defines the callback to call on notification
  32052. * @param mask defines the mask used to filter notifications
  32053. * @param scope defines the current scope used to restore the JS context
  32054. * @returns the new MultiObserver
  32055. */
  32056. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  32057. }
  32058. /**
  32059. * The Observable class is a simple implementation of the Observable pattern.
  32060. * 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.
  32061. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  32062. * 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).
  32063. * 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.
  32064. */
  32065. class Observable<T> {
  32066. private _observers;
  32067. private _eventState;
  32068. private _onObserverAdded;
  32069. /**
  32070. * Creates a new observable
  32071. * @param onObserverAdded defines a callback to call when a new observer is added
  32072. */
  32073. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  32074. /**
  32075. * Create a new Observer with the specified callback
  32076. * @param callback the callback that will be executed for that Observer
  32077. * @param mask the mask used to filter observers
  32078. * @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.
  32079. * @param scope optional scope for the callback to be called from
  32080. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  32081. * @returns the new observer created for the callback
  32082. */
  32083. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  32084. /**
  32085. * Remove an Observer from the Observable object
  32086. * @param observer the instance of the Observer to remove
  32087. * @returns false if it doesn't belong to this Observable
  32088. */
  32089. remove(observer: Nullable<Observer<T>>): boolean;
  32090. /**
  32091. * Remove a callback from the Observable object
  32092. * @param callback the callback to remove
  32093. * @param scope optional scope. If used only the callbacks with this scope will be removed
  32094. * @returns false if it doesn't belong to this Observable
  32095. */
  32096. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  32097. private _deferUnregister(observer);
  32098. /**
  32099. * Notify all Observers by calling their respective callback with the given data
  32100. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  32101. * @param eventData defines the data to send to all observers
  32102. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  32103. * @param target defines the original target of the state
  32104. * @param currentTarget defines the current target of the state
  32105. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  32106. */
  32107. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  32108. /**
  32109. * Calling this will execute each callback, expecting it to be a promise or return a value.
  32110. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  32111. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  32112. * and it is crucial that all callbacks will be executed.
  32113. * The order of the callbacks is kept, callbacks are not executed parallel.
  32114. *
  32115. * @param eventData The data to be sent to each callback
  32116. * @param mask is used to filter observers defaults to -1
  32117. * @param target defines the callback target (see EventState)
  32118. * @param currentTarget defines he current object in the bubbling phase
  32119. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  32120. */
  32121. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  32122. /**
  32123. * Notify a specific observer
  32124. * @param observer defines the observer to notify
  32125. * @param eventData defines the data to be sent to each callback
  32126. * @param mask is used to filter observers defaults to -1
  32127. */
  32128. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  32129. /**
  32130. * Gets a boolean indicating if the observable has at least one observer
  32131. * @returns true is the Observable has at least one Observer registered
  32132. */
  32133. hasObservers(): boolean;
  32134. /**
  32135. * Clear the list of observers
  32136. */
  32137. clear(): void;
  32138. /**
  32139. * Clone the current observable
  32140. * @returns a new observable
  32141. */
  32142. clone(): Observable<T>;
  32143. /**
  32144. * Does this observable handles observer registered with a given mask
  32145. * @param mask defines the mask to be tested
  32146. * @return whether or not one observer registered with the given mask is handeled
  32147. **/
  32148. hasSpecificMask(mask?: number): boolean;
  32149. }
  32150. }
  32151. declare module BABYLON {
  32152. /**
  32153. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32154. */
  32155. class PerformanceMonitor {
  32156. private _enabled;
  32157. private _rollingFrameTime;
  32158. private _lastFrameTimeMs;
  32159. /**
  32160. * constructor
  32161. * @param frameSampleSize The number of samples required to saturate the sliding window
  32162. */
  32163. constructor(frameSampleSize?: number);
  32164. /**
  32165. * Samples current frame
  32166. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32167. */
  32168. sampleFrame(timeMs?: number): void;
  32169. /**
  32170. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32171. * @return Average frame time in milliseconds
  32172. */
  32173. readonly averageFrameTime: number;
  32174. /**
  32175. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32176. * @return Frame time variance in milliseconds squared
  32177. */
  32178. readonly averageFrameTimeVariance: number;
  32179. /**
  32180. * Returns the frame time of the most recent frame
  32181. * @return Frame time in milliseconds
  32182. */
  32183. readonly instantaneousFrameTime: number;
  32184. /**
  32185. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32186. * @return Framerate in frames per second
  32187. */
  32188. readonly averageFPS: number;
  32189. /**
  32190. * Returns the average framerate in frames per second using the most recent frame time
  32191. * @return Framerate in frames per second
  32192. */
  32193. readonly instantaneousFPS: number;
  32194. /**
  32195. * Returns true if enough samples have been taken to completely fill the sliding window
  32196. * @return true if saturated
  32197. */
  32198. readonly isSaturated: boolean;
  32199. /**
  32200. * Enables contributions to the sliding window sample set
  32201. */
  32202. enable(): void;
  32203. /**
  32204. * Disables contributions to the sliding window sample set
  32205. * Samples will not be interpolated over the disabled period
  32206. */
  32207. disable(): void;
  32208. /**
  32209. * Returns true if sampling is enabled
  32210. * @return true if enabled
  32211. */
  32212. readonly isEnabled: boolean;
  32213. /**
  32214. * Resets performance monitor
  32215. */
  32216. reset(): void;
  32217. }
  32218. /**
  32219. * RollingAverage
  32220. *
  32221. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32222. */
  32223. class RollingAverage {
  32224. /**
  32225. * Current average
  32226. */
  32227. average: number;
  32228. /**
  32229. * Current variance
  32230. */
  32231. variance: number;
  32232. protected _samples: Array<number>;
  32233. protected _sampleCount: number;
  32234. protected _pos: number;
  32235. protected _m2: number;
  32236. /**
  32237. * constructor
  32238. * @param length The number of samples required to saturate the sliding window
  32239. */
  32240. constructor(length: number);
  32241. /**
  32242. * Adds a sample to the sample set
  32243. * @param v The sample value
  32244. */
  32245. add(v: number): void;
  32246. /**
  32247. * Returns previously added values or null if outside of history or outside the sliding window domain
  32248. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32249. * @return Value previously recorded with add() or null if outside of range
  32250. */
  32251. history(i: number): number;
  32252. /**
  32253. * Returns true if enough samples have been taken to completely fill the sliding window
  32254. * @return true if sample-set saturated
  32255. */
  32256. isSaturated(): boolean;
  32257. /**
  32258. * Resets the rolling average (equivalent to 0 samples taken so far)
  32259. */
  32260. reset(): void;
  32261. /**
  32262. * Wraps a value around the sample range boundaries
  32263. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32264. * @return Wrapped position in sample range
  32265. */
  32266. protected _wrapPosition(i: number): number;
  32267. =======
  32268. * A class serves as a medium between the observable and its observers
  32269. */
  32270. class EventState {
  32271. /**
  32272. * Create a new EventState
  32273. * @param mask defines the mask associated with this state
  32274. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  32275. * @param target defines the original target of the state
  32276. * @param currentTarget defines the current target of the state
  32277. */
  32278. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  32279. /**
  32280. * Initialize the current event state
  32281. * @param mask defines the mask associated with this state
  32282. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  32283. * @param target defines the original target of the state
  32284. * @param currentTarget defines the current target of the state
  32285. * @returns the current event state
  32286. */
  32287. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  32288. /**
  32289. * An Observer can set this property to true to prevent subsequent observers of being notified
  32290. */
  32291. skipNextObservers: boolean;
  32292. /**
  32293. * Get the mask value that were used to trigger the event corresponding to this EventState object
  32294. */
  32295. mask: number;
  32296. /**
  32297. * The object that originally notified the event
  32298. */
  32299. target?: any;
  32300. /**
  32301. * The current object in the bubbling phase
  32302. */
  32303. currentTarget?: any;
  32304. /**
  32305. * This will be populated with the return value of the last function that was executed.
  32306. * If it is the first function in the callback chain it will be the event data.
  32307. */
  32308. lastReturnValue?: any;
  32309. }
  32310. /**
  32311. * Represent an Observer registered to a given Observable object.
  32312. */
  32313. class Observer<T> {
  32314. /**
  32315. * Defines the callback to call when the observer is notified
  32316. */
  32317. callback: (eventData: T, eventState: EventState) => void;
  32318. /**
  32319. * Defines the mask of the observer (used to filter notifications)
  32320. */
  32321. mask: number;
  32322. /**
  32323. * Defines the current scope used to restore the JS context
  32324. */
  32325. scope: any;
  32326. /** @ignore */
  32327. _willBeUnregistered: boolean;
  32328. /**
  32329. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  32330. */
  32331. unregisterOnNextCall: boolean;
  32332. /**
  32333. * Creates a new observer
  32334. * @param callback defines the callback to call when the observer is notified
  32335. * @param mask defines the mask of the observer (used to filter notifications)
  32336. * @param scope defines the current scope used to restore the JS context
  32337. */
  32338. constructor(
  32339. /**
  32340. * Defines the callback to call when the observer is notified
  32341. */
  32342. callback: (eventData: T, eventState: EventState) => void,
  32343. /**
  32344. * Defines the mask of the observer (used to filter notifications)
  32345. */
  32346. mask: number,
  32347. /**
  32348. * Defines the current scope used to restore the JS context
  32349. */
  32350. scope?: any);
  32351. }
  32352. /**
  32353. * Represent a list of observers registered to multiple Observables object.
  32354. */
  32355. class MultiObserver<T> {
  32356. private _observers;
  32357. private _observables;
  32358. /**
  32359. * Release associated resources
  32360. */
  32361. dispose(): void;
  32362. /**
  32363. * Raise a callback when one of the observable will notify
  32364. * @param observables defines a list of observables to watch
  32365. * @param callback defines the callback to call on notification
  32366. * @param mask defines the mask used to filter notifications
  32367. * @param scope defines the current scope used to restore the JS context
  32368. * @returns the new MultiObserver
  32369. */
  32370. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  32371. }
  32372. /**
  32373. * The Observable class is a simple implementation of the Observable pattern.
  32374. * 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.
  32375. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  32376. * 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).
  32377. * 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.
  32378. */
  32379. class Observable<T> {
  32380. private _observers;
  32381. private _eventState;
  32382. private _onObserverAdded;
  32383. /**
  32384. * Creates a new observable
  32385. * @param onObserverAdded defines a callback to call when a new observer is added
  32386. */
  32387. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  32388. /**
  32389. * Create a new Observer with the specified callback
  32390. * @param callback the callback that will be executed for that Observer
  32391. * @param mask the mask used to filter observers
  32392. * @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.
  32393. * @param scope optional scope for the callback to be called from
  32394. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  32395. * @returns the new observer created for the callback
  32396. */
  32397. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  32398. /**
  32399. * Remove an Observer from the Observable object
  32400. * @param observer the instance of the Observer to remove
  32401. * @returns false if it doesn't belong to this Observable
  32402. */
  32403. remove(observer: Nullable<Observer<T>>): boolean;
  32404. /**
  32405. * Remove a callback from the Observable object
  32406. * @param callback the callback to remove
  32407. * @param scope optional scope. If used only the callbacks with this scope will be removed
  32408. * @returns false if it doesn't belong to this Observable
  32409. */
  32410. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  32411. private _deferUnregister(observer);
  32412. /**
  32413. * Notify all Observers by calling their respective callback with the given data
  32414. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  32415. * @param eventData defines the data to send to all observers
  32416. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  32417. * @param target defines the original target of the state
  32418. * @param currentTarget defines the current target of the state
  32419. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  32420. */
  32421. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  32422. /**
  32423. * Calling this will execute each callback, expecting it to be a promise or return a value.
  32424. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  32425. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  32426. * and it is crucial that all callbacks will be executed.
  32427. * The order of the callbacks is kept, callbacks are not executed parallel.
  32428. *
  32429. * @param eventData The data to be sent to each callback
  32430. * @param mask is used to filter observers defaults to -1
  32431. * @param target defines the callback target (see EventState)
  32432. * @param currentTarget defines he current object in the bubbling phase
  32433. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  32434. */
  32435. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  32436. /**
  32437. * Notify a specific observer
  32438. * @param observer defines the observer to notify
  32439. * @param eventData defines the data to be sent to each callback
  32440. * @param mask is used to filter observers defaults to -1
  32441. */
  32442. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  32443. /**
  32444. * Gets a boolean indicating if the observable has at least one observer
  32445. * @returns true is the Observable has at least one Observer registered
  32446. */
  32447. hasObservers(): boolean;
  32448. /**
  32449. * Clear the list of observers
  32450. */
  32451. clear(): void;
  32452. /**
  32453. * Clone the current observable
  32454. * @returns a new observable
  32455. */
  32456. clone(): Observable<T>;
  32457. /**
  32458. * Does this observable handles observer registered with a given mask
  32459. * @param mask defines the mask to be tested
  32460. * @return whether or not one observer registered with the given mask is handeled
  32461. **/
  32462. hasSpecificMask(mask?: number): boolean;
  32463. }
  32464. }
  32465. declare module BABYLON {
  32466. /**
  32467. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32468. */
  32469. class PerformanceMonitor {
  32470. private _enabled;
  32471. private _rollingFrameTime;
  32472. private _lastFrameTimeMs;
  32473. /**
  32474. * constructor
  32475. * @param frameSampleSize The number of samples required to saturate the sliding window
  32476. */
  32477. constructor(frameSampleSize?: number);
  32478. /**
  32479. * Samples current frame
  32480. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32481. */
  32482. sampleFrame(timeMs?: number): void;
  32483. /**
  32484. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32485. * @return Average frame time in milliseconds
  32486. */
  32487. readonly averageFrameTime: number;
  32488. /**
  32489. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32490. * @return Frame time variance in milliseconds squared
  32491. */
  32492. readonly averageFrameTimeVariance: number;
  32493. /**
  32494. * Returns the frame time of the most recent frame
  32495. * @return Frame time in milliseconds
  32496. */
  32497. readonly instantaneousFrameTime: number;
  32498. /**
  32499. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32500. * @return Framerate in frames per second
  32501. */
  32502. readonly averageFPS: number;
  32503. /**
  32504. * Returns the average framerate in frames per second using the most recent frame time
  32505. * @return Framerate in frames per second
  32506. */
  32507. readonly instantaneousFPS: number;
  32508. /**
  32509. * Returns true if enough samples have been taken to completely fill the sliding window
  32510. * @return true if saturated
  32511. */
  32512. readonly isSaturated: boolean;
  32513. /**
  32514. * Enables contributions to the sliding window sample set
  32515. */
  32516. enable(): void;
  32517. /**
  32518. * Disables contributions to the sliding window sample set
  32519. * Samples will not be interpolated over the disabled period
  32520. */
  32521. disable(): void;
  32522. /**
  32523. * Returns true if sampling is enabled
  32524. * @return true if enabled
  32525. */
  32526. readonly isEnabled: boolean;
  32527. /**
  32528. * Resets performance monitor
  32529. */
  32530. reset(): void;
  32531. }
  32532. /**
  32533. * RollingAverage
  32534. *
  32535. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32536. */
  32537. class RollingAverage {
  32538. /**
  32539. * Current average
  32540. */
  32541. average: number;
  32542. /**
  32543. * Current variance
  32544. */
  32545. variance: number;
  32546. protected _samples: Array<number>;
  32547. protected _sampleCount: number;
  32548. protected _pos: number;
  32549. protected _m2: number;
  32550. /**
  32551. * constructor
  32552. * @param length The number of samples required to saturate the sliding window
  32553. */
  32554. constructor(length: number);
  32555. /**
  32556. * Adds a sample to the sample set
  32557. * @param v The sample value
  32558. */
  32559. add(v: number): void;
  32560. /**
  32561. * Returns previously added values or null if outside of history or outside the sliding window domain
  32562. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32563. * @return Value previously recorded with add() or null if outside of range
  32564. */
  32565. history(i: number): number;
  32566. /**
  32567. * Returns true if enough samples have been taken to completely fill the sliding window
  32568. * @return true if sample-set saturated
  32569. */
  32570. isSaturated(): boolean;
  32571. /**
  32572. * Resets the rolling average (equivalent to 0 samples taken so far)
  32573. */
  32574. reset(): void;
  32575. /**
  32576. * Wraps a value around the sample range boundaries
  32577. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32578. * @return Wrapped position in sample range
  32579. */
  32580. protected _wrapPosition(i: number): number;
  32581. }
  32582. }
  32583. declare module BABYLON {
  32584. /**
  32585. * Helper class that provides a small promise polyfill
  32586. */
  32587. class PromisePolyfill {
  32588. /**
  32589. * Static function used to check if the polyfill is required
  32590. * If this is the case then the function will inject the polyfill to window.Promise
  32591. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32592. */
  32593. static Apply(force?: boolean): void;
  32594. }
  32595. }
  32596. declare module BABYLON {
  32597. /**
  32598. * Defines the root class used to create scene optimization to use with SceneOptimizer
  32599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32600. */
  32601. class SceneOptimization {
  32602. /**
  32603. * Defines the priority of this optimization (0 by default which means first in the list)
  32604. */
  32605. priority: number;
  32606. /**
  32607. * Gets a string describing the action executed by the current optimization
  32608. * @returns description string
  32609. */
  32610. getDescription(): string;
  32611. /**
  32612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32613. * @param scene defines the current scene where to apply this optimization
  32614. * @param optimizer defines the current optimizer
  32615. * @returns true if everything that can be done was applied
  32616. */
  32617. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32618. /**
  32619. * Creates the SceneOptimization object
  32620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  32621. * @param desc defines the description associated with the optimization
  32622. */
  32623. constructor(
  32624. /**
  32625. * Defines the priority of this optimization (0 by default which means first in the list)
  32626. */
  32627. priority?: number);
  32628. }
  32629. /**
  32630. * Defines an optimization used to reduce the size of render target textures
  32631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32632. */
  32633. class TextureOptimization extends SceneOptimization {
  32634. /**
  32635. * Defines the priority of this optimization (0 by default which means first in the list)
  32636. */
  32637. priority: number;
  32638. /**
  32639. * 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
  32640. */
  32641. maximumSize: number;
  32642. /**
  32643. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  32644. */
  32645. step: number;
  32646. /**
  32647. * Gets a string describing the action executed by the current optimization
  32648. * @returns description string
  32649. */
  32650. getDescription(): string;
  32651. /**
  32652. * Creates the TextureOptimization object
  32653. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  32654. * @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
  32655. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  32656. */
  32657. constructor(
  32658. /**
  32659. * Defines the priority of this optimization (0 by default which means first in the list)
  32660. */
  32661. priority?: number,
  32662. /**
  32663. * 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
  32664. */
  32665. maximumSize?: number,
  32666. /**
  32667. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  32668. */
  32669. step?: number);
  32670. /**
  32671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32672. * @param scene defines the current scene where to apply this optimization
  32673. * @param optimizer defines the current optimizer
  32674. * @returns true if everything that can be done was applied
  32675. */
  32676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32677. }
  32678. /**
  32679. * Defines an optimization used to increase or decrease the rendering resolution
  32680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32681. */
  32682. class HardwareScalingOptimization extends SceneOptimization {
  32683. /**
  32684. * Defines the priority of this optimization (0 by default which means first in the list)
  32685. */
  32686. priority: number;
  32687. /**
  32688. * Defines the maximum scale to use (2 by default)
  32689. */
  32690. maximumScale: number;
  32691. /**
  32692. * Defines the step to use between two passes (0.5 by default)
  32693. */
  32694. step: number;
  32695. private _currentScale;
  32696. private _directionOffset;
  32697. /**
  32698. * Gets a string describing the action executed by the current optimization
  32699. * @return description string
  32700. */
  32701. getDescription(): string;
  32702. /**
  32703. * Creates the HardwareScalingOptimization object
  32704. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  32705. * @param maximumScale defines the maximum scale to use (2 by default)
  32706. * @param step defines the step to use between two passes (0.5 by default)
  32707. */
  32708. constructor(
  32709. /**
  32710. * Defines the priority of this optimization (0 by default which means first in the list)
  32711. */
  32712. priority?: number,
  32713. /**
  32714. * Defines the maximum scale to use (2 by default)
  32715. */
  32716. maximumScale?: number,
  32717. /**
  32718. * Defines the step to use between two passes (0.5 by default)
  32719. */
  32720. step?: number);
  32721. /**
  32722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32723. * @param scene defines the current scene where to apply this optimization
  32724. * @param optimizer defines the current optimizer
  32725. * @returns true if everything that can be done was applied
  32726. */
  32727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32728. }
  32729. /**
  32730. * Defines an optimization used to remove shadows
  32731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32732. */
  32733. class ShadowsOptimization extends SceneOptimization {
  32734. /**
  32735. * Gets a string describing the action executed by the current optimization
  32736. * @return description string
  32737. */
  32738. getDescription(): string;
  32739. /**
  32740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32741. * @param scene defines the current scene where to apply this optimization
  32742. * @param optimizer defines the current optimizer
  32743. * @returns true if everything that can be done was applied
  32744. */
  32745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32746. }
  32747. /**
  32748. * Defines an optimization used to turn post-processes off
  32749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32750. */
  32751. class PostProcessesOptimization extends SceneOptimization {
  32752. /**
  32753. * Gets a string describing the action executed by the current optimization
  32754. * @return description string
  32755. */
  32756. getDescription(): string;
  32757. /**
  32758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32759. * @param scene defines the current scene where to apply this optimization
  32760. * @param optimizer defines the current optimizer
  32761. * @returns true if everything that can be done was applied
  32762. */
  32763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32764. }
  32765. /**
  32766. * Defines an optimization used to turn lens flares off
  32767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32768. */
  32769. class LensFlaresOptimization extends SceneOptimization {
  32770. /**
  32771. * Gets a string describing the action executed by the current optimization
  32772. * @return description string
  32773. */
  32774. getDescription(): string;
  32775. /**
  32776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32777. * @param scene defines the current scene where to apply this optimization
  32778. * @param optimizer defines the current optimizer
  32779. * @returns true if everything that can be done was applied
  32780. */
  32781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32782. }
  32783. /**
  32784. * Defines an optimization based on user defined callback.
  32785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32786. */
  32787. class CustomOptimization extends SceneOptimization {
  32788. /**
  32789. * Callback called to apply the custom optimization.
  32790. */
  32791. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  32792. /**
  32793. * Callback called to get custom description
  32794. */
  32795. onGetDescription: () => string;
  32796. /**
  32797. * Gets a string describing the action executed by the current optimization
  32798. * @returns description string
  32799. */
  32800. getDescription(): string;
  32801. /**
  32802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32803. * @param scene defines the current scene where to apply this optimization
  32804. * @param optimizer defines the current optimizer
  32805. * @returns true if everything that can be done was applied
  32806. */
  32807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32808. }
  32809. /**
  32810. * Defines an optimization used to turn particles off
  32811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32812. */
  32813. class ParticlesOptimization extends SceneOptimization {
  32814. /**
  32815. * Gets a string describing the action executed by the current optimization
  32816. * @return description string
  32817. */
  32818. getDescription(): string;
  32819. /**
  32820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32821. * @param scene defines the current scene where to apply this optimization
  32822. * @param optimizer defines the current optimizer
  32823. * @returns true if everything that can be done was applied
  32824. */
  32825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32826. }
  32827. /**
  32828. * Defines an optimization used to turn render targets off
  32829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32830. */
  32831. class RenderTargetsOptimization extends SceneOptimization {
  32832. /**
  32833. * Gets a string describing the action executed by the current optimization
  32834. * @return description string
  32835. */
  32836. getDescription(): string;
  32837. /**
  32838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32839. * @param scene defines the current scene where to apply this optimization
  32840. * @param optimizer defines the current optimizer
  32841. * @returns true if everything that can be done was applied
  32842. */
  32843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  32844. }
  32845. /**
  32846. * Defines an optimization used to merge meshes with compatible materials
  32847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32848. */
  32849. class MergeMeshesOptimization extends SceneOptimization {
  32850. private static _UpdateSelectionTree;
  32851. /**
  32852. * Gets or sets a boolean which defines if optimization octree has to be updated
  32853. */
  32854. /**
  32855. * Gets or sets a boolean which defines if optimization octree has to be updated
  32856. */
  32857. static UpdateSelectionTree: boolean;
  32858. /**
  32859. * Gets a string describing the action executed by the current optimization
  32860. * @return description string
  32861. */
  32862. getDescription(): string;
  32863. private _canBeMerged;
  32864. /**
  32865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  32866. * @param scene defines the current scene where to apply this optimization
  32867. * @param optimizer defines the current optimizer
  32868. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  32869. * @returns true if everything that can be done was applied
  32870. */
  32871. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  32872. }
  32873. /**
  32874. * Defines a list of options used by SceneOptimizer
  32875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32876. */
  32877. class SceneOptimizerOptions {
  32878. /**
  32879. * Defines the target frame rate to reach (60 by default)
  32880. */
  32881. targetFrameRate: number;
  32882. /**
  32883. * Defines the interval between two checkes (2000ms by default)
  32884. */
  32885. trackerDuration: number;
  32886. /**
  32887. * Gets the list of optimizations to apply
  32888. */
  32889. optimizations: SceneOptimization[];
  32890. /**
  32891. * Creates a new list of options used by SceneOptimizer
  32892. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  32893. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  32894. */
  32895. constructor(
  32896. /**
  32897. * Defines the target frame rate to reach (60 by default)
  32898. */
  32899. targetFrameRate?: number,
  32900. /**
  32901. * Defines the interval between two checkes (2000ms by default)
  32902. */
  32903. trackerDuration?: number);
  32904. /**
  32905. * Add a new optimization
  32906. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  32907. * @returns the current SceneOptimizerOptions
  32908. */
  32909. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  32910. /**
  32911. * Add a new custom optimization
  32912. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  32913. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  32914. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  32915. * @returns the current SceneOptimizerOptions
  32916. */
  32917. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  32918. /**
  32919. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  32920. * @param targetFrameRate defines the target frame rate (60 by default)
  32921. * @returns a SceneOptimizerOptions object
  32922. */
  32923. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  32924. /**
  32925. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  32926. * @param targetFrameRate defines the target frame rate (60 by default)
  32927. * @returns a SceneOptimizerOptions object
  32928. */
  32929. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  32930. /**
  32931. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  32932. * @param targetFrameRate defines the target frame rate (60 by default)
  32933. * @returns a SceneOptimizerOptions object
  32934. */
  32935. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  32936. }
  32937. /**
  32938. * Class used to run optimizations in order to reach a target frame rate
  32939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  32940. */
  32941. class SceneOptimizer implements IDisposable {
  32942. private _isRunning;
  32943. private _options;
  32944. private _scene;
  32945. private _currentPriorityLevel;
  32946. private _targetFrameRate;
  32947. private _trackerDuration;
  32948. private _currentFrameRate;
  32949. private _sceneDisposeObserver;
  32950. private _improvementMode;
  32951. /**
  32952. * Defines an observable called when the optimizer reaches the target frame rate
  32953. */
  32954. onSuccessObservable: Observable<SceneOptimizer>;
  32955. /**
  32956. * Defines an observable called when the optimizer enables an optimization
  32957. */
  32958. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  32959. /**
  32960. * Defines an observable called when the optimizer is not able to reach the target frame rate
  32961. */
  32962. onFailureObservable: Observable<SceneOptimizer>;
  32963. /**
  32964. * Gets a boolean indicating if the optimizer is in improvement mode
  32965. */
  32966. readonly isInImprovementMode: boolean;
  32967. /**
  32968. * Gets the current priority level (0 at start)
  32969. */
  32970. readonly currentPriorityLevel: number;
  32971. /**
  32972. * Gets the current frame rate checked by the SceneOptimizer
  32973. */
  32974. readonly currentFrameRate: number;
  32975. /**
  32976. * Gets or sets the current target frame rate (60 by default)
  32977. */
  32978. /**
  32979. * Gets or sets the current target frame rate (60 by default)
  32980. */
  32981. targetFrameRate: number;
  32982. /**
  32983. * Gets or sets the current interval between two checks (every 2000ms by default)
  32984. */
  32985. /**
  32986. * Gets or sets the current interval between two checks (every 2000ms by default)
  32987. */
  32988. trackerDuration: number;
  32989. /**
  32990. * Gets the list of active optimizations
  32991. */
  32992. readonly optimizations: SceneOptimization[];
  32993. /**
  32994. * Creates a new SceneOptimizer
  32995. * @param scene defines the scene to work on
  32996. * @param options defines the options to use with the SceneOptimizer
  32997. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  32998. * @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)
  32999. */
  33000. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  33001. /**
  33002. * Stops the current optimizer
  33003. */
  33004. stop(): void;
  33005. /**
  33006. * Reset the optimizer to initial step (current priority level = 0)
  33007. */
  33008. reset(): void;
  33009. /**
  33010. * Start the optimizer. By default it will try to reach a specific framerate
  33011. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  33012. */
  33013. start(): void;
  33014. private _checkCurrentState();
  33015. /**
  33016. * Release all resources
  33017. */
  33018. dispose(): void;
  33019. /**
  33020. * Helper function to create a SceneOptimizer with one single line of code
  33021. * @param scene defines the scene to work on
  33022. * @param options defines the options to use with the SceneOptimizer
  33023. * @param onSuccess defines a callback to call on success
  33024. * @param onFailure defines a callback to call on failure
  33025. * @returns the new SceneOptimizer object
  33026. */
  33027. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  33028. }
  33029. }
  33030. declare module BABYLON {
  33031. class SceneSerializer {
  33032. static ClearCache(): void;
  33033. static Serialize(scene: Scene): any;
  33034. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  33035. }
  33036. }
  33037. declare module BABYLON {
  33038. class SmartArray<T> {
  33039. data: Array<T>;
  33040. length: number;
  33041. protected _id: number;
  33042. [index: number]: T;
  33043. constructor(capacity: number);
  33044. push(value: T): void;
  33045. forEach(func: (content: T) => void): void;
  33046. sort(compareFn: (a: T, b: T) => number): void;
  33047. reset(): void;
  33048. dispose(): void;
  33049. concat(array: any): void;
  33050. indexOf(value: T): number;
  33051. contains(value: T): boolean;
  33052. private static _GlobalId;
  33053. }
  33054. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  33055. private _duplicateId;
  33056. [index: number]: T;
  33057. push(value: T): void;
  33058. pushNoDuplicate(value: T): boolean;
  33059. reset(): void;
  33060. concatWithNoDuplicate(array: any): void;
  33061. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  33062. }
  33063. }
  33064. declare module BABYLON {
  33065. /**
  33066. <<<<<<< HEAD
  33067. * Helper class that provides a small promise polyfill
  33068. */
  33069. class PromisePolyfill {
  33070. /**
  33071. * Static function used to check if the polyfill is required
  33072. * If this is the case then the function will inject the polyfill to window.Promise
  33073. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33074. */
  33075. static Apply(force?: boolean): void;
  33076. }
  33077. }
  33078. declare module BABYLON {
  33079. /**
  33080. * Defines the root class used to create scene optimization to use with SceneOptimizer
  33081. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33082. */
  33083. class SceneOptimization {
  33084. /**
  33085. * Defines the priority of this optimization (0 by default which means first in the list)
  33086. */
  33087. priority: number;
  33088. /**
  33089. * Gets a string describing the action executed by the current optimization
  33090. * @returns description string
  33091. */
  33092. getDescription(): string;
  33093. /**
  33094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33095. * @param scene defines the current scene where to apply this optimization
  33096. * @param optimizer defines the current optimizer
  33097. * @returns true if everything that can be done was applied
  33098. */
  33099. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33100. /**
  33101. * Creates the SceneOptimization object
  33102. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  33103. * @param desc defines the description associated with the optimization
  33104. */
  33105. constructor(
  33106. /**
  33107. * Defines the priority of this optimization (0 by default which means first in the list)
  33108. */
  33109. priority?: number);
  33110. }
  33111. /**
  33112. * Defines an optimization used to reduce the size of render target textures
  33113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33114. */
  33115. class TextureOptimization extends SceneOptimization {
  33116. /**
  33117. * Defines the priority of this optimization (0 by default which means first in the list)
  33118. */
  33119. priority: number;
  33120. /**
  33121. * 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
  33122. */
  33123. maximumSize: number;
  33124. /**
  33125. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  33126. */
  33127. step: number;
  33128. /**
  33129. * Gets a string describing the action executed by the current optimization
  33130. * @returns description string
  33131. */
  33132. getDescription(): string;
  33133. /**
  33134. * Creates the TextureOptimization object
  33135. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  33136. * @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
  33137. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  33138. */
  33139. constructor(
  33140. /**
  33141. * Defines the priority of this optimization (0 by default which means first in the list)
  33142. */
  33143. priority?: number,
  33144. /**
  33145. * 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
  33146. */
  33147. maximumSize?: number,
  33148. /**
  33149. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  33150. */
  33151. step?: number);
  33152. /**
  33153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33154. * @param scene defines the current scene where to apply this optimization
  33155. * @param optimizer defines the current optimizer
  33156. * @returns true if everything that can be done was applied
  33157. */
  33158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33159. }
  33160. /**
  33161. * Defines an optimization used to increase or decrease the rendering resolution
  33162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33163. */
  33164. class HardwareScalingOptimization extends SceneOptimization {
  33165. /**
  33166. * Defines the priority of this optimization (0 by default which means first in the list)
  33167. */
  33168. priority: number;
  33169. /**
  33170. * Defines the maximum scale to use (2 by default)
  33171. */
  33172. maximumScale: number;
  33173. /**
  33174. * Defines the step to use between two passes (0.5 by default)
  33175. */
  33176. step: number;
  33177. private _currentScale;
  33178. private _directionOffset;
  33179. /**
  33180. * Gets a string describing the action executed by the current optimization
  33181. * @return description string
  33182. */
  33183. getDescription(): string;
  33184. /**
  33185. * Creates the HardwareScalingOptimization object
  33186. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  33187. * @param maximumScale defines the maximum scale to use (2 by default)
  33188. * @param step defines the step to use between two passes (0.5 by default)
  33189. */
  33190. constructor(
  33191. /**
  33192. * Defines the priority of this optimization (0 by default which means first in the list)
  33193. */
  33194. priority?: number,
  33195. /**
  33196. * Defines the maximum scale to use (2 by default)
  33197. */
  33198. maximumScale?: number,
  33199. /**
  33200. * Defines the step to use between two passes (0.5 by default)
  33201. */
  33202. step?: number);
  33203. /**
  33204. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33205. * @param scene defines the current scene where to apply this optimization
  33206. * @param optimizer defines the current optimizer
  33207. * @returns true if everything that can be done was applied
  33208. */
  33209. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33210. }
  33211. /**
  33212. * Defines an optimization used to remove shadows
  33213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33214. */
  33215. class ShadowsOptimization extends SceneOptimization {
  33216. /**
  33217. * Gets a string describing the action executed by the current optimization
  33218. * @return description string
  33219. */
  33220. getDescription(): string;
  33221. /**
  33222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33223. * @param scene defines the current scene where to apply this optimization
  33224. * @param optimizer defines the current optimizer
  33225. * @returns true if everything that can be done was applied
  33226. */
  33227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33228. }
  33229. /**
  33230. * Defines an optimization used to turn post-processes off
  33231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33232. */
  33233. class PostProcessesOptimization extends SceneOptimization {
  33234. /**
  33235. * Gets a string describing the action executed by the current optimization
  33236. * @return description string
  33237. */
  33238. getDescription(): string;
  33239. /**
  33240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33241. * @param scene defines the current scene where to apply this optimization
  33242. * @param optimizer defines the current optimizer
  33243. * @returns true if everything that can be done was applied
  33244. */
  33245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33246. }
  33247. /**
  33248. * Defines an optimization used to turn lens flares off
  33249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33250. */
  33251. class LensFlaresOptimization extends SceneOptimization {
  33252. /**
  33253. * Gets a string describing the action executed by the current optimization
  33254. * @return description string
  33255. */
  33256. getDescription(): string;
  33257. /**
  33258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33259. * @param scene defines the current scene where to apply this optimization
  33260. * @param optimizer defines the current optimizer
  33261. * @returns true if everything that can be done was applied
  33262. */
  33263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33264. }
  33265. /**
  33266. * Defines an optimization based on user defined callback.
  33267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33268. */
  33269. class CustomOptimization extends SceneOptimization {
  33270. /**
  33271. * Callback called to apply the custom optimization.
  33272. */
  33273. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  33274. /**
  33275. * Callback called to get custom description
  33276. */
  33277. onGetDescription: () => string;
  33278. /**
  33279. * Gets a string describing the action executed by the current optimization
  33280. * @returns description string
  33281. */
  33282. getDescription(): string;
  33283. /**
  33284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33285. * @param scene defines the current scene where to apply this optimization
  33286. * @param optimizer defines the current optimizer
  33287. * @returns true if everything that can be done was applied
  33288. */
  33289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33290. }
  33291. /**
  33292. * Defines an optimization used to turn particles off
  33293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33294. */
  33295. class ParticlesOptimization extends SceneOptimization {
  33296. /**
  33297. * Gets a string describing the action executed by the current optimization
  33298. * @return description string
  33299. */
  33300. getDescription(): string;
  33301. /**
  33302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33303. * @param scene defines the current scene where to apply this optimization
  33304. * @param optimizer defines the current optimizer
  33305. * @returns true if everything that can be done was applied
  33306. */
  33307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33308. }
  33309. /**
  33310. * Defines an optimization used to turn render targets off
  33311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33312. */
  33313. class RenderTargetsOptimization extends SceneOptimization {
  33314. /**
  33315. * Gets a string describing the action executed by the current optimization
  33316. * @return description string
  33317. */
  33318. getDescription(): string;
  33319. /**
  33320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33321. * @param scene defines the current scene where to apply this optimization
  33322. * @param optimizer defines the current optimizer
  33323. * @returns true if everything that can be done was applied
  33324. */
  33325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  33326. }
  33327. /**
  33328. * Defines an optimization used to merge meshes with compatible materials
  33329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33330. */
  33331. class MergeMeshesOptimization extends SceneOptimization {
  33332. private static _UpdateSelectionTree;
  33333. /**
  33334. * Gets or sets a boolean which defines if optimization octree has to be updated
  33335. */
  33336. /**
  33337. * Gets or sets a boolean which defines if optimization octree has to be updated
  33338. */
  33339. static UpdateSelectionTree: boolean;
  33340. /**
  33341. * Gets a string describing the action executed by the current optimization
  33342. * @return description string
  33343. */
  33344. getDescription(): string;
  33345. private _canBeMerged;
  33346. /**
  33347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  33348. * @param scene defines the current scene where to apply this optimization
  33349. * @param optimizer defines the current optimizer
  33350. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  33351. * @returns true if everything that can be done was applied
  33352. */
  33353. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  33354. }
  33355. /**
  33356. * Defines a list of options used by SceneOptimizer
  33357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33358. */
  33359. class SceneOptimizerOptions {
  33360. /**
  33361. * Defines the target frame rate to reach (60 by default)
  33362. */
  33363. targetFrameRate: number;
  33364. /**
  33365. * Defines the interval between two checkes (2000ms by default)
  33366. */
  33367. trackerDuration: number;
  33368. /**
  33369. * Gets the list of optimizations to apply
  33370. */
  33371. optimizations: SceneOptimization[];
  33372. /**
  33373. * Creates a new list of options used by SceneOptimizer
  33374. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  33375. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  33376. */
  33377. constructor(
  33378. /**
  33379. * Defines the target frame rate to reach (60 by default)
  33380. */
  33381. targetFrameRate?: number,
  33382. /**
  33383. * Defines the interval between two checkes (2000ms by default)
  33384. */
  33385. trackerDuration?: number);
  33386. /**
  33387. * Add a new optimization
  33388. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  33389. * @returns the current SceneOptimizerOptions
  33390. */
  33391. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  33392. /**
  33393. * Add a new custom optimization
  33394. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  33395. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  33396. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  33397. * @returns the current SceneOptimizerOptions
  33398. */
  33399. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  33400. /**
  33401. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  33402. * @param targetFrameRate defines the target frame rate (60 by default)
  33403. * @returns a SceneOptimizerOptions object
  33404. */
  33405. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  33406. /**
  33407. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  33408. * @param targetFrameRate defines the target frame rate (60 by default)
  33409. * @returns a SceneOptimizerOptions object
  33410. */
  33411. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  33412. /**
  33413. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  33414. * @param targetFrameRate defines the target frame rate (60 by default)
  33415. * @returns a SceneOptimizerOptions object
  33416. */
  33417. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  33418. }
  33419. /**
  33420. * Class used to run optimizations in order to reach a target frame rate
  33421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33422. */
  33423. class SceneOptimizer implements IDisposable {
  33424. private _isRunning;
  33425. private _options;
  33426. private _scene;
  33427. private _currentPriorityLevel;
  33428. private _targetFrameRate;
  33429. private _trackerDuration;
  33430. private _currentFrameRate;
  33431. private _sceneDisposeObserver;
  33432. private _improvementMode;
  33433. /**
  33434. * Defines an observable called when the optimizer reaches the target frame rate
  33435. */
  33436. onSuccessObservable: Observable<SceneOptimizer>;
  33437. /**
  33438. * Defines an observable called when the optimizer enables an optimization
  33439. */
  33440. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  33441. /**
  33442. * Defines an observable called when the optimizer is not able to reach the target frame rate
  33443. */
  33444. onFailureObservable: Observable<SceneOptimizer>;
  33445. /**
  33446. * Gets a boolean indicating if the optimizer is in improvement mode
  33447. */
  33448. readonly isInImprovementMode: boolean;
  33449. /**
  33450. * Gets the current priority level (0 at start)
  33451. */
  33452. readonly currentPriorityLevel: number;
  33453. /**
  33454. * Gets the current frame rate checked by the SceneOptimizer
  33455. */
  33456. readonly currentFrameRate: number;
  33457. /**
  33458. * Gets or sets the current target frame rate (60 by default)
  33459. */
  33460. /**
  33461. * Gets or sets the current target frame rate (60 by default)
  33462. */
  33463. targetFrameRate: number;
  33464. /**
  33465. * Gets or sets the current interval between two checks (every 2000ms by default)
  33466. */
  33467. /**
  33468. * Gets or sets the current interval between two checks (every 2000ms by default)
  33469. */
  33470. trackerDuration: number;
  33471. /**
  33472. * Gets the list of active optimizations
  33473. */
  33474. readonly optimizations: SceneOptimization[];
  33475. /**
  33476. * Creates a new SceneOptimizer
  33477. * @param scene defines the scene to work on
  33478. * @param options defines the options to use with the SceneOptimizer
  33479. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  33480. * @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)
  33481. */
  33482. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  33483. /**
  33484. * Stops the current optimizer
  33485. */
  33486. stop(): void;
  33487. /**
  33488. * Reset the optimizer to initial step (current priority level = 0)
  33489. */
  33490. reset(): void;
  33491. /**
  33492. * Start the optimizer. By default it will try to reach a specific framerate
  33493. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  33494. */
  33495. start(): void;
  33496. private _checkCurrentState();
  33497. /**
  33498. * Release all resources
  33499. */
  33500. dispose(): void;
  33501. /**
  33502. * Helper function to create a SceneOptimizer with one single line of code
  33503. * @param scene defines the scene to work on
  33504. * @param options defines the options to use with the SceneOptimizer
  33505. * @param onSuccess defines a callback to call on success
  33506. * @param onFailure defines a callback to call on failure
  33507. * @returns the new SceneOptimizer object
  33508. */
  33509. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  33510. =======
  33511. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33512. * The underlying implementation relies on an associative array to ensure the best performances.
  33513. * The value can be anything including 'null' but except 'undefined'
  33514. */
  33515. class StringDictionary<T> {
  33516. /**
  33517. * This will clear this dictionary and copy the content from the 'source' one.
  33518. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33519. * @param source the dictionary to take the content from and copy to this dictionary
  33520. */
  33521. copyFrom(source: StringDictionary<T>): void;
  33522. /**
  33523. * Get a value based from its key
  33524. * @param key the given key to get the matching value from
  33525. * @return the value if found, otherwise undefined is returned
  33526. */
  33527. get(key: string): T | undefined;
  33528. /**
  33529. * Get a value from its key or add it if it doesn't exist.
  33530. * This method will ensure you that a given key/data will be present in the dictionary.
  33531. * @param key the given key to get the matching value from
  33532. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33533. * The factory will only be invoked if there's no data for the given key.
  33534. * @return the value corresponding to the key.
  33535. */
  33536. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33537. /**
  33538. * Get a value from its key if present in the dictionary otherwise add it
  33539. * @param key the key to get the value from
  33540. * @param val if there's no such key/value pair in the dictionary add it with this value
  33541. * @return the value corresponding to the key
  33542. */
  33543. getOrAdd(key: string, val: T): T;
  33544. /**
  33545. * Check if there's a given key in the dictionary
  33546. * @param key the key to check for
  33547. * @return true if the key is present, false otherwise
  33548. */
  33549. contains(key: string): boolean;
  33550. /**
  33551. * Add a new key and its corresponding value
  33552. * @param key the key to add
  33553. * @param value the value corresponding to the key
  33554. * @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
  33555. */
  33556. add(key: string, value: T): boolean;
  33557. set(key: string, value: T): boolean;
  33558. /**
  33559. * Get the element of the given key and remove it from the dictionary
  33560. * @param key
  33561. */
  33562. getAndRemove(key: string): Nullable<T>;
  33563. /**
  33564. * Remove a key/value from the dictionary.
  33565. * @param key the key to remove
  33566. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33567. */
  33568. remove(key: string): boolean;
  33569. /**
  33570. * Clear the whole content of the dictionary
  33571. */
  33572. clear(): void;
  33573. readonly count: number;
  33574. /**
  33575. * Execute a callback on each key/val of the dictionary.
  33576. * Note that you can remove any element in this dictionary in the callback implementation
  33577. * @param callback the callback to execute on a given key/value pair
  33578. */
  33579. forEach(callback: (key: string, val: T) => void): void;
  33580. /**
  33581. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33582. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33583. * Note that you can remove any element in this dictionary in the callback implementation
  33584. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33585. */
  33586. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33587. private _count;
  33588. private _data;
  33589. }
  33590. }
  33591. declare module BABYLON {
  33592. class Tags {
  33593. static EnableFor(obj: any): void;
  33594. static DisableFor(obj: any): void;
  33595. static HasTags(obj: any): boolean;
  33596. static GetTags(obj: any, asString?: boolean): any;
  33597. static AddTagsTo(obj: any, tagsString: string): void;
  33598. static _AddTagTo(obj: any, tag: string): void;
  33599. static RemoveTagsFrom(obj: any, tagsString: string): void;
  33600. static _RemoveTagFrom(obj: any, tag: string): void;
  33601. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  33602. }
  33603. }
  33604. declare module BABYLON {
  33605. class TextureTools {
  33606. /**
  33607. * Uses the GPU to create a copy texture rescaled at a given size
  33608. * @param texture Texture to copy from
  33609. * @param width Desired width
  33610. * @param height Desired height
  33611. * @return Generated texture
  33612. */
  33613. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  33614. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  33615. private static _environmentBRDFBase64Texture;
  33616. }
  33617. }
  33618. declare module BABYLON {
  33619. class TGATools {
  33620. private static _TYPE_INDEXED;
  33621. private static _TYPE_RGB;
  33622. private static _TYPE_GREY;
  33623. private static _TYPE_RLE_INDEXED;
  33624. private static _TYPE_RLE_RGB;
  33625. private static _TYPE_RLE_GREY;
  33626. private static _ORIGIN_MASK;
  33627. private static _ORIGIN_SHIFT;
  33628. private static _ORIGIN_BL;
  33629. private static _ORIGIN_BR;
  33630. private static _ORIGIN_UL;
  33631. private static _ORIGIN_UR;
  33632. static GetTGAHeader(data: Uint8Array): any;
  33633. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  33634. 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;
  33635. 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;
  33636. 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;
  33637. 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;
  33638. 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;
  33639. 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;
  33640. }
  33641. }
  33642. declare module BABYLON {
  33643. interface IAnimatable {
  33644. animations: Array<Animation>;
  33645. }
  33646. class LoadFileError extends Error {
  33647. request: XMLHttpRequest | undefined;
  33648. private static _setPrototypeOf;
  33649. constructor(message: string, request?: XMLHttpRequest | undefined);
  33650. }
  33651. class RetryStrategy {
  33652. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  33653. }
  33654. interface IFileRequest {
  33655. /**
  33656. * Raised when the request is complete (success or error).
  33657. */
  33658. onCompleteObservable: Observable<IFileRequest>;
  33659. /**
  33660. * Aborts the request for a file.
  33661. */
  33662. abort: () => void;
  33663. }
  33664. class Tools {
  33665. static BaseUrl: string;
  33666. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  33667. /**
  33668. * Default behaviour for cors in the application.
  33669. * It can be a string if the expected behavior is identical in the entire app.
  33670. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33671. */
  33672. static CorsBehavior: string | ((url: string | string[]) => string);
  33673. static UseFallbackTexture: boolean;
  33674. /**
  33675. * Use this object to register external classes like custom textures or material
  33676. * to allow the laoders to instantiate them
  33677. */
  33678. static RegisteredExternalClasses: {
  33679. [key: string]: Object;
  33680. };
  33681. static fallbackTexture: string;
  33682. /**
  33683. * Interpolates between a and b via alpha
  33684. * @param a The lower value (returned when alpha = 0)
  33685. * @param b The upper value (returned when alpha = 1)
  33686. * @param alpha The interpolation-factor
  33687. * @return The mixed value
  33688. */
  33689. static Mix(a: number, b: number, alpha: number): number;
  33690. static Instantiate(className: string): any;
  33691. /**
  33692. * Provides a slice function that will work even on IE
  33693. * @param data defines the array to slice
  33694. * @returns the new sliced array
  33695. */
  33696. static Slice(data: FloatArray): FloatArray;
  33697. static SetImmediate(action: () => void): void;
  33698. static IsExponentOfTwo(value: number): boolean;
  33699. /**
  33700. * Find the next highest power of two.
  33701. * @param x Number to start search from.
  33702. * @return Next highest power of two.
  33703. */
  33704. static CeilingPOT(x: number): number;
  33705. /**
  33706. * Find the next lowest power of two.
  33707. * @param x Number to start search from.
  33708. * @return Next lowest power of two.
  33709. */
  33710. static FloorPOT(x: number): number;
  33711. /**
  33712. * Find the nearest power of two.
  33713. * @param x Number to start search from.
  33714. * @return Next nearest power of two.
  33715. */
  33716. static NearestPOT(x: number): number;
  33717. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33718. static GetFilename(path: string): string;
  33719. /**
  33720. * Extracts the "folder" part of a path (everything before the filename).
  33721. * @param uri The URI to extract the info from
  33722. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33723. * @returns The "folder" part of the path
  33724. */
  33725. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33726. static GetDOMTextContent(element: HTMLElement): string;
  33727. static ToDegrees(angle: number): number;
  33728. static ToRadians(angle: number): number;
  33729. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  33730. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  33731. minimum: Vector3;
  33732. maximum: Vector3;
  33733. };
  33734. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  33735. minimum: Vector3;
  33736. maximum: Vector3;
  33737. };
  33738. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  33739. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  33740. minimum: Vector2;
  33741. maximum: Vector2;
  33742. };
  33743. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33744. static GetPointerPrefix(): string;
  33745. /**
  33746. * @param func - the function to be called
  33747. * @param requester - the object that will request the next frame. Falls back to window.
  33748. */
  33749. static QueueNewFrame(func: () => void, requester?: any): number;
  33750. static RequestFullscreen(element: HTMLElement): void;
  33751. static ExitFullscreen(): void;
  33752. static SetCorsBehavior(url: string | string[], element: {
  33753. crossOrigin: string | null;
  33754. }): void;
  33755. static CleanUrl(url: string): string;
  33756. static PreprocessUrl: (url: string) => string;
  33757. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  33758. 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;
  33759. /**
  33760. * Load a script (identified by an url). When the url returns, the
  33761. * content of this file is added into a new script element, attached to the DOM (body element)
  33762. */
  33763. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  33764. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  33765. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33766. static FileAsURL(content: string): string;
  33767. static Format(value: number, decimals?: number): string;
  33768. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  33769. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33770. static IsEmpty(obj: any): boolean;
  33771. static RegisterTopRootEvents(events: {
  33772. name: string;
  33773. handler: Nullable<(e: FocusEvent) => any>;
  33774. }[]): void;
  33775. static UnregisterTopRootEvents(events: {
  33776. name: string;
  33777. handler: Nullable<(e: FocusEvent) => any>;
  33778. }[]): void;
  33779. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33780. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33781. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  33782. /**
  33783. * Generates an image screenshot from the specified camera.
  33784. *
  33785. * @param engine The engine to use for rendering
  33786. * @param camera The camera to use for rendering
  33787. * @param size This parameter can be set to a single number or to an object with the
  33788. * following (optional) properties: precision, width, height. If a single number is passed,
  33789. * it will be used for both width and height. If an object is passed, the screenshot size
  33790. * will be derived from the parameters. The precision property is a multiplier allowing
  33791. * rendering at a higher or lower resolution.
  33792. * @param successCallback The callback receives a single parameter which contains the
  33793. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33794. * src parameter of an <img> to display it.
  33795. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33796. * Check your browser for supported MIME types.
  33797. * @param samples Texture samples (default: 1)
  33798. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33799. * @param fileName A name for for the downloaded file.
  33800. * @constructor
  33801. */
  33802. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33803. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  33804. /**
  33805. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33806. * Be aware Math.random() could cause collisions, but:
  33807. * "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"
  33808. */
  33809. static RandomId(): string;
  33810. /**
  33811. * Test if the given uri is a base64 string.
  33812. * @param uri The uri to test
  33813. * @return True if the uri is a base64 string or false otherwise.
  33814. */
  33815. static IsBase64(uri: string): boolean;
  33816. /**
  33817. * Decode the given base64 uri.
  33818. * @param uri The uri to decode
  33819. * @return The decoded base64 data.
  33820. */
  33821. static DecodeBase64(uri: string): ArrayBuffer;
  33822. private static _NoneLogLevel;
  33823. private static _MessageLogLevel;
  33824. private static _WarningLogLevel;
  33825. private static _ErrorLogLevel;
  33826. private static _LogCache;
  33827. static errorsCount: number;
  33828. static OnNewCacheEntry: (entry: string) => void;
  33829. static readonly NoneLogLevel: number;
  33830. static readonly MessageLogLevel: number;
  33831. static readonly WarningLogLevel: number;
  33832. static readonly ErrorLogLevel: number;
  33833. static readonly AllLogLevel: number;
  33834. private static _AddLogEntry(entry);
  33835. private static _FormatMessage(message);
  33836. private static _LogDisabled(message);
  33837. private static _LogEnabled(message);
  33838. private static _WarnDisabled(message);
  33839. private static _WarnEnabled(message);
  33840. private static _ErrorDisabled(message);
  33841. private static _ErrorEnabled(message);
  33842. static Log: (message: string) => void;
  33843. static Warn: (message: string) => void;
  33844. static Error: (message: string) => void;
  33845. static readonly LogCache: string;
  33846. static ClearLogCache(): void;
  33847. static LogLevels: number;
  33848. static IsWindowObjectExist(): boolean;
  33849. private static _PerformanceNoneLogLevel;
  33850. private static _PerformanceUserMarkLogLevel;
  33851. private static _PerformanceConsoleLogLevel;
  33852. private static _performance;
  33853. static readonly PerformanceNoneLogLevel: number;
  33854. static readonly PerformanceUserMarkLogLevel: number;
  33855. static readonly PerformanceConsoleLogLevel: number;
  33856. static PerformanceLogLevel: number;
  33857. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  33858. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  33859. static _StartUserMark(counterName: string, condition?: boolean): void;
  33860. static _EndUserMark(counterName: string, condition?: boolean): void;
  33861. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  33862. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  33863. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33864. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33865. static readonly Now: number;
  33866. /**
  33867. * This method will return the name of the class used to create the instance of the given object.
  33868. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33869. * @param object the object to get the class name from
  33870. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  33871. */
  33872. static GetClassName(object: any, isType?: boolean): string;
  33873. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33874. /**
  33875. * This method will return the name of the full name of the class, including its owning module (if any).
  33876. * 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).
  33877. * @param object the object to get the class name from
  33878. * @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.
  33879. */
  33880. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33881. /**
  33882. * 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.
  33883. * @param array
  33884. */
  33885. static arrayOrStringFeeder(array: any): (i: number) => number;
  33886. /**
  33887. * Compute the hashCode of a stream of number
  33888. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  33889. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  33890. * @return the hash code computed
  33891. */
  33892. static hashCodeFromStream(feeder: (index: number) => number): number;
  33893. /**
  33894. * Returns a promise that resolves after the given amount of time.
  33895. * @param delay Number of milliseconds to delay
  33896. * @returns Promise that resolves after the given amount of time
  33897. */
  33898. static DelayAsync(delay: number): Promise<void>;
  33899. }
  33900. /**
  33901. * This class is used to track a performance counter which is number based.
  33902. * The user has access to many properties which give statistics of different nature
  33903. *
  33904. * The implementer can track two kinds of Performance Counter: time and count
  33905. * 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.
  33906. * 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.
  33907. */
  33908. class PerfCounter {
  33909. static Enabled: boolean;
  33910. /**
  33911. * Returns the smallest value ever
  33912. */
  33913. readonly min: number;
  33914. /**
  33915. * Returns the biggest value ever
  33916. */
  33917. readonly max: number;
  33918. /**
  33919. * Returns the average value since the performance counter is running
  33920. */
  33921. readonly average: number;
  33922. /**
  33923. * Returns the average value of the last second the counter was monitored
  33924. */
  33925. readonly lastSecAverage: number;
  33926. /**
  33927. * Returns the current value
  33928. */
  33929. readonly current: number;
  33930. readonly total: number;
  33931. readonly count: number;
  33932. constructor();
  33933. /**
  33934. * Call this method to start monitoring a new frame.
  33935. * 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.
  33936. */
  33937. fetchNewFrame(): void;
  33938. /**
  33939. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33940. * @param newCount the count value to add to the monitored count
  33941. * @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.
  33942. */
  33943. addCount(newCount: number, fetchResult: boolean): void;
  33944. /**
  33945. * Start monitoring this performance counter
  33946. */
  33947. beginMonitoring(): void;
  33948. /**
  33949. * Compute the time lapsed since the previous beginMonitoring() call.
  33950. * @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
  33951. */
  33952. endMonitoring(newFrame?: boolean): void;
  33953. private _fetchResult();
  33954. private _startMonitoringTime;
  33955. private _min;
  33956. private _max;
  33957. private _average;
  33958. private _current;
  33959. private _totalValueCount;
  33960. private _totalAccumulated;
  33961. private _lastSecAverage;
  33962. private _lastSecAccumulated;
  33963. private _lastSecTime;
  33964. private _lastSecValueCount;
  33965. }
  33966. /**
  33967. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33968. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33969. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33970. * @param name The name of the class, case should be preserved
  33971. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33972. */
  33973. function className(name: string, module?: string): (target: Object) => void;
  33974. /**
  33975. * An implementation of a loop for asynchronous functions.
  33976. */
  33977. class AsyncLoop {
  33978. iterations: number;
  33979. private _fn;
  33980. private _successCallback;
  33981. index: number;
  33982. private _done;
  33983. /**
  33984. * Constroctor.
  33985. * @param iterations the number of iterations.
  33986. * @param _fn the function to run each iteration
  33987. * @param _successCallback the callback that will be called upon succesful execution
  33988. * @param offset starting offset.
  33989. */
  33990. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  33991. /**
  33992. * Execute the next iteration. Must be called after the last iteration was finished.
  33993. */
  33994. executeNext(): void;
  33995. /**
  33996. * Break the loop and run the success callback.
  33997. */
  33998. breakLoop(): void;
  33999. /**
  34000. * Helper function
  34001. */
  34002. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  34003. /**
  34004. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34005. * @param iterations total number of iterations
  34006. * @param syncedIterations number of synchronous iterations in each async iteration.
  34007. * @param fn the function to call each iteration.
  34008. * @param callback a success call back that will be called when iterating stops.
  34009. * @param breakFunction a break condition (optional)
  34010. * @param timeout timeout settings for the setTimeout function. default - 0.
  34011. * @constructor
  34012. */
  34013. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  34014. }
  34015. }
  34016. declare module BABYLON {
  34017. enum JoystickAxis {
  34018. X = 0,
  34019. Y = 1,
  34020. Z = 2,
  34021. }
  34022. class VirtualJoystick {
  34023. reverseLeftRight: boolean;
  34024. reverseUpDown: boolean;
  34025. deltaPosition: Vector3;
  34026. pressed: boolean;
  34027. private static _globalJoystickIndex;
  34028. private static vjCanvas;
  34029. private static vjCanvasContext;
  34030. private static vjCanvasWidth;
  34031. private static vjCanvasHeight;
  34032. private static halfWidth;
  34033. private _action;
  34034. private _axisTargetedByLeftAndRight;
  34035. private _axisTargetedByUpAndDown;
  34036. private _joystickSensibility;
  34037. private _inversedSensibility;
  34038. private _joystickPointerID;
  34039. private _joystickColor;
  34040. private _joystickPointerPos;
  34041. private _joystickPreviousPointerPos;
  34042. private _joystickPointerStartPos;
  34043. private _deltaJoystickVector;
  34044. private _leftJoystick;
  34045. private _touches;
  34046. private _onPointerDownHandlerRef;
  34047. private _onPointerMoveHandlerRef;
  34048. private _onPointerUpHandlerRef;
  34049. private _onResize;
  34050. constructor(leftJoystick?: boolean);
  34051. setJoystickSensibility(newJoystickSensibility: number): void;
  34052. private _onPointerDown(e);
  34053. private _onPointerMove(e);
  34054. private _onPointerUp(e);
  34055. /**
  34056. * Change the color of the virtual joystick
  34057. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  34058. */
  34059. setJoystickColor(newColor: string): void;
  34060. setActionOnTouch(action: () => any): void;
  34061. setAxisForLeftRight(axis: JoystickAxis): void;
  34062. setAxisForUpDown(axis: JoystickAxis): void;
  34063. private _drawVirtualJoystick();
  34064. releaseCanvas(): void;
  34065. }
  34066. }
  34067. declare module BABYLON {
  34068. /**
  34069. * Helper class to push actions to a pool of workers.
  34070. */
  34071. class WorkerPool implements IDisposable {
  34072. private _workerInfos;
  34073. private _pendingActions;
  34074. /**
  34075. * Constructor
  34076. * @param workers Array of workers to use for actions
  34077. */
  34078. constructor(workers: Array<Worker>);
  34079. /**
  34080. * Terminates all workers and clears any pending actions.
  34081. */
  34082. dispose(): void;
  34083. /**
  34084. * Pushes an action to the worker pool. If all the workers are active, the action will be
  34085. * pended until a worker has completed its action.
  34086. * @param action The action to perform. Call onComplete when the action is complete.
  34087. */
  34088. push(action: (worker: Worker, onComplete: () => void) => void): void;
  34089. private _execute(workerInfo, action);
  34090. }
  34091. }
  34092. declare module BABYLON {
  34093. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34094. readonly name: string;
  34095. private _zoomStopsAnimation;
  34096. private _idleRotationSpeed;
  34097. private _idleRotationWaitTime;
  34098. private _idleRotationSpinupTime;
  34099. /**
  34100. * Gets the flag that indicates if user zooming should stop animation.
  34101. */
  34102. /**
  34103. * Sets the flag that indicates if user zooming should stop animation.
  34104. */
  34105. zoomStopsAnimation: boolean;
  34106. /**
  34107. * Gets the default speed at which the camera rotates around the model.
  34108. */
  34109. /**
  34110. * Sets the default speed at which the camera rotates around the model.
  34111. */
  34112. idleRotationSpeed: number;
  34113. /**
  34114. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34115. */
  34116. /**
  34117. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34118. */
  34119. idleRotationWaitTime: number;
  34120. /**
  34121. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34122. */
  34123. /**
  34124. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34125. */
  34126. idleRotationSpinupTime: number;
  34127. /**
  34128. * Gets a value indicating if the camera is currently rotating because of this behavior
  34129. */
  34130. readonly rotationInProgress: boolean;
  34131. private _onPrePointerObservableObserver;
  34132. private _onAfterCheckInputsObserver;
  34133. private _attachedCamera;
  34134. private _isPointerDown;
  34135. private _lastFrameTime;
  34136. private _lastInteractionTime;
  34137. private _cameraRotationSpeed;
  34138. init(): void;
  34139. attach(camera: ArcRotateCamera): void;
  34140. detach(): void;
  34141. /**
  34142. * Returns true if user is scrolling.
  34143. * @return true if user is scrolling.
  34144. */
  34145. private _userIsZooming();
  34146. private _lastFrameRadius;
  34147. private _shouldAnimationStopForInteraction();
  34148. /**
  34149. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34150. */
  34151. private _applyUserInteraction();
  34152. private _userIsMoving();
  34153. }
  34154. }
  34155. declare module BABYLON {
  34156. /**
  34157. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34158. */
  34159. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34160. readonly name: string;
  34161. /**
  34162. * The easing function used by animations
  34163. */
  34164. static EasingFunction: BackEase;
  34165. /**
  34166. * The easing mode used by animations
  34167. */
  34168. static EasingMode: number;
  34169. /**
  34170. * The duration of the animation, in milliseconds
  34171. */
  34172. transitionDuration: number;
  34173. /**
  34174. * Length of the distance animated by the transition when lower radius is reached
  34175. */
  34176. lowerRadiusTransitionRange: number;
  34177. /**
  34178. * Length of the distance animated by the transition when upper radius is reached
  34179. */
  34180. upperRadiusTransitionRange: number;
  34181. private _autoTransitionRange;
  34182. /**
  34183. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34184. */
  34185. /**
  34186. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34187. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34188. */
  34189. autoTransitionRange: boolean;
  34190. private _attachedCamera;
  34191. private _onAfterCheckInputsObserver;
  34192. private _onMeshTargetChangedObserver;
  34193. init(): void;
  34194. attach(camera: ArcRotateCamera): void;
  34195. detach(): void;
  34196. private _radiusIsAnimating;
  34197. private _radiusBounceTransition;
  34198. private _animatables;
  34199. private _cachedWheelPrecision;
  34200. /**
  34201. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34202. * @param radiusLimit The limit to check against.
  34203. * @return Bool to indicate if at limit.
  34204. */
  34205. private _isRadiusAtLimit(radiusLimit);
  34206. /**
  34207. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34208. * @param radiusDelta The delta by which to animate to. Can be negative.
  34209. */
  34210. private _applyBoundRadiusAnimation(radiusDelta);
  34211. /**
  34212. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34213. */
  34214. protected _clearAnimationLocks(): void;
  34215. /**
  34216. * Stops and removes all animations that have been applied to the camera
  34217. */
  34218. stopAllAnimations(): void;
  34219. }
  34220. }
  34221. declare module BABYLON {
  34222. class FramingBehavior implements Behavior<ArcRotateCamera> {
  34223. readonly name: string;
  34224. private _mode;
  34225. private _radiusScale;
  34226. private _positionScale;
  34227. private _defaultElevation;
  34228. private _elevationReturnTime;
  34229. private _elevationReturnWaitTime;
  34230. private _zoomStopsAnimation;
  34231. private _framingTime;
  34232. /**
  34233. * The easing function used by animations
  34234. */
  34235. static EasingFunction: ExponentialEase;
  34236. /**
  34237. * The easing mode used by animations
  34238. */
  34239. static EasingMode: number;
  34240. /**
  34241. * Gets current mode used by the behavior.
  34242. */
  34243. /**
  34244. * Sets the current mode used by the behavior
  34245. */
  34246. mode: number;
  34247. /**
  34248. * Gets the scale applied to the radius
  34249. */
  34250. /**
  34251. * Sets the scale applied to the radius (1 by default)
  34252. */
  34253. radiusScale: number;
  34254. /**
  34255. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34256. */
  34257. /**
  34258. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34259. */
  34260. positionScale: number;
  34261. /**
  34262. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34263. * behaviour is triggered, in radians.
  34264. */
  34265. /**
  34266. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34267. * behaviour is triggered, in radians.
  34268. */
  34269. defaultElevation: number;
  34270. /**
  34271. * Gets the time (in milliseconds) taken to return to the default beta position.
  34272. * Negative value indicates camera should not return to default.
  34273. */
  34274. /**
  34275. * Sets the time (in milliseconds) taken to return to the default beta position.
  34276. * Negative value indicates camera should not return to default.
  34277. */
  34278. elevationReturnTime: number;
  34279. /**
  34280. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34281. */
  34282. /**
  34283. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34284. */
  34285. elevationReturnWaitTime: number;
  34286. /**
  34287. * Gets the flag that indicates if user zooming should stop animation.
  34288. */
  34289. /**
  34290. * Sets the flag that indicates if user zooming should stop animation.
  34291. */
  34292. zoomStopsAnimation: boolean;
  34293. /**
  34294. * Gets the transition time when framing the mesh, in milliseconds
  34295. */
  34296. /**
  34297. * Sets the transition time when framing the mesh, in milliseconds
  34298. */
  34299. framingTime: number;
  34300. private _onPrePointerObservableObserver;
  34301. private _onAfterCheckInputsObserver;
  34302. private _onMeshTargetChangedObserver;
  34303. private _attachedCamera;
  34304. private _isPointerDown;
  34305. private _lastInteractionTime;
  34306. init(): void;
  34307. attach(camera: ArcRotateCamera): void;
  34308. detach(): void;
  34309. private _animatables;
  34310. private _betaIsAnimating;
  34311. private _betaTransition;
  34312. private _radiusTransition;
  34313. private _vectorTransition;
  34314. /**
  34315. * Targets the given mesh and updates zoom level accordingly.
  34316. * @param mesh The mesh to target.
  34317. * @param radius Optional. If a cached radius position already exists, overrides default.
  34318. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34319. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34320. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34321. */
  34322. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34323. /**
  34324. * Targets the given mesh with its children and updates zoom level accordingly.
  34325. * @param mesh The mesh to target.
  34326. * @param radius Optional. If a cached radius position already exists, overrides default.
  34327. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34328. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34329. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34330. */
  34331. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34332. /**
  34333. * Targets the given meshes with their children and updates zoom level accordingly.
  34334. * @param meshes The mesh to target.
  34335. * @param radius Optional. If a cached radius position already exists, overrides default.
  34336. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34337. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34338. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34339. */
  34340. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34341. /**
  34342. * Targets the given mesh and updates zoom level accordingly.
  34343. * @param mesh The mesh to target.
  34344. * @param radius Optional. If a cached radius position already exists, overrides default.
  34345. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34346. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34347. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34348. */
  34349. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34350. /**
  34351. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34352. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34353. * frustum width.
  34354. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34355. * to fully enclose the mesh in the viewing frustum.
  34356. */
  34357. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34358. /**
  34359. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34360. * is automatically returned to its default position (expected to be above ground plane).
  34361. */
  34362. private _maintainCameraAboveGround();
  34363. /**
  34364. * Returns the frustum slope based on the canvas ratio and camera FOV
  34365. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34366. */
  34367. private _getFrustumSlope();
  34368. /**
  34369. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34370. */
  34371. private _clearAnimationLocks();
  34372. /**
  34373. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34374. */
  34375. private _applyUserInteraction();
  34376. /**
  34377. * Stops and removes all animations that have been applied to the camera
  34378. */
  34379. stopAllAnimations(): void;
  34380. /**
  34381. * Gets a value indicating if the user is moving the camera
  34382. */
  34383. readonly isUserIsMoving: boolean;
  34384. /**
  34385. * The camera can move all the way towards the mesh.
  34386. */
  34387. static IgnoreBoundsSizeMode: number;
  34388. /**
  34389. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34390. */
  34391. static FitFrustumSidesMode: number;
  34392. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  34393. }
  34394. }
  34395. declare module BABYLON {
  34396. class SceneSerializer {
  34397. static ClearCache(): void;
  34398. static Serialize(scene: Scene): any;
  34399. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  34400. }
  34401. }
  34402. declare module BABYLON {
  34403. class SmartArray<T> {
  34404. data: Array<T>;
  34405. length: number;
  34406. protected _id: number;
  34407. [index: number]: T;
  34408. constructor(capacity: number);
  34409. push(value: T): void;
  34410. forEach(func: (content: T) => void): void;
  34411. sort(compareFn: (a: T, b: T) => number): void;
  34412. reset(): void;
  34413. dispose(): void;
  34414. concat(array: any): void;
  34415. indexOf(value: T): number;
  34416. contains(value: T): boolean;
  34417. private static _GlobalId;
  34418. }
  34419. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  34420. private _duplicateId;
  34421. [index: number]: T;
  34422. push(value: T): void;
  34423. pushNoDuplicate(value: T): boolean;
  34424. reset(): void;
  34425. concatWithNoDuplicate(array: any): void;
  34426. }
  34427. }
  34428. declare module BABYLON {
  34429. /**
  34430. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34431. * The underlying implementation relies on an associative array to ensure the best performances.
  34432. * The value can be anything including 'null' but except 'undefined'
  34433. */
  34434. class StringDictionary<T> {
  34435. /**
  34436. * This will clear this dictionary and copy the content from the 'source' one.
  34437. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34438. * @param source the dictionary to take the content from and copy to this dictionary
  34439. */
  34440. copyFrom(source: StringDictionary<T>): void;
  34441. /**
  34442. * Get a value based from its key
  34443. * @param key the given key to get the matching value from
  34444. * @return the value if found, otherwise undefined is returned
  34445. */
  34446. get(key: string): T | undefined;
  34447. /**
  34448. * Get a value from its key or add it if it doesn't exist.
  34449. * This method will ensure you that a given key/data will be present in the dictionary.
  34450. * @param key the given key to get the matching value from
  34451. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34452. * The factory will only be invoked if there's no data for the given key.
  34453. * @return the value corresponding to the key.
  34454. */
  34455. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34456. /**
  34457. * Get a value from its key if present in the dictionary otherwise add it
  34458. * @param key the key to get the value from
  34459. * @param val if there's no such key/value pair in the dictionary add it with this value
  34460. * @return the value corresponding to the key
  34461. */
  34462. getOrAdd(key: string, val: T): T;
  34463. /**
  34464. * Check if there's a given key in the dictionary
  34465. * @param key the key to check for
  34466. * @return true if the key is present, false otherwise
  34467. */
  34468. contains(key: string): boolean;
  34469. /**
  34470. * Add a new key and its corresponding value
  34471. * @param key the key to add
  34472. * @param value the value corresponding to the key
  34473. * @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
  34474. */
  34475. add(key: string, value: T): boolean;
  34476. set(key: string, value: T): boolean;
  34477. /**
  34478. * Get the element of the given key and remove it from the dictionary
  34479. * @param key
  34480. */
  34481. getAndRemove(key: string): Nullable<T>;
  34482. /**
  34483. * Remove a key/value from the dictionary.
  34484. * @param key the key to remove
  34485. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34486. */
  34487. remove(key: string): boolean;
  34488. /**
  34489. * Clear the whole content of the dictionary
  34490. */
  34491. clear(): void;
  34492. readonly count: number;
  34493. /**
  34494. * Execute a callback on each key/val of the dictionary.
  34495. * Note that you can remove any element in this dictionary in the callback implementation
  34496. * @param callback the callback to execute on a given key/value pair
  34497. */
  34498. forEach(callback: (key: string, val: T) => void): void;
  34499. /**
  34500. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34501. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34502. * Note that you can remove any element in this dictionary in the callback implementation
  34503. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34504. */
  34505. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34506. private _count;
  34507. private _data;
  34508. }
  34509. }
  34510. declare module BABYLON {
  34511. class Tags {
  34512. static EnableFor(obj: any): void;
  34513. static DisableFor(obj: any): void;
  34514. static HasTags(obj: any): boolean;
  34515. static GetTags(obj: any, asString?: boolean): any;
  34516. static AddTagsTo(obj: any, tagsString: string): void;
  34517. static _AddTagTo(obj: any, tag: string): void;
  34518. static RemoveTagsFrom(obj: any, tagsString: string): void;
  34519. static _RemoveTagFrom(obj: any, tag: string): void;
  34520. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  34521. }
  34522. }
  34523. declare module BABYLON {
  34524. class TextureTools {
  34525. /**
  34526. * Uses the GPU to create a copy texture rescaled at a given size
  34527. * @param texture Texture to copy from
  34528. * @param width Desired width
  34529. * @param height Desired height
  34530. * @return Generated texture
  34531. */
  34532. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  34533. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  34534. private static _environmentBRDFBase64Texture;
  34535. }
  34536. }
  34537. declare module BABYLON {
  34538. class TGATools {
  34539. private static _TYPE_INDEXED;
  34540. private static _TYPE_RGB;
  34541. private static _TYPE_GREY;
  34542. private static _TYPE_RLE_INDEXED;
  34543. private static _TYPE_RLE_RGB;
  34544. private static _TYPE_RLE_GREY;
  34545. private static _ORIGIN_MASK;
  34546. private static _ORIGIN_SHIFT;
  34547. private static _ORIGIN_BL;
  34548. private static _ORIGIN_BR;
  34549. private static _ORIGIN_UL;
  34550. private static _ORIGIN_UR;
  34551. static GetTGAHeader(data: Uint8Array): any;
  34552. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  34553. 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;
  34554. 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;
  34555. 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;
  34556. 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;
  34557. 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;
  34558. 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;
  34559. }
  34560. }
  34561. declare module BABYLON {
  34562. interface IAnimatable {
  34563. animations: Array<Animation>;
  34564. }
  34565. class LoadFileError extends Error {
  34566. request: XMLHttpRequest | undefined;
  34567. private static _setPrototypeOf;
  34568. constructor(message: string, request?: XMLHttpRequest | undefined);
  34569. }
  34570. class RetryStrategy {
  34571. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  34572. }
  34573. interface IFileRequest {
  34574. /**
  34575. * Raised when the request is complete (success or error).
  34576. */
  34577. onCompleteObservable: Observable<IFileRequest>;
  34578. /**
  34579. * Aborts the request for a file.
  34580. */
  34581. abort: () => void;
  34582. }
  34583. class Tools {
  34584. static BaseUrl: string;
  34585. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  34586. /**
  34587. * Default behaviour for cors in the application.
  34588. * It can be a string if the expected behavior is identical in the entire app.
  34589. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34590. */
  34591. static CorsBehavior: string | ((url: string | string[]) => string);
  34592. static UseFallbackTexture: boolean;
  34593. /**
  34594. * Use this object to register external classes like custom textures or material
  34595. * to allow the laoders to instantiate them
  34596. */
  34597. static RegisteredExternalClasses: {
  34598. [key: string]: Object;
  34599. };
  34600. static fallbackTexture: string;
  34601. /**
  34602. * Interpolates between a and b via alpha
  34603. * @param a The lower value (returned when alpha = 0)
  34604. * @param b The upper value (returned when alpha = 1)
  34605. * @param alpha The interpolation-factor
  34606. * @return The mixed value
  34607. */
  34608. static Mix(a: number, b: number, alpha: number): number;
  34609. static Instantiate(className: string): any;
  34610. /**
  34611. * Provides a slice function that will work even on IE
  34612. * @param data defines the array to slice
  34613. * @returns the new sliced array
  34614. */
  34615. static Slice(data: FloatArray): FloatArray;
  34616. static SetImmediate(action: () => void): void;
  34617. static IsExponentOfTwo(value: number): boolean;
  34618. /**
  34619. * Find the next highest power of two.
  34620. * @param x Number to start search from.
  34621. * @return Next highest power of two.
  34622. */
  34623. static CeilingPOT(x: number): number;
  34624. /**
  34625. * Find the next lowest power of two.
  34626. * @param x Number to start search from.
  34627. * @return Next lowest power of two.
  34628. */
  34629. static FloorPOT(x: number): number;
  34630. /**
  34631. * Find the nearest power of two.
  34632. * @param x Number to start search from.
  34633. * @return Next nearest power of two.
  34634. */
  34635. static NearestPOT(x: number): number;
  34636. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  34637. static GetFilename(path: string): string;
  34638. /**
  34639. * Extracts the "folder" part of a path (everything before the filename).
  34640. * @param uri The URI to extract the info from
  34641. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34642. * @returns The "folder" part of the path
  34643. */
  34644. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34645. static GetDOMTextContent(element: HTMLElement): string;
  34646. static ToDegrees(angle: number): number;
  34647. static ToRadians(angle: number): number;
  34648. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  34649. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  34650. minimum: Vector3;
  34651. maximum: Vector3;
  34652. };
  34653. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  34654. minimum: Vector3;
  34655. maximum: Vector3;
  34656. };
  34657. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  34658. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  34659. minimum: Vector2;
  34660. maximum: Vector2;
  34661. };
  34662. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34663. static GetPointerPrefix(): string;
  34664. /**
  34665. * @param func - the function to be called
  34666. * @param requester - the object that will request the next frame. Falls back to window.
  34667. */
  34668. static QueueNewFrame(func: () => void, requester?: any): number;
  34669. static RequestFullscreen(element: HTMLElement): void;
  34670. static ExitFullscreen(): void;
  34671. static SetCorsBehavior(url: string | string[], element: {
  34672. crossOrigin: string | null;
  34673. }): void;
  34674. static CleanUrl(url: string): string;
  34675. static PreprocessUrl: (url: string) => string;
  34676. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  34677. 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;
  34678. /**
  34679. * Load a script (identified by an url). When the url returns, the
  34680. * content of this file is added into a new script element, attached to the DOM (body element)
  34681. */
  34682. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  34683. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  34684. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  34685. static FileAsURL(content: string): string;
  34686. static Format(value: number, decimals?: number): string;
  34687. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  34688. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34689. static IsEmpty(obj: any): boolean;
  34690. static RegisterTopRootEvents(events: {
  34691. name: string;
  34692. handler: Nullable<(e: FocusEvent) => any>;
  34693. }[]): void;
  34694. static UnregisterTopRootEvents(events: {
  34695. name: string;
  34696. handler: Nullable<(e: FocusEvent) => any>;
  34697. }[]): void;
  34698. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34699. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34700. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  34701. /**
  34702. * Generates an image screenshot from the specified camera.
  34703. *
  34704. * @param engine The engine to use for rendering
  34705. * @param camera The camera to use for rendering
  34706. * @param size This parameter can be set to a single number or to an object with the
  34707. * following (optional) properties: precision, width, height. If a single number is passed,
  34708. * it will be used for both width and height. If an object is passed, the screenshot size
  34709. * will be derived from the parameters. The precision property is a multiplier allowing
  34710. * rendering at a higher or lower resolution.
  34711. * @param successCallback The callback receives a single parameter which contains the
  34712. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34713. * src parameter of an <img> to display it.
  34714. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34715. * Check your browser for supported MIME types.
  34716. * @param samples Texture samples (default: 1)
  34717. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34718. * @param fileName A name for for the downloaded file.
  34719. * @constructor
  34720. */
  34721. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34722. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  34723. /**
  34724. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34725. * Be aware Math.random() could cause collisions, but:
  34726. * "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"
  34727. */
  34728. static RandomId(): string;
  34729. /**
  34730. * Test if the given uri is a base64 string.
  34731. * @param uri The uri to test
  34732. * @return True if the uri is a base64 string or false otherwise.
  34733. */
  34734. static IsBase64(uri: string): boolean;
  34735. /**
  34736. * Decode the given base64 uri.
  34737. * @param uri The uri to decode
  34738. * @return The decoded base64 data.
  34739. */
  34740. static DecodeBase64(uri: string): ArrayBuffer;
  34741. private static _NoneLogLevel;
  34742. private static _MessageLogLevel;
  34743. private static _WarningLogLevel;
  34744. private static _ErrorLogLevel;
  34745. private static _LogCache;
  34746. static errorsCount: number;
  34747. static OnNewCacheEntry: (entry: string) => void;
  34748. static readonly NoneLogLevel: number;
  34749. static readonly MessageLogLevel: number;
  34750. static readonly WarningLogLevel: number;
  34751. static readonly ErrorLogLevel: number;
  34752. static readonly AllLogLevel: number;
  34753. private static _AddLogEntry(entry);
  34754. private static _FormatMessage(message);
  34755. private static _LogDisabled(message);
  34756. private static _LogEnabled(message);
  34757. private static _WarnDisabled(message);
  34758. private static _WarnEnabled(message);
  34759. private static _ErrorDisabled(message);
  34760. private static _ErrorEnabled(message);
  34761. static Log: (message: string) => void;
  34762. static Warn: (message: string) => void;
  34763. static Error: (message: string) => void;
  34764. static readonly LogCache: string;
  34765. static ClearLogCache(): void;
  34766. static LogLevels: number;
  34767. static IsWindowObjectExist(): boolean;
  34768. private static _PerformanceNoneLogLevel;
  34769. private static _PerformanceUserMarkLogLevel;
  34770. private static _PerformanceConsoleLogLevel;
  34771. private static _performance;
  34772. static readonly PerformanceNoneLogLevel: number;
  34773. static readonly PerformanceUserMarkLogLevel: number;
  34774. static readonly PerformanceConsoleLogLevel: number;
  34775. static PerformanceLogLevel: number;
  34776. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  34777. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  34778. static _StartUserMark(counterName: string, condition?: boolean): void;
  34779. static _EndUserMark(counterName: string, condition?: boolean): void;
  34780. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  34781. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  34782. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34783. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34784. static readonly Now: number;
  34785. /**
  34786. * This method will return the name of the class used to create the instance of the given object.
  34787. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34788. * @param object the object to get the class name from
  34789. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  34790. */
  34791. static GetClassName(object: any, isType?: boolean): string;
  34792. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34793. /**
  34794. * This method will return the name of the full name of the class, including its owning module (if any).
  34795. * 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).
  34796. * @param object the object to get the class name from
  34797. * @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.
  34798. */
  34799. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34800. /**
  34801. * 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.
  34802. * @param array
  34803. */
  34804. static arrayOrStringFeeder(array: any): (i: number) => number;
  34805. /**
  34806. * Compute the hashCode of a stream of number
  34807. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  34808. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  34809. * @return the hash code computed
  34810. */
  34811. static hashCodeFromStream(feeder: (index: number) => number): number;
  34812. /**
  34813. * Returns a promise that resolves after the given amount of time.
  34814. * @param delay Number of milliseconds to delay
  34815. * @returns Promise that resolves after the given amount of time
  34816. */
  34817. static DelayAsync(delay: number): Promise<void>;
  34818. }
  34819. /**
  34820. * This class is used to track a performance counter which is number based.
  34821. * The user has access to many properties which give statistics of different nature
  34822. *
  34823. * The implementer can track two kinds of Performance Counter: time and count
  34824. * 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.
  34825. * 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.
  34826. */
  34827. class PerfCounter {
  34828. static Enabled: boolean;
  34829. /**
  34830. * Returns the smallest value ever
  34831. */
  34832. readonly min: number;
  34833. /**
  34834. * Returns the biggest value ever
  34835. */
  34836. readonly max: number;
  34837. /**
  34838. * Returns the average value since the performance counter is running
  34839. */
  34840. readonly average: number;
  34841. /**
  34842. * Returns the average value of the last second the counter was monitored
  34843. */
  34844. readonly lastSecAverage: number;
  34845. /**
  34846. * Returns the current value
  34847. */
  34848. readonly current: number;
  34849. readonly total: number;
  34850. readonly count: number;
  34851. constructor();
  34852. /**
  34853. * Call this method to start monitoring a new frame.
  34854. * 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.
  34855. */
  34856. fetchNewFrame(): void;
  34857. /**
  34858. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34859. * @param newCount the count value to add to the monitored count
  34860. * @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.
  34861. */
  34862. addCount(newCount: number, fetchResult: boolean): void;
  34863. /**
  34864. * Start monitoring this performance counter
  34865. */
  34866. beginMonitoring(): void;
  34867. /**
  34868. * Compute the time lapsed since the previous beginMonitoring() call.
  34869. * @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
  34870. */
  34871. endMonitoring(newFrame?: boolean): void;
  34872. private _fetchResult();
  34873. private _startMonitoringTime;
  34874. private _min;
  34875. private _max;
  34876. private _average;
  34877. private _current;
  34878. private _totalValueCount;
  34879. private _totalAccumulated;
  34880. private _lastSecAverage;
  34881. private _lastSecAccumulated;
  34882. private _lastSecTime;
  34883. private _lastSecValueCount;
  34884. }
  34885. /**
  34886. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34887. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34888. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34889. * @param name The name of the class, case should be preserved
  34890. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34891. */
  34892. function className(name: string, module?: string): (target: Object) => void;
  34893. /**
  34894. * An implementation of a loop for asynchronous functions.
  34895. */
  34896. class AsyncLoop {
  34897. iterations: number;
  34898. private _fn;
  34899. private _successCallback;
  34900. index: number;
  34901. private _done;
  34902. /**
  34903. * Constroctor.
  34904. * @param iterations the number of iterations.
  34905. * @param _fn the function to run each iteration
  34906. * @param _successCallback the callback that will be called upon succesful execution
  34907. * @param offset starting offset.
  34908. */
  34909. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  34910. /**
  34911. * Execute the next iteration. Must be called after the last iteration was finished.
  34912. */
  34913. executeNext(): void;
  34914. /**
  34915. * Break the loop and run the success callback.
  34916. */
  34917. breakLoop(): void;
  34918. /**
  34919. * Helper function
  34920. */
  34921. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  34922. /**
  34923. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34924. * @param iterations total number of iterations
  34925. * @param syncedIterations number of synchronous iterations in each async iteration.
  34926. * @param fn the function to call each iteration.
  34927. * @param callback a success call back that will be called when iterating stops.
  34928. * @param breakFunction a break condition (optional)
  34929. * @param timeout timeout settings for the setTimeout function. default - 0.
  34930. * @constructor
  34931. */
  34932. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  34933. }
  34934. }
  34935. declare module BABYLON {
  34936. enum JoystickAxis {
  34937. X = 0,
  34938. Y = 1,
  34939. Z = 2,
  34940. }
  34941. class VirtualJoystick {
  34942. reverseLeftRight: boolean;
  34943. reverseUpDown: boolean;
  34944. deltaPosition: Vector3;
  34945. pressed: boolean;
  34946. private static _globalJoystickIndex;
  34947. private static vjCanvas;
  34948. private static vjCanvasContext;
  34949. private static vjCanvasWidth;
  34950. private static vjCanvasHeight;
  34951. private static halfWidth;
  34952. private _action;
  34953. private _axisTargetedByLeftAndRight;
  34954. private _axisTargetedByUpAndDown;
  34955. private _joystickSensibility;
  34956. private _inversedSensibility;
  34957. private _joystickPointerID;
  34958. private _joystickColor;
  34959. private _joystickPointerPos;
  34960. private _joystickPreviousPointerPos;
  34961. private _joystickPointerStartPos;
  34962. private _deltaJoystickVector;
  34963. private _leftJoystick;
  34964. private _touches;
  34965. private _onPointerDownHandlerRef;
  34966. private _onPointerMoveHandlerRef;
  34967. private _onPointerUpHandlerRef;
  34968. private _onResize;
  34969. constructor(leftJoystick?: boolean);
  34970. setJoystickSensibility(newJoystickSensibility: number): void;
  34971. private _onPointerDown(e);
  34972. private _onPointerMove(e);
  34973. private _onPointerUp(e);
  34974. /**
  34975. * Change the color of the virtual joystick
  34976. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  34977. */
  34978. setJoystickColor(newColor: string): void;
  34979. setActionOnTouch(action: () => any): void;
  34980. setAxisForLeftRight(axis: JoystickAxis): void;
  34981. setAxisForUpDown(axis: JoystickAxis): void;
  34982. private _drawVirtualJoystick();
  34983. releaseCanvas(): void;
  34984. }
  34985. }
  34986. declare module BABYLON {
  34987. /**
  34988. * Helper class to push actions to a pool of workers.
  34989. */
  34990. class WorkerPool implements IDisposable {
  34991. private _workerInfos;
  34992. private _pendingActions;
  34993. /**
  34994. * Constructor
  34995. * @param workers Array of workers to use for actions
  34996. */
  34997. constructor(workers: Array<Worker>);
  34998. /**
  34999. * Terminates all workers and clears any pending actions.
  35000. */
  35001. dispose(): void;
  35002. /**
  35003. * Pushes an action to the worker pool. If all the workers are active, the action will be
  35004. * pended until a worker has completed its action.
  35005. * @param action The action to perform. Call onComplete when the action is complete.
  35006. */
  35007. push(action: (worker: Worker, onComplete: () => void) => void): void;
  35008. private _execute(workerInfo, action);
  35009. }
  35010. }
  35011. declare module BABYLON {
  35012. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35013. camera: ArcRotateCamera;
  35014. gamepad: Nullable<Gamepad>;
  35015. private _onGamepadConnectedObserver;
  35016. private _onGamepadDisconnectedObserver;
  35017. gamepadRotationSensibility: number;
  35018. gamepadMoveSensibility: number;
  35019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35020. detachControl(element: Nullable<HTMLElement>): void;
  35021. checkInputs(): void;
  35022. getClassName(): string;
  35023. getSimpleName(): string;
  35024. }
  35025. }
  35026. declare module BABYLON {
  35027. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35028. camera: ArcRotateCamera;
  35029. private _keys;
  35030. keysUp: number[];
  35031. keysDown: number[];
  35032. keysLeft: number[];
  35033. keysRight: number[];
  35034. keysReset: number[];
  35035. panningSensibility: number;
  35036. zoomingSensibility: number;
  35037. useAltToZoom: boolean;
  35038. private _ctrlPressed;
  35039. private _altPressed;
  35040. private _onCanvasBlurObserver;
  35041. private _onKeyboardObserver;
  35042. private _engine;
  35043. private _scene;
  35044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35045. detachControl(element: Nullable<HTMLElement>): void;
  35046. checkInputs(): void;
  35047. getClassName(): string;
  35048. getSimpleName(): string;
  35049. }
  35050. }
  35051. declare module BABYLON {
  35052. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35053. camera: ArcRotateCamera;
  35054. private _wheel;
  35055. private _observer;
  35056. wheelPrecision: number;
  35057. /**
  35058. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35059. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35060. */
  35061. wheelDeltaPercentage: number;
  35062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35063. detachControl(element: Nullable<HTMLElement>): void;
  35064. getClassName(): string;
  35065. getSimpleName(): string;
  35066. }
  35067. }
  35068. declare module BABYLON {
  35069. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  35070. camera: ArcRotateCamera;
  35071. buttons: number[];
  35072. angularSensibilityX: number;
  35073. angularSensibilityY: number;
  35074. pinchPrecision: number;
  35075. /**
  35076. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  35077. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35078. */
  35079. pinchDeltaPercentage: number;
  35080. panningSensibility: number;
  35081. multiTouchPanning: boolean;
  35082. multiTouchPanAndZoom: boolean;
  35083. private _isPanClick;
  35084. pinchInwards: boolean;
  35085. private _pointerInput;
  35086. private _observer;
  35087. private _onMouseMove;
  35088. private _onGestureStart;
  35089. private _onGesture;
  35090. private _MSGestureHandler;
  35091. private _onLostFocus;
  35092. private _onContextMenu;
  35093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35094. detachControl(element: Nullable<HTMLElement>): void;
  35095. getClassName(): string;
  35096. getSimpleName(): string;
  35097. }
  35098. }
  35099. declare module BABYLON {
  35100. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35101. camera: ArcRotateCamera;
  35102. alphaCorrection: number;
  35103. betaCorrection: number;
  35104. gammaCorrection: number;
  35105. private _alpha;
  35106. private _gamma;
  35107. private _dirty;
  35108. private _deviceOrientationHandler;
  35109. constructor();
  35110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35111. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35112. checkInputs(): void;
  35113. detachControl(element: Nullable<HTMLElement>): void;
  35114. getClassName(): string;
  35115. getSimpleName(): string;
  35116. }
  35117. }
  35118. declare module BABYLON {
  35119. /**
  35120. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  35121. * Screen rotation is taken into account.
  35122. */
  35123. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  35124. private _camera;
  35125. private _screenOrientationAngle;
  35126. private _constantTranform;
  35127. private _screenQuaternion;
  35128. private _alpha;
  35129. private _beta;
  35130. private _gamma;
  35131. constructor();
  35132. camera: FreeCamera;
  35133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35134. private _orientationChanged;
  35135. private _deviceOrientation;
  35136. detachControl(element: Nullable<HTMLElement>): void;
  35137. checkInputs(): void;
  35138. getClassName(): string;
  35139. getSimpleName(): string;
  35140. }
  35141. }
  35142. declare module BABYLON {
  35143. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  35144. camera: FreeCamera;
  35145. gamepad: Nullable<Gamepad>;
  35146. private _onGamepadConnectedObserver;
  35147. private _onGamepadDisconnectedObserver;
  35148. gamepadAngularSensibility: number;
  35149. gamepadMoveSensibility: number;
  35150. private _cameraTransform;
  35151. private _deltaTransform;
  35152. private _vector3;
  35153. private _vector2;
  35154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35155. detachControl(element: Nullable<HTMLElement>): void;
  35156. checkInputs(): void;
  35157. getClassName(): string;
  35158. getSimpleName(): string;
  35159. }
  35160. }
  35161. declare module BABYLON {
  35162. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  35163. camera: FreeCamera;
  35164. private _keys;
  35165. private _onCanvasBlurObserver;
  35166. private _onKeyboardObserver;
  35167. private _engine;
  35168. private _scene;
  35169. keysUp: number[];
  35170. keysDown: number[];
  35171. keysLeft: number[];
  35172. keysRight: number[];
  35173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35174. detachControl(element: Nullable<HTMLElement>): void;
  35175. checkInputs(): void;
  35176. getClassName(): string;
  35177. _onLostFocus(e: FocusEvent): void;
  35178. getSimpleName(): string;
  35179. }
  35180. }
  35181. declare module BABYLON {
  35182. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  35183. touchEnabled: boolean;
  35184. camera: FreeCamera;
  35185. buttons: number[];
  35186. angularSensibility: number;
  35187. private _pointerInput;
  35188. private _onMouseMove;
  35189. private _observer;
  35190. private previousPosition;
  35191. constructor(touchEnabled?: boolean);
  35192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35193. detachControl(element: Nullable<HTMLElement>): void;
  35194. getClassName(): string;
  35195. getSimpleName(): string;
  35196. }
  35197. }
  35198. declare module BABYLON {
  35199. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  35200. camera: FreeCamera;
  35201. private _offsetX;
  35202. private _offsetY;
  35203. private _pointerPressed;
  35204. private _pointerInput;
  35205. private _observer;
  35206. private _onLostFocus;
  35207. touchAngularSensibility: number;
  35208. touchMoveSensibility: number;
  35209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35210. detachControl(element: Nullable<HTMLElement>): void;
  35211. checkInputs(): void;
  35212. getClassName(): string;
  35213. getSimpleName(): string;
  35214. }
  35215. }
  35216. declare module BABYLON {
  35217. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35218. camera: FreeCamera;
  35219. private _leftjoystick;
  35220. private _rightjoystick;
  35221. getLeftJoystick(): VirtualJoystick;
  35222. getRightJoystick(): VirtualJoystick;
  35223. checkInputs(): void;
  35224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35225. detachControl(element: Nullable<HTMLElement>): void;
  35226. getClassName(): string;
  35227. getSimpleName(): string;
  35228. }
  35229. }
  35230. declare module BABYLON {
  35231. class VRCameraMetrics {
  35232. hResolution: number;
  35233. vResolution: number;
  35234. hScreenSize: number;
  35235. vScreenSize: number;
  35236. vScreenCenter: number;
  35237. eyeToScreenDistance: number;
  35238. lensSeparationDistance: number;
  35239. interpupillaryDistance: number;
  35240. distortionK: number[];
  35241. chromaAbCorrection: number[];
  35242. postProcessScaleFactor: number;
  35243. lensCenterOffset: number;
  35244. compensateDistortion: boolean;
  35245. readonly aspectRatio: number;
  35246. readonly aspectRatioFov: number;
  35247. readonly leftHMatrix: Matrix;
  35248. readonly rightHMatrix: Matrix;
  35249. readonly leftPreViewMatrix: Matrix;
  35250. readonly rightPreViewMatrix: Matrix;
  35251. static GetDefault(): VRCameraMetrics;
  35252. }
  35253. }
  35254. declare module BABYLON {
  35255. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  35256. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  35257. getClassName(): string;
  35258. }
  35259. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  35260. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  35261. getClassName(): string;
  35262. }
  35263. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  35264. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  35265. getClassName(): string;
  35266. }
  35267. }
  35268. declare module BABYLON {
  35269. /**
  35270. * Options to modify the vr teleportation behavior.
  35271. */
  35272. interface VRTeleportationOptions {
  35273. /**
  35274. * The name of the mesh which should be used as the teleportation floor. (default: null)
  35275. */
  35276. floorMeshName?: string;
  35277. /**
  35278. * A list of meshes to be used as the teleportation floor. (default: empty)
  35279. */
  35280. floorMeshes?: Mesh[];
  35281. }
  35282. /**
  35283. * Options to modify the vr experience helper's behavior.
  35284. */
  35285. interface VRExperienceHelperOptions extends WebVROptions {
  35286. /**
  35287. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  35288. */
  35289. createDeviceOrientationCamera?: boolean;
  35290. /**
  35291. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  35292. */
  35293. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  35294. }
  35295. /**
  35296. * Helps to quickly add VR support to an existing scene.
  35297. * See http://doc.babylonjs.com/how_to/webvr_helper
  35298. */
  35299. class VRExperienceHelper {
  35300. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  35301. private _scene;
  35302. private _position;
  35303. private _btnVR;
  35304. private _btnVRDisplayed;
  35305. private _webVRsupported;
  35306. private _webVRready;
  35307. private _webVRrequesting;
  35308. private _webVRpresenting;
  35309. private _fullscreenVRpresenting;
  35310. private _canvas;
  35311. private _webVRCamera;
  35312. private _vrDeviceOrientationCamera;
  35313. private _deviceOrientationCamera;
  35314. private _existingCamera;
  35315. private _onKeyDown;
  35316. private _onVrDisplayPresentChange;
  35317. private _onVRDisplayChanged;
  35318. private _onVRRequestPresentStart;
  35319. private _onVRRequestPresentComplete;
  35320. /**
  35321. * Observable raised when entering VR.
  35322. */
  35323. onEnteringVRObservable: Observable<VRExperienceHelper>;
  35324. /**
  35325. * Observable raised when exiting VR.
  35326. */
  35327. onExitingVRObservable: Observable<VRExperienceHelper>;
  35328. /**
  35329. * Observable raised when controller mesh is loaded.
  35330. */
  35331. onControllerMeshLoadedObservable: Observable<WebVRController>;
  35332. /** Return this.onEnteringVRObservable
  35333. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  35334. */
  35335. readonly onEnteringVR: Observable<VRExperienceHelper>;
  35336. /** Return this.onExitingVRObservable
  35337. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  35338. */
  35339. readonly onExitingVR: Observable<VRExperienceHelper>;
  35340. /** Return this.onControllerMeshLoadedObservable
  35341. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  35342. */
  35343. readonly onControllerMeshLoaded: Observable<WebVRController>;
  35344. private _rayLength;
  35345. private _useCustomVRButton;
  35346. private _teleportationRequested;
  35347. private _teleportActive;
  35348. private _floorMeshName;
  35349. private _floorMeshesCollection;
  35350. private _rotationAllowed;
  35351. private _teleportBackwardsVector;
  35352. private _rotationRightAsked;
  35353. private _rotationLeftAsked;
  35354. private _teleportationTarget;
  35355. private _isDefaultTeleportationTarget;
  35356. private _postProcessMove;
  35357. private _teleportationFillColor;
  35358. private _teleportationBorderColor;
  35359. private _rotationAngle;
  35360. private _haloCenter;
  35361. private _cameraGazer;
  35362. private _padSensibilityUp;
  35363. private _padSensibilityDown;
  35364. private leftController;
  35365. private rightController;
  35366. /**
  35367. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  35368. */
  35369. onNewMeshSelected: Observable<AbstractMesh>;
  35370. /**
  35371. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  35372. */
  35373. onNewMeshPicked: Observable<PickingInfo>;
  35374. private _circleEase;
  35375. /**
  35376. * Observable raised before camera teleportation
  35377. */
  35378. onBeforeCameraTeleport: Observable<Vector3>;
  35379. /**
  35380. * Observable raised after camera teleportation
  35381. */
  35382. onAfterCameraTeleport: Observable<Vector3>;
  35383. /**
  35384. * Observable raised when current selected mesh gets unselected
  35385. */
  35386. onSelectedMeshUnselected: Observable<AbstractMesh>;
  35387. private _raySelectionPredicate;
  35388. /**
  35389. * To be optionaly changed by user to define custom ray selection
  35390. */
  35391. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  35392. /**
  35393. * To be optionaly changed by user to define custom selection logic (after ray selection)
  35394. */
  35395. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  35396. /**
  35397. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  35398. */
  35399. teleportationEnabled: boolean;
  35400. private _defaultHeight;
  35401. private _teleportationInitialized;
  35402. private _interactionsEnabled;
  35403. private _interactionsRequested;
  35404. private _displayGaze;
  35405. private _displayLaserPointer;
  35406. /**
  35407. * The mesh used to display where the user is going to teleport.
  35408. */
  35409. /**
  35410. * Sets the mesh to be used to display where the user is going to teleport.
  35411. */
  35412. teleportationTarget: Mesh;
  35413. /**
  35414. * The mesh used to display where the user is selecting,
  35415. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  35416. * See http://doc.babylonjs.com/resources/baking_transformations
  35417. */
  35418. gazeTrackerMesh: Mesh;
  35419. /**
  35420. * If the ray of the gaze should be displayed.
  35421. */
  35422. /**
  35423. * Sets if the ray of the gaze should be displayed.
  35424. */
  35425. displayGaze: boolean;
  35426. /**
  35427. * If the ray of the LaserPointer should be displayed.
  35428. */
  35429. /**
  35430. * Sets if the ray of the LaserPointer should be displayed.
  35431. */
  35432. displayLaserPointer: boolean;
  35433. /**
  35434. * The deviceOrientationCamera used as the camera when not in VR.
  35435. */
  35436. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  35437. /**
  35438. * Based on the current WebVR support, returns the current VR camera used.
  35439. */
  35440. readonly currentVRCamera: Nullable<Camera>;
  35441. /**
  35442. * The webVRCamera which is used when in VR.
  35443. */
  35444. readonly webVRCamera: WebVRFreeCamera;
  35445. /**
  35446. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  35447. */
  35448. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  35449. private readonly _teleportationRequestInitiated;
  35450. /**
  35451. * Instantiates a VRExperienceHelper.
  35452. * Helps to quickly add VR support to an existing scene.
  35453. * @param scene The scene the VRExperienceHelper belongs to.
  35454. * @param webVROptions Options to modify the vr experience helper's behavior.
  35455. */
  35456. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  35457. private _onDefaultMeshLoaded(webVRController);
  35458. private _onResize;
  35459. private _onFullscreenChange;
  35460. /**
  35461. * Gets a value indicating if we are currently in VR mode.
  35462. */
  35463. readonly isInVRMode: boolean;
  35464. private onVrDisplayPresentChange();
  35465. private onVRDisplayChanged(eventArgs);
  35466. private moveButtonToBottomRight();
  35467. private displayVRButton();
  35468. private updateButtonVisibility();
  35469. /**
  35470. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  35471. * Otherwise, will use the fullscreen API.
  35472. */
  35473. enterVR(): void;
  35474. /**
  35475. * Attempt to exit VR, or fullscreen.
  35476. */
  35477. exitVR(): void;
  35478. /**
  35479. * The position of the vr experience helper.
  35480. */
  35481. /**
  35482. * Sets the position of the vr experience helper.
  35483. */
  35484. position: Vector3;
  35485. /**
  35486. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  35487. */
  35488. enableInteractions(): void;
  35489. private beforeRender;
  35490. private _isTeleportationFloor(mesh);
  35491. /**
  35492. * Adds a floor mesh to be used for teleportation.
  35493. * @param floorMesh the mesh to be used for teleportation.
  35494. */
  35495. addFloorMesh(floorMesh: Mesh): void;
  35496. /**
  35497. * Removes a floor mesh from being used for teleportation.
  35498. * @param floorMesh the mesh to be removed.
  35499. */
  35500. removeFloorMesh(floorMesh: Mesh): void;
  35501. /**
  35502. * Enables interactions and teleportation using the VR controllers and gaze.
  35503. * @param vrTeleportationOptions options to modify teleportation behavior.
  35504. */
  35505. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  35506. private _onNewGamepadConnected;
  35507. private _tryEnableInteractionOnController;
  35508. private _onNewGamepadDisconnected;
  35509. private _enableInteractionOnController(controller);
  35510. private _checkTeleportWithRay(stateObject, gazer);
  35511. private _checkRotate(stateObject, gazer);
  35512. private _checkTeleportBackwards(stateObject, gazer);
  35513. private _enableTeleportationOnController(controller);
  35514. private _createTeleportationCircles();
  35515. private _displayTeleportationTarget();
  35516. private _hideTeleportationTarget();
  35517. private _rotateCamera(right);
  35518. private _moveTeleportationSelectorTo(hit, gazer);
  35519. private _workingVector;
  35520. private _workingQuaternion;
  35521. private _workingMatrix;
  35522. private _teleportCamera(location);
  35523. private _castRayAndSelectObject(gazer);
  35524. private _notifySelectedMeshUnselected(mesh);
  35525. /**
  35526. * Sets the color of the laser ray from the vr controllers.
  35527. * @param color new color for the ray.
  35528. */
  35529. changeLaserColor(color: Color3): void;
  35530. /**
  35531. * Sets the color of the ray from the vr headsets gaze.
  35532. * @param color new color for the ray.
  35533. */
  35534. changeGazeColor(color: Color3): void;
  35535. /**
  35536. <<<<<<< HEAD
  35537. * Exits VR and disposes of the vr experience helper
  35538. */
  35539. dispose(): void;
  35540. /**
  35541. * Gets the name of the VRExperienceHelper class
  35542. * @returns "VRExperienceHelper"
  35543. */
  35544. getClassName(): string;
  35545. =======
  35546. * This function is called by the two RIG cameras.
  35547. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  35548. */
  35549. protected _getWebVRViewMatrix(): Matrix;
  35550. protected _getWebVRProjectionMatrix(): Matrix;
  35551. private _onGamepadConnectedObserver;
  35552. private _onGamepadDisconnectedObserver;
  35553. /**
  35554. * Initializes the controllers and their meshes
  35555. */
  35556. initControllers(): void;
  35557. }
  35558. }
  35559. declare module BABYLON {
  35560. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35561. camera: ArcRotateCamera;
  35562. gamepad: Nullable<Gamepad>;
  35563. private _onGamepadConnectedObserver;
  35564. private _onGamepadDisconnectedObserver;
  35565. gamepadRotationSensibility: number;
  35566. gamepadMoveSensibility: number;
  35567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35568. detachControl(element: Nullable<HTMLElement>): void;
  35569. checkInputs(): void;
  35570. getClassName(): string;
  35571. getSimpleName(): string;
  35572. }
  35573. }
  35574. declare module BABYLON {
  35575. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35576. camera: ArcRotateCamera;
  35577. private _keys;
  35578. keysUp: number[];
  35579. keysDown: number[];
  35580. keysLeft: number[];
  35581. keysRight: number[];
  35582. keysReset: number[];
  35583. panningSensibility: number;
  35584. zoomingSensibility: number;
  35585. useAltToZoom: boolean;
  35586. private _ctrlPressed;
  35587. private _altPressed;
  35588. private _onCanvasBlurObserver;
  35589. private _onKeyboardObserver;
  35590. private _engine;
  35591. private _scene;
  35592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35593. detachControl(element: Nullable<HTMLElement>): void;
  35594. checkInputs(): void;
  35595. getClassName(): string;
  35596. getSimpleName(): string;
  35597. }
  35598. }
  35599. declare module BABYLON {
  35600. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35601. camera: ArcRotateCamera;
  35602. private _wheel;
  35603. private _observer;
  35604. wheelPrecision: number;
  35605. /**
  35606. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35607. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35608. */
  35609. wheelDeltaPercentage: number;
  35610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35611. detachControl(element: Nullable<HTMLElement>): void;
  35612. getClassName(): string;
  35613. getSimpleName(): string;
  35614. }
  35615. }
  35616. declare module BABYLON {
  35617. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  35618. camera: ArcRotateCamera;
  35619. buttons: number[];
  35620. angularSensibilityX: number;
  35621. angularSensibilityY: number;
  35622. pinchPrecision: number;
  35623. /**
  35624. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  35625. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35626. */
  35627. pinchDeltaPercentage: number;
  35628. panningSensibility: number;
  35629. multiTouchPanning: boolean;
  35630. multiTouchPanAndZoom: boolean;
  35631. private _isPanClick;
  35632. pinchInwards: boolean;
  35633. private _pointerInput;
  35634. private _observer;
  35635. private _onMouseMove;
  35636. private _onGestureStart;
  35637. private _onGesture;
  35638. private _MSGestureHandler;
  35639. private _onLostFocus;
  35640. private _onContextMenu;
  35641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35642. detachControl(element: Nullable<HTMLElement>): void;
  35643. getClassName(): string;
  35644. getSimpleName(): string;
  35645. }
  35646. }
  35647. declare module BABYLON {
  35648. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35649. camera: ArcRotateCamera;
  35650. alphaCorrection: number;
  35651. betaCorrection: number;
  35652. gammaCorrection: number;
  35653. private _alpha;
  35654. private _gamma;
  35655. private _dirty;
  35656. private _deviceOrientationHandler;
  35657. constructor();
  35658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35659. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35660. checkInputs(): void;
  35661. detachControl(element: Nullable<HTMLElement>): void;
  35662. getClassName(): string;
  35663. getSimpleName(): string;
  35664. }
  35665. }
  35666. declare module BABYLON {
  35667. /**
  35668. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  35669. * Screen rotation is taken into account.
  35670. */
  35671. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  35672. private _camera;
  35673. private _screenOrientationAngle;
  35674. private _constantTranform;
  35675. private _screenQuaternion;
  35676. private _alpha;
  35677. private _beta;
  35678. private _gamma;
  35679. constructor();
  35680. camera: FreeCamera;
  35681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35682. private _orientationChanged;
  35683. private _deviceOrientation;
  35684. detachControl(element: Nullable<HTMLElement>): void;
  35685. checkInputs(): void;
  35686. getClassName(): string;
  35687. getSimpleName(): string;
  35688. }
  35689. }
  35690. declare module BABYLON {
  35691. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  35692. camera: FreeCamera;
  35693. gamepad: Nullable<Gamepad>;
  35694. private _onGamepadConnectedObserver;
  35695. private _onGamepadDisconnectedObserver;
  35696. gamepadAngularSensibility: number;
  35697. gamepadMoveSensibility: number;
  35698. private _cameraTransform;
  35699. private _deltaTransform;
  35700. private _vector3;
  35701. private _vector2;
  35702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35703. detachControl(element: Nullable<HTMLElement>): void;
  35704. checkInputs(): void;
  35705. getClassName(): string;
  35706. getSimpleName(): string;
  35707. }
  35708. }
  35709. declare module BABYLON {
  35710. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  35711. camera: FreeCamera;
  35712. private _keys;
  35713. private _onCanvasBlurObserver;
  35714. private _onKeyboardObserver;
  35715. private _engine;
  35716. private _scene;
  35717. keysUp: number[];
  35718. keysDown: number[];
  35719. keysLeft: number[];
  35720. keysRight: number[];
  35721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35722. detachControl(element: Nullable<HTMLElement>): void;
  35723. checkInputs(): void;
  35724. getClassName(): string;
  35725. _onLostFocus(e: FocusEvent): void;
  35726. getSimpleName(): string;
  35727. }
  35728. }
  35729. declare module BABYLON {
  35730. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  35731. touchEnabled: boolean;
  35732. camera: FreeCamera;
  35733. buttons: number[];
  35734. angularSensibility: number;
  35735. private _pointerInput;
  35736. private _onMouseMove;
  35737. private _observer;
  35738. private previousPosition;
  35739. constructor(touchEnabled?: boolean);
  35740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35741. detachControl(element: Nullable<HTMLElement>): void;
  35742. getClassName(): string;
  35743. getSimpleName(): string;
  35744. }
  35745. }
  35746. declare module BABYLON {
  35747. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  35748. camera: FreeCamera;
  35749. private _offsetX;
  35750. private _offsetY;
  35751. private _pointerPressed;
  35752. private _pointerInput;
  35753. private _observer;
  35754. private _onLostFocus;
  35755. touchAngularSensibility: number;
  35756. touchMoveSensibility: number;
  35757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35758. detachControl(element: Nullable<HTMLElement>): void;
  35759. checkInputs(): void;
  35760. getClassName(): string;
  35761. getSimpleName(): string;
  35762. }
  35763. }
  35764. declare module BABYLON {
  35765. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35766. camera: FreeCamera;
  35767. private _leftjoystick;
  35768. private _rightjoystick;
  35769. getLeftJoystick(): VirtualJoystick;
  35770. getRightJoystick(): VirtualJoystick;
  35771. checkInputs(): void;
  35772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35773. detachControl(element: Nullable<HTMLElement>): void;
  35774. getClassName(): string;
  35775. getSimpleName(): string;
  35776. }
  35777. }
  35778. declare module BABYLON {
  35779. interface IOctreeContainer<T> {
  35780. blocks: Array<OctreeBlock<T>>;
  35781. }
  35782. class Octree<T> {
  35783. maxDepth: number;
  35784. blocks: Array<OctreeBlock<T>>;
  35785. dynamicContent: T[];
  35786. private _maxBlockCapacity;
  35787. private _selectionContent;
  35788. private _creationFunc;
  35789. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  35790. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  35791. addMesh(entry: T): void;
  35792. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  35793. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  35794. intersectsRay(ray: Ray): SmartArray<T>;
  35795. 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;
  35796. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  35797. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  35798. }
  35799. }
  35800. declare module BABYLON {
  35801. class OctreeBlock<T> {
  35802. entries: T[];
  35803. blocks: Array<OctreeBlock<T>>;
  35804. private _depth;
  35805. private _maxDepth;
  35806. private _capacity;
  35807. private _minPoint;
  35808. private _maxPoint;
  35809. private _boundingVectors;
  35810. private _creationFunc;
  35811. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  35812. readonly capacity: number;
  35813. readonly minPoint: Vector3;
  35814. readonly maxPoint: Vector3;
  35815. addEntry(entry: T): void;
  35816. addEntries(entries: T[]): void;
  35817. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  35818. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  35819. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  35820. createInnerBlocks(): void;
  35821. >>>>>>> 70d3435c5f934f0416dfbf106f59fe53aacc8393
  35822. }
  35823. }
  35824. declare var VRFrameData: any;
  35825. declare module BABYLON {
  35826. /**
  35827. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  35828. * IMPORTANT!! The data is right-hand data.
  35829. * @export
  35830. * @interface DevicePose
  35831. */
  35832. interface DevicePose {
  35833. /**
  35834. * The position of the device, values in array are [x,y,z].
  35835. */
  35836. readonly position?: Float32Array;
  35837. /**
  35838. * The linearVelocity of the device, values in array are [x,y,z].
  35839. */
  35840. readonly linearVelocity?: Float32Array;
  35841. /**
  35842. * The linearAcceleration of the device, values in array are [x,y,z].
  35843. */
  35844. readonly linearAcceleration?: Float32Array;
  35845. /**
  35846. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  35847. */
  35848. readonly orientation?: Float32Array;
  35849. /**
  35850. * The angularVelocity of the device, values in array are [x,y,z].
  35851. */
  35852. readonly angularVelocity?: Float32Array;
  35853. /**
  35854. * The angularAcceleration of the device, values in array are [x,y,z].
  35855. */
  35856. readonly angularAcceleration?: Float32Array;
  35857. }
  35858. /**
  35859. * Interface representing a pose controlled object in Babylon.
  35860. * A pose controlled object has both regular pose values as well as pose values
  35861. * from an external device such as a VR head mounted display
  35862. */
  35863. interface PoseControlled {
  35864. /**
  35865. * The position of the object in babylon space.
  35866. */
  35867. position: Vector3;
  35868. /**
  35869. * The rotation quaternion of the object in babylon space.
  35870. */
  35871. rotationQuaternion: Quaternion;
  35872. /**
  35873. * The position of the device in babylon space.
  35874. */
  35875. devicePosition?: Vector3;
  35876. /**
  35877. * The rotation quaternion of the device in babylon space.
  35878. */
  35879. deviceRotationQuaternion: Quaternion;
  35880. /**
  35881. * The raw pose coming from the device.
  35882. */
  35883. rawPose: Nullable<DevicePose>;
  35884. /**
  35885. * The scale of the device to be used when translating from device space to babylon space.
  35886. */
  35887. deviceScaleFactor: number;
  35888. /**
  35889. * Updates the poseControlled values based on the input device pose.
  35890. * @param poseData the pose data to update the object with
  35891. */
  35892. updateFromDevice(poseData: DevicePose): void;
  35893. }
  35894. /**
  35895. * Set of options to customize the webVRCamera
  35896. */
  35897. interface WebVROptions {
  35898. /**
  35899. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  35900. */
  35901. trackPosition?: boolean;
  35902. /**
  35903. * Sets the scale of the vrDevice in babylon space. (default: 1)
  35904. */
  35905. positionScale?: number;
  35906. /**
  35907. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  35908. */
  35909. displayName?: string;
  35910. /**
  35911. * Should the native controller meshes be initialized. (default: true)
  35912. */
  35913. controllerMeshes?: boolean;
  35914. /**
  35915. * Creating a default HemiLight only on controllers. (default: true)
  35916. */
  35917. defaultLightingOnControllers?: boolean;
  35918. /**
  35919. * If you don't want to use the default VR button of the helper. (default: false)
  35920. */
  35921. useCustomVRButton?: boolean;
  35922. /**
  35923. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  35924. */
  35925. customVRButton?: HTMLButtonElement;
  35926. /**
  35927. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  35928. */
  35929. rayLength?: number;
  35930. /**
  35931. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  35932. */
  35933. defaultHeight?: number;
  35934. }
  35935. /**
  35936. * This represents a WebVR camera.
  35937. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  35938. * @example http://doc.babylonjs.com/how_to/webvr_camera
  35939. */
  35940. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  35941. private webVROptions;
  35942. /**
  35943. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  35944. */
  35945. _vrDevice: any;
  35946. /**
  35947. * The rawPose of the vrDevice.
  35948. */
  35949. rawPose: Nullable<DevicePose>;
  35950. private _onVREnabled;
  35951. private _specsVersion;
  35952. private _attached;
  35953. private _frameData;
  35954. protected _descendants: Array<Node>;
  35955. private _deviceRoomPosition;
  35956. private _deviceRoomRotationQuaternion;
  35957. private _standingMatrix;
  35958. /**
  35959. * Represents device position in babylon space.
  35960. */
  35961. devicePosition: Vector3;
  35962. /**
  35963. * Represents device rotation in babylon space.
  35964. */
  35965. deviceRotationQuaternion: Quaternion;
  35966. /**
  35967. * The scale of the device to be used when translating from device space to babylon space.
  35968. */
  35969. deviceScaleFactor: number;
  35970. private _deviceToWorld;
  35971. private _worldToDevice;
  35972. /**
  35973. * References to the webVR controllers for the vrDevice.
  35974. */
  35975. controllers: Array<WebVRController>;
  35976. /**
  35977. * Emits an event when a controller is attached.
  35978. */
  35979. onControllersAttachedObservable: Observable<WebVRController[]>;
  35980. /**
  35981. * Emits an event when a controller's mesh has been loaded;
  35982. */
  35983. onControllerMeshLoadedObservable: Observable<WebVRController>;
  35984. /**
  35985. * If the rig cameras be used as parent instead of this camera.
  35986. */
  35987. rigParenting: boolean;
  35988. private _lightOnControllers;
  35989. private _defaultHeight?;
  35990. /**
  35991. * Instantiates a WebVRFreeCamera.
  35992. * @param name The name of the WebVRFreeCamera
  35993. * @param position The starting anchor position for the camera
  35994. * @param scene The scene the camera belongs to
  35995. * @param webVROptions a set of customizable options for the webVRCamera
  35996. */
  35997. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  35998. /**
  35999. * Gets the device distance from the ground in meters.
  36000. * @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.
  36001. */
  36002. deviceDistanceToRoomGround(): number;
  36003. /**
  36004. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  36005. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  36006. */
  36007. useStandingMatrix(callback?: (bool: boolean) => void): void;
  36008. /**
  36009. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  36010. * @returns A promise with a boolean set to if the standing matrix is supported.
  36011. */
  36012. useStandingMatrixAsync(): Promise<boolean>;
  36013. /**
  36014. * Disposes the camera
  36015. */
  36016. dispose(): void;
  36017. /**
  36018. * Gets a vrController by name.
  36019. * @param name The name of the controller to retreive
  36020. * @returns the controller matching the name specified or null if not found
  36021. */
  36022. getControllerByName(name: string): Nullable<WebVRController>;
  36023. private _leftController;
  36024. /**
  36025. * The controller corrisponding to the users left hand.
  36026. */
  36027. readonly leftController: Nullable<WebVRController>;
  36028. private _rightController;
  36029. /**
  36030. * The controller corrisponding to the users right hand.
  36031. */
  36032. readonly rightController: Nullable<WebVRController>;
  36033. /**
  36034. * Casts a ray forward from the vrCamera's gaze.
  36035. * @param length Length of the ray (default: 100)
  36036. * @returns the ray corrisponding to the gaze
  36037. */
  36038. getForwardRay(length?: number): Ray;
  36039. /**
  36040. * Updates the camera based on device's frame data
  36041. */
  36042. _checkInputs(): void;
  36043. /**
  36044. * Updates the poseControlled values based on the input device pose.
  36045. * @param poseData Pose coming from the device
  36046. */
  36047. updateFromDevice(poseData: DevicePose): void;
  36048. /**
  36049. * WebVR's attach control will start broadcasting frames to the device.
  36050. * Note that in certain browsers (chrome for example) this function must be called
  36051. * within a user-interaction callback. Example:
  36052. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  36053. *
  36054. * @param element html element to attach the vrDevice to
  36055. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  36056. */
  36057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36058. /**
  36059. * Detaches the camera from the html element and disables VR
  36060. *
  36061. * @param element html element to detach from
  36062. */
  36063. detachControl(element: HTMLElement): void;
  36064. /**
  36065. * @returns the name of this class
  36066. */
  36067. getClassName(): string;
  36068. /**
  36069. * Calls resetPose on the vrDisplay
  36070. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  36071. */
  36072. resetToCurrentRotation(): void;
  36073. /**
  36074. * Updates the rig cameras (left and right eye)
  36075. */
  36076. _updateRigCameras(): void;
  36077. private _workingVector;
  36078. private _oneVector;
  36079. private _workingMatrix;
  36080. private updateCacheCalled;
  36081. /**
  36082. * Updates the cached values of the camera
  36083. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  36084. */
  36085. _updateCache(ignoreParentClass?: boolean): void;
  36086. /**
  36087. * Updates the current device position and rotation in the babylon world
  36088. */
  36089. update(): void;
  36090. /**
  36091. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  36092. * @returns an identity matrix
  36093. */
  36094. _getViewMatrix(): Matrix;
  36095. /**
  36096. * This function is called by the two RIG cameras.
  36097. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  36098. */
  36099. protected _getWebVRViewMatrix(): Matrix;
  36100. protected _getWebVRProjectionMatrix(): Matrix;
  36101. private _onGamepadConnectedObserver;
  36102. private _onGamepadDisconnectedObserver;
  36103. /**
  36104. * Initializes the controllers and their meshes
  36105. */
  36106. initControllers(): void;
  36107. }
  36108. }
  36109. declare module BABYLON {
  36110. interface IOctreeContainer<T> {
  36111. blocks: Array<OctreeBlock<T>>;
  36112. }
  36113. class Octree<T> {
  36114. maxDepth: number;
  36115. blocks: Array<OctreeBlock<T>>;
  36116. dynamicContent: T[];
  36117. private _maxBlockCapacity;
  36118. private _selectionContent;
  36119. private _creationFunc;
  36120. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  36121. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  36122. addMesh(entry: T): void;
  36123. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  36124. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  36125. intersectsRay(ray: Ray): SmartArray<T>;
  36126. 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;
  36127. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  36128. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  36129. }
  36130. }
  36131. declare module BABYLON {
  36132. class OctreeBlock<T> {
  36133. entries: T[];
  36134. blocks: Array<OctreeBlock<T>>;
  36135. private _depth;
  36136. private _maxDepth;
  36137. private _capacity;
  36138. private _minPoint;
  36139. private _maxPoint;
  36140. private _boundingVectors;
  36141. private _creationFunc;
  36142. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  36143. readonly capacity: number;
  36144. readonly minPoint: Vector3;
  36145. readonly maxPoint: Vector3;
  36146. addEntry(entry: T): void;
  36147. addEntries(entries: T[]): void;
  36148. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  36149. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  36150. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  36151. createInnerBlocks(): void;
  36152. }
  36153. }
  36154. declare module BABYLON {
  36155. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36156. readonly name: string;
  36157. private _zoomStopsAnimation;
  36158. private _idleRotationSpeed;
  36159. private _idleRotationWaitTime;
  36160. private _idleRotationSpinupTime;
  36161. /**
  36162. * Gets the flag that indicates if user zooming should stop animation.
  36163. */
  36164. /**
  36165. * Sets the flag that indicates if user zooming should stop animation.
  36166. */
  36167. zoomStopsAnimation: boolean;
  36168. /**
  36169. * Gets the default speed at which the camera rotates around the model.
  36170. */
  36171. /**
  36172. * Sets the default speed at which the camera rotates around the model.
  36173. */
  36174. idleRotationSpeed: number;
  36175. /**
  36176. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36177. */
  36178. /**
  36179. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36180. */
  36181. idleRotationWaitTime: number;
  36182. /**
  36183. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36184. */
  36185. /**
  36186. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36187. */
  36188. idleRotationSpinupTime: number;
  36189. /**
  36190. * Gets a value indicating if the camera is currently rotating because of this behavior
  36191. */
  36192. readonly rotationInProgress: boolean;
  36193. private _onPrePointerObservableObserver;
  36194. private _onAfterCheckInputsObserver;
  36195. private _attachedCamera;
  36196. private _isPointerDown;
  36197. private _lastFrameTime;
  36198. private _lastInteractionTime;
  36199. private _cameraRotationSpeed;
  36200. init(): void;
  36201. attach(camera: ArcRotateCamera): void;
  36202. detach(): void;
  36203. /**
  36204. * Returns true if user is scrolling.
  36205. * @return true if user is scrolling.
  36206. */
  36207. private _userIsZooming();
  36208. private _lastFrameRadius;
  36209. private _shouldAnimationStopForInteraction();
  36210. /**
  36211. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36212. */
  36213. private _applyUserInteraction();
  36214. private _userIsMoving();
  36215. }
  36216. }
  36217. declare module BABYLON {
  36218. /**
  36219. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36220. */
  36221. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36222. readonly name: string;
  36223. /**
  36224. * The easing function used by animations
  36225. */
  36226. static EasingFunction: BackEase;
  36227. /**
  36228. * The easing mode used by animations
  36229. */
  36230. static EasingMode: number;
  36231. /**
  36232. * The duration of the animation, in milliseconds
  36233. */
  36234. transitionDuration: number;
  36235. /**
  36236. * Length of the distance animated by the transition when lower radius is reached
  36237. */
  36238. lowerRadiusTransitionRange: number;
  36239. /**
  36240. * Length of the distance animated by the transition when upper radius is reached
  36241. */
  36242. upperRadiusTransitionRange: number;
  36243. private _autoTransitionRange;
  36244. /**
  36245. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36246. */
  36247. /**
  36248. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36249. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36250. */
  36251. autoTransitionRange: boolean;
  36252. private _attachedCamera;
  36253. private _onAfterCheckInputsObserver;
  36254. private _onMeshTargetChangedObserver;
  36255. init(): void;
  36256. attach(camera: ArcRotateCamera): void;
  36257. detach(): void;
  36258. private _radiusIsAnimating;
  36259. private _radiusBounceTransition;
  36260. private _animatables;
  36261. private _cachedWheelPrecision;
  36262. /**
  36263. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36264. * @param radiusLimit The limit to check against.
  36265. * @return Bool to indicate if at limit.
  36266. */
  36267. private _isRadiusAtLimit(radiusLimit);
  36268. /**
  36269. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36270. * @param radiusDelta The delta by which to animate to. Can be negative.
  36271. */
  36272. private _applyBoundRadiusAnimation(radiusDelta);
  36273. /**
  36274. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36275. */
  36276. protected _clearAnimationLocks(): void;
  36277. /**
  36278. * Stops and removes all animations that have been applied to the camera
  36279. */
  36280. stopAllAnimations(): void;
  36281. }
  36282. }
  36283. declare module BABYLON {
  36284. class FramingBehavior implements Behavior<ArcRotateCamera> {
  36285. readonly name: string;
  36286. private _mode;
  36287. private _radiusScale;
  36288. private _positionScale;
  36289. private _defaultElevation;
  36290. private _elevationReturnTime;
  36291. private _elevationReturnWaitTime;
  36292. private _zoomStopsAnimation;
  36293. private _framingTime;
  36294. /**
  36295. * The easing function used by animations
  36296. */
  36297. static EasingFunction: ExponentialEase;
  36298. /**
  36299. * The easing mode used by animations
  36300. */
  36301. static EasingMode: number;
  36302. /**
  36303. * Gets current mode used by the behavior.
  36304. */
  36305. /**
  36306. * Sets the current mode used by the behavior
  36307. */
  36308. mode: number;
  36309. /**
  36310. * Gets the scale applied to the radius
  36311. */
  36312. /**
  36313. * Sets the scale applied to the radius (1 by default)
  36314. */
  36315. radiusScale: number;
  36316. /**
  36317. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36318. */
  36319. /**
  36320. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36321. */
  36322. positionScale: number;
  36323. /**
  36324. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36325. * behaviour is triggered, in radians.
  36326. */
  36327. /**
  36328. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36329. * behaviour is triggered, in radians.
  36330. */
  36331. defaultElevation: number;
  36332. /**
  36333. * Gets the time (in milliseconds) taken to return to the default beta position.
  36334. * Negative value indicates camera should not return to default.
  36335. */
  36336. /**
  36337. * Sets the time (in milliseconds) taken to return to the default beta position.
  36338. * Negative value indicates camera should not return to default.
  36339. */
  36340. elevationReturnTime: number;
  36341. /**
  36342. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36343. */
  36344. /**
  36345. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36346. */
  36347. elevationReturnWaitTime: number;
  36348. /**
  36349. * Gets the flag that indicates if user zooming should stop animation.
  36350. */
  36351. /**
  36352. * Sets the flag that indicates if user zooming should stop animation.
  36353. */
  36354. zoomStopsAnimation: boolean;
  36355. /**
  36356. * Gets the transition time when framing the mesh, in milliseconds
  36357. */
  36358. /**
  36359. * Sets the transition time when framing the mesh, in milliseconds
  36360. */
  36361. framingTime: number;
  36362. private _onPrePointerObservableObserver;
  36363. private _onAfterCheckInputsObserver;
  36364. private _onMeshTargetChangedObserver;
  36365. private _attachedCamera;
  36366. private _isPointerDown;
  36367. private _lastInteractionTime;
  36368. init(): void;
  36369. attach(camera: ArcRotateCamera): void;
  36370. detach(): void;
  36371. private _animatables;
  36372. private _betaIsAnimating;
  36373. private _betaTransition;
  36374. private _radiusTransition;
  36375. private _vectorTransition;
  36376. /**
  36377. * Targets the given mesh and updates zoom level accordingly.
  36378. * @param mesh The mesh to target.
  36379. * @param radius Optional. If a cached radius position already exists, overrides default.
  36380. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36381. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36382. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36383. */
  36384. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36385. /**
  36386. * Targets the given mesh with its children and updates zoom level accordingly.
  36387. * @param mesh The mesh to target.
  36388. * @param radius Optional. If a cached radius position already exists, overrides default.
  36389. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36390. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36391. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36392. */
  36393. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36394. /**
  36395. * Targets the given meshes with their children and updates zoom level accordingly.
  36396. * @param meshes The mesh to target.
  36397. * @param radius Optional. If a cached radius position already exists, overrides default.
  36398. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36399. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36400. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36401. */
  36402. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36403. /**
  36404. * Targets the given mesh and updates zoom level accordingly.
  36405. * @param mesh The mesh to target.
  36406. * @param radius Optional. If a cached radius position already exists, overrides default.
  36407. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36408. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36409. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36410. */
  36411. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36412. /**
  36413. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36414. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36415. * frustum width.
  36416. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36417. * to fully enclose the mesh in the viewing frustum.
  36418. */
  36419. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36420. /**
  36421. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36422. * is automatically returned to its default position (expected to be above ground plane).
  36423. */
  36424. private _maintainCameraAboveGround();
  36425. /**
  36426. * Returns the frustum slope based on the canvas ratio and camera FOV
  36427. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36428. */
  36429. private _getFrustumSlope();
  36430. /**
  36431. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36432. */
  36433. private _clearAnimationLocks();
  36434. /**
  36435. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36436. */
  36437. private _applyUserInteraction();
  36438. /**
  36439. * Stops and removes all animations that have been applied to the camera
  36440. */
  36441. stopAllAnimations(): void;
  36442. /**
  36443. * Gets a value indicating if the user is moving the camera
  36444. */
  36445. readonly isUserIsMoving: boolean;
  36446. /**
  36447. * The camera can move all the way towards the mesh.
  36448. */
  36449. static IgnoreBoundsSizeMode: number;
  36450. /**
  36451. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36452. */
  36453. static FitFrustumSidesMode: number;
  36454. }
  36455. }
  36456. declare module BABYLON {
  36457. /**
  36458. * Google Daydream controller
  36459. */
  36460. class DaydreamController extends WebVRController {
  36461. /**
  36462. * Base Url for the controller model.
  36463. */
  36464. static MODEL_BASE_URL: string;
  36465. /**
  36466. * File name for the controller model.
  36467. */
  36468. static MODEL_FILENAME: string;
  36469. /**
  36470. * Gamepad Id prefix used to identify Daydream Controller.
  36471. */
  36472. static readonly GAMEPAD_ID_PREFIX: string;
  36473. constructor(vrGamepad: any);
  36474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  36475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36476. }
  36477. }
  36478. declare module BABYLON {
  36479. class GearVRController extends WebVRController {
  36480. static MODEL_BASE_URL: string;
  36481. static MODEL_FILENAME: string;
  36482. static readonly GAMEPAD_ID_PREFIX: string;
  36483. private readonly _buttonIndexToObservableNameMap;
  36484. constructor(vrGamepad: any);
  36485. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  36486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36487. }
  36488. }
  36489. declare module BABYLON {
  36490. class GenericController extends WebVRController {
  36491. static readonly MODEL_BASE_URL: string;
  36492. static readonly MODEL_FILENAME: string;
  36493. constructor(vrGamepad: any);
  36494. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  36495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. class OculusTouchController extends WebVRController {
  36500. static MODEL_BASE_URL: string;
  36501. static MODEL_LEFT_FILENAME: string;
  36502. static MODEL_RIGHT_FILENAME: string;
  36503. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  36504. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  36505. constructor(vrGamepad: any);
  36506. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  36507. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36508. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36509. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36510. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36511. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36512. }
  36513. }
  36514. declare module BABYLON {
  36515. enum PoseEnabledControllerType {
  36516. VIVE = 0,
  36517. OCULUS = 1,
  36518. WINDOWS = 2,
  36519. GEAR_VR = 3,
  36520. /**
  36521. * Google Daydream
  36522. */
  36523. DAYDREAM = 4,
  36524. GENERIC = 5,
  36525. }
  36526. interface MutableGamepadButton {
  36527. value: number;
  36528. touched: boolean;
  36529. pressed: boolean;
  36530. }
  36531. interface ExtendedGamepadButton extends GamepadButton {
  36532. readonly pressed: boolean;
  36533. readonly touched: boolean;
  36534. readonly value: number;
  36535. }
  36536. class PoseEnabledControllerHelper {
  36537. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  36538. }
  36539. class PoseEnabledController extends Gamepad implements PoseControlled {
  36540. private _deviceRoomPosition;
  36541. private _deviceRoomRotationQuaternion;
  36542. devicePosition: Vector3;
  36543. deviceRotationQuaternion: Quaternion;
  36544. deviceScaleFactor: number;
  36545. position: Vector3;
  36546. rotationQuaternion: Quaternion;
  36547. controllerType: PoseEnabledControllerType;
  36548. private _calculatedPosition;
  36549. private _calculatedRotation;
  36550. rawPose: DevicePose;
  36551. _mesh: Nullable<AbstractMesh>;
  36552. private _poseControlledCamera;
  36553. private _leftHandSystemQuaternion;
  36554. _deviceToWorld: Matrix;
  36555. /**
  36556. * Node to be used when casting a ray from the controller
  36557. */
  36558. _pointingPoseNode: Nullable<AbstractMesh>;
  36559. /**
  36560. * Name of the child mesh that can be used to cast a ray from the controller
  36561. */
  36562. static readonly POINTING_POSE: string;
  36563. constructor(browserGamepad: any);
  36564. private _workingMatrix;
  36565. update(): void;
  36566. updateFromDevice(poseData: DevicePose): void;
  36567. attachToMesh(mesh: AbstractMesh): void;
  36568. attachToPoseControlledCamera(camera: TargetCamera): void;
  36569. dispose(): void;
  36570. readonly mesh: Nullable<AbstractMesh>;
  36571. getForwardRay(length?: number): Ray;
  36572. }
  36573. }
  36574. declare module BABYLON {
  36575. class ViveController extends WebVRController {
  36576. static MODEL_BASE_URL: string;
  36577. static MODEL_FILENAME: string;
  36578. constructor(vrGamepad: any);
  36579. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  36580. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36581. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36582. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36583. /**
  36584. * Vive mapping:
  36585. * 0: touchpad
  36586. * 1: trigger
  36587. * 2: left AND right buttons
  36588. * 3: menu button
  36589. */
  36590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36591. }
  36592. }
  36593. declare module BABYLON {
  36594. abstract class WebVRController extends PoseEnabledController {
  36595. protected _defaultModel: AbstractMesh;
  36596. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  36597. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36598. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36599. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  36600. onPadValuesChangedObservable: Observable<StickValues>;
  36601. protected _buttons: Array<MutableGamepadButton>;
  36602. private _onButtonStateChange;
  36603. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  36604. pad: StickValues;
  36605. hand: string;
  36606. readonly defaultModel: AbstractMesh;
  36607. constructor(vrGamepad: any);
  36608. update(): void;
  36609. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36610. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  36611. private _setButtonValue(newState, currentState, buttonIndex);
  36612. private _changes;
  36613. private _checkChanges(newState, currentState);
  36614. dispose(): void;
  36615. }
  36616. }
  36617. declare module BABYLON {
  36618. class WindowsMotionController extends WebVRController {
  36619. static MODEL_BASE_URL: string;
  36620. static MODEL_LEFT_FILENAME: string;
  36621. static MODEL_RIGHT_FILENAME: string;
  36622. static readonly GAMEPAD_ID_PREFIX: string;
  36623. private static readonly GAMEPAD_ID_PATTERN;
  36624. private _loadedMeshInfo;
  36625. private readonly _mapping;
  36626. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  36627. onTrackpadValuesChangedObservable: Observable<StickValues>;
  36628. trackpad: StickValues;
  36629. constructor(vrGamepad: any);
  36630. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36631. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36632. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36633. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36634. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  36635. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  36636. /**
  36637. * Called once per frame by the engine.
  36638. */
  36639. update(): void;
  36640. /**
  36641. * Called once for each button that changed state since the last frame
  36642. * @param buttonIdx Which button index changed
  36643. * @param state New state of the button
  36644. * @param changes Which properties on the state changed since last frame
  36645. */
  36646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  36647. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  36648. protected lerpAxisTransform(axis: number, axisValue: number): void;
  36649. /**
  36650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36651. * @param scene scene in which to add meshes
  36652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36653. */
  36654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  36655. /**
  36656. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36657. * can be transformed by button presses and axes values, based on this._mapping.
  36658. *
  36659. * @param scene scene in which the meshes exist
  36660. * @param meshes list of meshes that make up the controller model to process
  36661. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36662. */
  36663. private processModel(scene, meshes);
  36664. private createMeshInfo(rootNode);
  36665. getForwardRay(length?: number): Ray;
  36666. dispose(): void;
  36667. }
  36668. }
  36669. declare module BABYLON {
  36670. /**
  36671. * Interface to implement to create a shadow generator compatible with BJS.
  36672. */
  36673. interface IShadowGenerator {
  36674. /**
  36675. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  36676. * @returns The render target texture if present otherwise, null
  36677. */
  36678. getShadowMap(): Nullable<RenderTargetTexture>;
  36679. /**
  36680. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  36681. * @returns The render target texture if the shadow map is present otherwise, null
  36682. */
  36683. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  36684. /**
  36685. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  36686. * @param subMesh The submesh we want to render in the shadow map
  36687. * @param useInstances Defines wether will draw in the map using instances
  36688. * @returns true if ready otherwise, false
  36689. */
  36690. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36691. /**
  36692. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  36693. * @param defines Defines of the material we want to update
  36694. * @param lightIndex Index of the light in the enabled light list of the material
  36695. */
  36696. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  36697. /**
  36698. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  36699. * defined in the generator but impacting the effect).
  36700. * It implies the unifroms available on the materials are the standard BJS ones.
  36701. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  36702. * @param effect The effect we are binfing the information for
  36703. */
  36704. bindShadowLight(lightIndex: string, effect: Effect): void;
  36705. /**
  36706. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  36707. * (eq to shadow prjection matrix * light transform matrix)
  36708. * @returns The transform matrix used to create the shadow map
  36709. */
  36710. getTransformMatrix(): Matrix;
  36711. /**
  36712. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  36713. * Cube and 2D textures for instance.
  36714. */
  36715. recreateShadowMap(): void;
  36716. /**
  36717. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  36718. * @param onCompiled Callback triggered at the and of the effects compilation
  36719. * @param options Sets of optional options forcing the compilation with different modes
  36720. */
  36721. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  36722. useInstances: boolean;
  36723. }>): void;
  36724. /**
  36725. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  36726. * @param options Sets of optional options forcing the compilation with different modes
  36727. * @returns A promise that resolves when the compilation completes
  36728. */
  36729. forceCompilationAsync(options?: Partial<{
  36730. useInstances: boolean;
  36731. }>): Promise<void>;
  36732. /**
  36733. * Serializes the shadow generator setup to a json object.
  36734. * @returns The serialized JSON object
  36735. */
  36736. serialize(): any;
  36737. /**
  36738. * Disposes the Shadow map and related Textures and effects.
  36739. */
  36740. dispose(): void;
  36741. }
  36742. /**
  36743. * Default implementation IShadowGenerator.
  36744. * This is the main object responsible of generating shadows in the framework.
  36745. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  36746. */
  36747. class ShadowGenerator implements IShadowGenerator {
  36748. /**
  36749. * Shadow generator mode None: no filtering applied.
  36750. */
  36751. static readonly FILTER_NONE: number;
  36752. /**
  36753. * Shadow generator mode ESM: Exponential Shadow Mapping.
  36754. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  36755. */
  36756. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  36757. /**
  36758. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  36759. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  36760. */
  36761. static readonly FILTER_POISSONSAMPLING: number;
  36762. /**
  36763. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  36764. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  36765. */
  36766. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  36767. /**
  36768. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  36769. * edge artifacts on steep falloff.
  36770. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  36771. */
  36772. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  36773. /**
  36774. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  36775. * edge artifacts on steep falloff.
  36776. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  36777. */
  36778. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  36779. /**
  36780. * Shadow generator mode PCF: Percentage Closer Filtering
  36781. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  36782. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  36783. */
  36784. static readonly FILTER_PCF: number;
  36785. /**
  36786. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  36787. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  36788. * Contact Hardening
  36789. */
  36790. static readonly FILTER_PCSS: number;
  36791. /**
  36792. * Reserved for PCF and PCSS
  36793. * Highest Quality.
  36794. *
  36795. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  36796. *
  36797. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  36798. */
  36799. static readonly QUALITY_HIGH: number;
  36800. /**
  36801. * Reserved for PCF and PCSS
  36802. * Good tradeoff for quality/perf cross devices
  36803. *
  36804. * Execute PCF on a 3*3 kernel.
  36805. *
  36806. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  36807. */
  36808. static readonly QUALITY_MEDIUM: number;
  36809. /**
  36810. * Reserved for PCF and PCSS
  36811. * The lowest quality but the fastest.
  36812. *
  36813. * Execute PCF on a 1*1 kernel.
  36814. *
  36815. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  36816. */
  36817. static readonly QUALITY_LOW: number;
  36818. private _bias;
  36819. /**
  36820. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  36821. */
  36822. /**
  36823. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  36824. */
  36825. bias: number;
  36826. private _normalBias;
  36827. /**
  36828. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  36829. */
  36830. /**
  36831. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  36832. */
  36833. normalBias: number;
  36834. private _blurBoxOffset;
  36835. /**
  36836. * Gets the blur box offset: offset applied during the blur pass.
  36837. * Only usefull if useKernelBlur = false
  36838. */
  36839. /**
  36840. * Sets the blur box offset: offset applied during the blur pass.
  36841. * Only usefull if useKernelBlur = false
  36842. */
  36843. blurBoxOffset: number;
  36844. private _blurScale;
  36845. /**
  36846. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  36847. * 2 means half of the size.
  36848. */
  36849. /**
  36850. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  36851. * 2 means half of the size.
  36852. */
  36853. blurScale: number;
  36854. private _blurKernel;
  36855. /**
  36856. * Gets the blur kernel: kernel size of the blur pass.
  36857. * Only usefull if useKernelBlur = true
  36858. */
  36859. /**
  36860. * Sets the blur kernel: kernel size of the blur pass.
  36861. * Only usefull if useKernelBlur = true
  36862. */
  36863. blurKernel: number;
  36864. private _useKernelBlur;
  36865. /**
  36866. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  36867. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  36868. */
  36869. /**
  36870. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  36871. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  36872. */
  36873. useKernelBlur: boolean;
  36874. private _depthScale;
  36875. /**
  36876. * Gets the depth scale used in ESM mode.
  36877. */
  36878. /**
  36879. * Sets the depth scale used in ESM mode.
  36880. * This can override the scale stored on the light.
  36881. */
  36882. depthScale: number;
  36883. private _filter;
  36884. /**
  36885. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  36886. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  36887. */
  36888. /**
  36889. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  36890. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  36891. */
  36892. filter: number;
  36893. /**
  36894. * Gets if the current filter is set to Poisson Sampling.
  36895. */
  36896. /**
  36897. * Sets the current filter to Poisson Sampling.
  36898. */
  36899. usePoissonSampling: boolean;
  36900. /**
  36901. * Gets if the current filter is set to VSM.
  36902. * DEPRECATED. Should use useExponentialShadowMap instead.
  36903. */
  36904. /**
  36905. * Sets the current filter is to VSM.
  36906. * DEPRECATED. Should use useExponentialShadowMap instead.
  36907. */
  36908. useVarianceShadowMap: boolean;
  36909. /**
  36910. * Gets if the current filter is set to blurred VSM.
  36911. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  36912. */
  36913. /**
  36914. * Sets the current filter is to blurred VSM.
  36915. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  36916. */
  36917. useBlurVarianceShadowMap: boolean;
  36918. /**
  36919. * Gets if the current filter is set to ESM.
  36920. */
  36921. /**
  36922. * Sets the current filter is to ESM.
  36923. */
  36924. useExponentialShadowMap: boolean;
  36925. /**
  36926. * Gets if the current filter is set to filtered ESM.
  36927. */
  36928. /**
  36929. * Gets if the current filter is set to filtered ESM.
  36930. */
  36931. useBlurExponentialShadowMap: boolean;
  36932. /**
  36933. * Gets if the current filter is set to "close ESM" (using the inverse of the
  36934. * exponential to prevent steep falloff artifacts).
  36935. */
  36936. /**
  36937. * Sets the current filter to "close ESM" (using the inverse of the
  36938. * exponential to prevent steep falloff artifacts).
  36939. */
  36940. useCloseExponentialShadowMap: boolean;
  36941. /**
  36942. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  36943. * exponential to prevent steep falloff artifacts).
  36944. */
  36945. /**
  36946. * Sets the current filter to filtered "close ESM" (using the inverse of the
  36947. * exponential to prevent steep falloff artifacts).
  36948. */
  36949. useBlurCloseExponentialShadowMap: boolean;
  36950. /**
  36951. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  36952. */
  36953. /**
  36954. * Sets the current filter to "PCF" (percentage closer filtering).
  36955. */
  36956. usePercentageCloserFiltering: boolean;
  36957. private _filteringQuality;
  36958. /**
  36959. * Gets the PCF or PCSS Quality.
  36960. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  36961. */
  36962. /**
  36963. * Sets the PCF or PCSS Quality.
  36964. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  36965. */
  36966. filteringQuality: number;
  36967. /**
  36968. * Gets if the current filter is set to "PCSS" (contact hardening).
  36969. */
  36970. /**
  36971. * Sets the current filter to "PCSS" (contact hardening).
  36972. */
  36973. useContactHardeningShadow: boolean;
  36974. private _contactHardeningLightSizeUVRatio;
  36975. /**
  36976. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  36977. * Using a ratio helps keeping shape stability independently of the map size.
  36978. *
  36979. * It does not account for the light projection as it was having too much
  36980. * instability during the light setup or during light position changes.
  36981. *
  36982. * Only valid if useContactHardeningShadow is true.
  36983. */
  36984. /**
  36985. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  36986. * Using a ratio helps keeping shape stability independently of the map size.
  36987. *
  36988. * It does not account for the light projection as it was having too much
  36989. * instability during the light setup or during light position changes.
  36990. *
  36991. * Only valid if useContactHardeningShadow is true.
  36992. */
  36993. contactHardeningLightSizeUVRatio: number;
  36994. private _darkness;
  36995. /**
  36996. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  36997. * 0 means strongest and 1 would means no shadow.
  36998. * @returns the darkness.
  36999. */
  37000. getDarkness(): number;
  37001. /**
  37002. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  37003. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  37004. * @returns the shadow generator allowing fluent coding.
  37005. */
  37006. setDarkness(darkness: number): ShadowGenerator;
  37007. private _transparencyShadow;
  37008. /**
  37009. * Sets the ability to have transparent shadow (boolean).
  37010. * @param transparent True if transparent else False
  37011. * @returns the shadow generator allowing fluent coding
  37012. */
  37013. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  37014. private _shadowMap;
  37015. private _shadowMap2;
  37016. /**
  37017. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  37018. * @returns The render target texture if present otherwise, null
  37019. */
  37020. getShadowMap(): Nullable<RenderTargetTexture>;
  37021. /**
  37022. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  37023. * @returns The render target texture if the shadow map is present otherwise, null
  37024. */
  37025. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  37026. /**
  37027. * Helper function to add a mesh and its descendants to the list of shadow casters.
  37028. * @param mesh Mesh to add
  37029. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  37030. * @returns the Shadow Generator itself
  37031. */
  37032. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  37033. /**
  37034. * Helper function to remove a mesh and its descendants from the list of shadow casters
  37035. * @param mesh Mesh to remove
  37036. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  37037. * @returns the Shadow Generator itself
  37038. */
  37039. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  37040. /**
  37041. * Controls the extent to which the shadows fade out at the edge of the frustum
  37042. * Used only by directionals and spots
  37043. */
  37044. frustumEdgeFalloff: number;
  37045. private _light;
  37046. /**
  37047. * Returns the associated light object.
  37048. * @returns the light generating the shadow
  37049. */
  37050. getLight(): IShadowLight;
  37051. /**
  37052. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  37053. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  37054. * It might on the other hand introduce peter panning.
  37055. */
  37056. forceBackFacesOnly: boolean;
  37057. private _scene;
  37058. private _lightDirection;
  37059. private _effect;
  37060. private _viewMatrix;
  37061. private _projectionMatrix;
  37062. private _transformMatrix;
  37063. private _cachedPosition;
  37064. private _cachedDirection;
  37065. private _cachedDefines;
  37066. private _currentRenderID;
  37067. private _boxBlurPostprocess;
  37068. private _kernelBlurXPostprocess;
  37069. private _kernelBlurYPostprocess;
  37070. private _blurPostProcesses;
  37071. private _mapSize;
  37072. private _currentFaceIndex;
  37073. private _currentFaceIndexCache;
  37074. private _textureType;
  37075. private _defaultTextureMatrix;
  37076. /**
  37077. * Creates a ShadowGenerator object.
  37078. * A ShadowGenerator is the required tool to use the shadows.
  37079. * Each light casting shadows needs to use its own ShadowGenerator.
  37080. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  37081. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  37082. * @param light The light object generating the shadows.
  37083. * @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.
  37084. */
  37085. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  37086. private _initializeGenerator();
  37087. private _initializeShadowMap();
  37088. private _initializeBlurRTTAndPostProcesses();
  37089. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  37090. private _renderSubMeshForShadowMap(subMesh);
  37091. private _applyFilterValues();
  37092. /**
  37093. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  37094. * @param onCompiled Callback triggered at the and of the effects compilation
  37095. * @param options Sets of optional options forcing the compilation with different modes
  37096. */
  37097. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  37098. useInstances: boolean;
  37099. }>): void;
  37100. /**
  37101. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  37102. * @param options Sets of optional options forcing the compilation with different modes
  37103. * @returns A promise that resolves when the compilation completes
  37104. */
  37105. forceCompilationAsync(options?: Partial<{
  37106. useInstances: boolean;
  37107. }>): Promise<void>;
  37108. /**
  37109. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  37110. * @param subMesh The submesh we want to render in the shadow map
  37111. * @param useInstances Defines wether will draw in the map using instances
  37112. * @returns true if ready otherwise, false
  37113. */
  37114. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  37115. /**
  37116. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  37117. * @param defines Defines of the material we want to update
  37118. * @param lightIndex Index of the light in the enabled light list of the material
  37119. */
  37120. prepareDefines(defines: any, lightIndex: number): void;
  37121. /**
  37122. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  37123. * defined in the generator but impacting the effect).
  37124. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  37125. * @param effect The effect we are binfing the information for
  37126. */
  37127. bindShadowLight(lightIndex: string, effect: Effect): void;
  37128. /**
  37129. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  37130. * (eq to shadow prjection matrix * light transform matrix)
  37131. * @returns The transform matrix used to create the shadow map
  37132. */
  37133. getTransformMatrix(): Matrix;
  37134. /**
  37135. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  37136. * Cube and 2D textures for instance.
  37137. */
  37138. recreateShadowMap(): void;
  37139. private _disposeBlurPostProcesses();
  37140. private _disposeRTTandPostProcesses();
  37141. /**
  37142. * Disposes the ShadowGenerator.
  37143. * Returns nothing.
  37144. */
  37145. dispose(): void;
  37146. /**
  37147. * Serializes the shadow generator setup to a json object.
  37148. * @returns The serialized JSON object
  37149. */
  37150. serialize(): any;
  37151. /**
  37152. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  37153. * @param parsedShadowGenerator The JSON object to parse
  37154. * @param scene The scene to create the shadow map for
  37155. * @returns The parsed shadow generator
  37156. */
  37157. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  37158. }
  37159. }
  37160. declare module BABYLON {
  37161. }
  37162. declare var DracoDecoderModule: any;
  37163. declare module BABYLON {
  37164. /**
  37165. * Draco compression (https://google.github.io/draco/)
  37166. */
  37167. class DracoCompression implements IDisposable {
  37168. private _workerPool;
  37169. /**
  37170. * Gets the url to the draco decoder if available.
  37171. */
  37172. static DecoderUrl: Nullable<string>;
  37173. /**
  37174. * Constructor
  37175. * @param numWorkers The number of workers for async operations
  37176. */
  37177. constructor(numWorkers?: number);
  37178. /**
  37179. * Stop all async operations and release resources.
  37180. */
  37181. dispose(): void;
  37182. /**
  37183. * Decode Draco compressed mesh data to vertex data.
  37184. * @param data The array buffer view for the Draco compression data
  37185. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  37186. * @returns A promise that resolves with the decoded vertex data
  37187. */
  37188. decodeMeshAsync(data: ArrayBufferView, attributes: {
  37189. [kind: string]: number;
  37190. }): Promise<VertexData>;
  37191. /**
  37192. * The worker function that gets converted to a blob url to pass into a worker.
  37193. */
  37194. private static _Worker();
  37195. private static _GetDefaultDecoderUrl();
  37196. }
  37197. }
  37198. declare module BABYLON {
  37199. /**
  37200. * Background material used to create an efficient environement around your scene.
  37201. */
  37202. class BackgroundMaterial extends PushMaterial {
  37203. /**
  37204. * Standard reflectance value at parallel view angle.
  37205. */
  37206. static StandardReflectance0: number;
  37207. /**
  37208. * Standard reflectance value at grazing angle.
  37209. */
  37210. static StandardReflectance90: number;
  37211. protected _primaryColor: Color3;
  37212. /**
  37213. * Key light Color (multiply against the R channel of the environement texture)
  37214. */
  37215. primaryColor: Color3;
  37216. protected _primaryLevel: float;
  37217. /**
  37218. * Key light Level (allowing HDR output of the background)
  37219. */
  37220. primaryLevel: float;
  37221. protected _secondaryColor: Color3;
  37222. /**
  37223. * Secondary light Color (multiply against the G channel of the environement texture)
  37224. */
  37225. secondaryColor: Color3;
  37226. protected _secondaryLevel: float;
  37227. /**
  37228. * Secondary light Level (allowing HDR output of the background)
  37229. */
  37230. secondaryLevel: float;
  37231. protected _tertiaryColor: Color3;
  37232. /**
  37233. * Tertiary light Color (multiply against the B channel of the environement texture)
  37234. */
  37235. tertiaryColor: Color3;
  37236. protected _tertiaryLevel: float;
  37237. /**
  37238. * Tertiary light Level (allowing HDR output of the background)
  37239. */
  37240. tertiaryLevel: float;
  37241. protected _reflectionTexture: Nullable<BaseTexture>;
  37242. /**
  37243. * Reflection Texture used in the material.
  37244. * Should be author in a specific way for the best result (refer to the documentation).
  37245. */
  37246. reflectionTexture: Nullable<BaseTexture>;
  37247. protected _reflectionBlur: float;
  37248. /**
  37249. * Reflection Texture level of blur.
  37250. *
  37251. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  37252. * texture twice.
  37253. */
  37254. reflectionBlur: float;
  37255. protected _diffuseTexture: Nullable<BaseTexture>;
  37256. /**
  37257. * Diffuse Texture used in the material.
  37258. * Should be author in a specific way for the best result (refer to the documentation).
  37259. */
  37260. diffuseTexture: Nullable<BaseTexture>;
  37261. protected _shadowLights: Nullable<IShadowLight[]>;
  37262. /**
  37263. * Specify the list of lights casting shadow on the material.
  37264. * All scene shadow lights will be included if null.
  37265. */
  37266. shadowLights: Nullable<IShadowLight[]>;
  37267. protected _shadowBlurScale: int;
  37268. /**
  37269. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  37270. * soft lighting on the background.
  37271. */
  37272. shadowBlurScale: int;
  37273. protected _shadowLevel: float;
  37274. /**
  37275. * Helps adjusting the shadow to a softer level if required.
  37276. * 0 means black shadows and 1 means no shadows.
  37277. */
  37278. shadowLevel: float;
  37279. protected _sceneCenter: Vector3;
  37280. /**
  37281. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  37282. * It is usually zero but might be interesting to modify according to your setup.
  37283. */
  37284. sceneCenter: Vector3;
  37285. protected _opacityFresnel: boolean;
  37286. /**
  37287. * This helps specifying that the material is falling off to the sky box at grazing angle.
  37288. * This helps ensuring a nice transition when the camera goes under the ground.
  37289. */
  37290. opacityFresnel: boolean;
  37291. protected _reflectionFresnel: boolean;
  37292. /**
  37293. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  37294. * This helps adding a mirror texture on the ground.
  37295. */
  37296. reflectionFresnel: boolean;
  37297. protected _reflectionFalloffDistance: number;
  37298. /**
  37299. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  37300. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  37301. */
  37302. reflectionFalloffDistance: number;
  37303. protected _reflectionAmount: number;
  37304. /**
  37305. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  37306. */
  37307. reflectionAmount: number;
  37308. protected _reflectionReflectance0: number;
  37309. /**
  37310. * This specifies the weight of the reflection at grazing angle.
  37311. */
  37312. reflectionReflectance0: number;
  37313. protected _reflectionReflectance90: number;
  37314. /**
  37315. * This specifies the weight of the reflection at a perpendicular point of view.
  37316. */
  37317. reflectionReflectance90: number;
  37318. /**
  37319. * Sets the reflection reflectance fresnel values according to the default standard
  37320. * empirically know to work well :-)
  37321. */
  37322. reflectionStandardFresnelWeight: number;
  37323. protected _useRGBColor: boolean;
  37324. /**
  37325. * Helps to directly use the maps channels instead of their level.
  37326. */
  37327. useRGBColor: boolean;
  37328. protected _enableNoise: boolean;
  37329. /**
  37330. * This helps reducing the banding effect that could occur on the background.
  37331. */
  37332. enableNoise: boolean;
  37333. /**
  37334. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  37335. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  37336. * Recommended to be keep at 1.0 except for special cases.
  37337. */
  37338. fovMultiplier: number;
  37339. private _fovMultiplier;
  37340. /**
  37341. * Enable the FOV adjustment feature controlled by fovMultiplier.
  37342. * @type {boolean}
  37343. */
  37344. useEquirectangularFOV: boolean;
  37345. private _maxSimultaneousLights;
  37346. /**
  37347. * Number of Simultaneous lights allowed on the material.
  37348. */
  37349. maxSimultaneousLights: int;
  37350. /**
  37351. * Default configuration related to image processing available in the Background Material.
  37352. */
  37353. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37354. /**
  37355. * Keep track of the image processing observer to allow dispose and replace.
  37356. */
  37357. private _imageProcessingObserver;
  37358. /**
  37359. * Attaches a new image processing configuration to the PBR Material.
  37360. * @param configuration (if null the scene configuration will be use)
  37361. */
  37362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37363. /**
  37364. * Gets the image processing configuration used either in this material.
  37365. */
  37366. /**
  37367. * Sets the Default image processing configuration used either in the this material.
  37368. *
  37369. * If sets to null, the scene one is in use.
  37370. */
  37371. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  37372. /**
  37373. * Gets wether the color curves effect is enabled.
  37374. */
  37375. /**
  37376. * Sets wether the color curves effect is enabled.
  37377. */
  37378. cameraColorCurvesEnabled: boolean;
  37379. /**
  37380. * Gets wether the color grading effect is enabled.
  37381. */
  37382. /**
  37383. * Gets wether the color grading effect is enabled.
  37384. */
  37385. cameraColorGradingEnabled: boolean;
  37386. /**
  37387. * Gets wether tonemapping is enabled or not.
  37388. */
  37389. /**
  37390. * Sets wether tonemapping is enabled or not
  37391. */
  37392. cameraToneMappingEnabled: boolean;
  37393. /**
  37394. * The camera exposure used on this material.
  37395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37396. * This corresponds to a photographic exposure.
  37397. */
  37398. /**
  37399. * The camera exposure used on this material.
  37400. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37401. * This corresponds to a photographic exposure.
  37402. */
  37403. cameraExposure: float;
  37404. /**
  37405. * Gets The camera contrast used on this material.
  37406. */
  37407. /**
  37408. * Sets The camera contrast used on this material.
  37409. */
  37410. cameraContrast: float;
  37411. /**
  37412. * Gets the Color Grading 2D Lookup Texture.
  37413. */
  37414. /**
  37415. * Sets the Color Grading 2D Lookup Texture.
  37416. */
  37417. cameraColorGradingTexture: Nullable<BaseTexture>;
  37418. /**
  37419. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37420. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37421. * 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;
  37422. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37423. */
  37424. /**
  37425. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37426. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37427. * 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;
  37428. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37429. */
  37430. cameraColorCurves: Nullable<ColorCurves>;
  37431. /**
  37432. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  37433. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  37434. */
  37435. switchToBGR: boolean;
  37436. private _renderTargets;
  37437. private _reflectionControls;
  37438. /**
  37439. * Instantiates a Background Material in the given scene
  37440. * @param name The friendly name of the material
  37441. * @param scene The scene to add the material to
  37442. */
  37443. constructor(name: string, scene: Scene);
  37444. /**
  37445. * The entire material has been created in order to prevent overdraw.
  37446. * @returns false
  37447. */
  37448. needAlphaTesting(): boolean;
  37449. /**
  37450. * The entire material has been created in order to prevent overdraw.
  37451. * @returns true if blending is enable
  37452. */
  37453. needAlphaBlending(): boolean;
  37454. /**
  37455. * Checks wether the material is ready to be rendered for a given mesh.
  37456. * @param mesh The mesh to render
  37457. * @param subMesh The submesh to check against
  37458. * @param useInstances Specify wether or not the material is used with instances
  37459. * @returns true if all the dependencies are ready (Textures, Effects...)
  37460. */
  37461. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37462. /**
  37463. * Build the uniform buffer used in the material.
  37464. */
  37465. buildUniformLayout(): void;
  37466. /**
  37467. * Unbind the material.
  37468. */
  37469. unbind(): void;
  37470. /**
  37471. * Bind only the world matrix to the material.
  37472. * @param world The world matrix to bind.
  37473. */
  37474. bindOnlyWorldMatrix(world: Matrix): void;
  37475. /**
  37476. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  37477. * @param world The world matrix to bind.
  37478. * @param subMesh The submesh to bind for.
  37479. */
  37480. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37481. /**
  37482. * Dispose the material.
  37483. * @param forceDisposeEffect Force disposal of the associated effect.
  37484. * @param forceDisposeTextures Force disposal of the associated textures.
  37485. */
  37486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37487. /**
  37488. * Clones the material.
  37489. * @param name The cloned name.
  37490. * @returns The cloned material.
  37491. */
  37492. clone(name: string): BackgroundMaterial;
  37493. /**
  37494. * Serializes the current material to its JSON representation.
  37495. * @returns The JSON representation.
  37496. */
  37497. serialize(): any;
  37498. /**
  37499. * Gets the class name of the material
  37500. * @returns "BackgroundMaterial"
  37501. */
  37502. getClassName(): string;
  37503. /**
  37504. * Parse a JSON input to create back a background material.
  37505. * @param source The JSON data to parse
  37506. * @param scene The scene to create the parsed material in
  37507. * @param rootUrl The root url of the assets the material depends upon
  37508. * @returns the instantiated BackgroundMaterial.
  37509. */
  37510. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  37511. }
  37512. }
  37513. declare module BABYLON {
  37514. class BaseTexture {
  37515. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37516. name: string;
  37517. private _hasAlpha;
  37518. hasAlpha: boolean;
  37519. getAlphaFromRGB: boolean;
  37520. level: number;
  37521. coordinatesIndex: number;
  37522. private _coordinatesMode;
  37523. /**
  37524. * How a texture is mapped.
  37525. *
  37526. * | Value | Type | Description |
  37527. * | ----- | ----------------------------------- | ----------- |
  37528. * | 0 | EXPLICIT_MODE | |
  37529. * | 1 | SPHERICAL_MODE | |
  37530. * | 2 | PLANAR_MODE | |
  37531. * | 3 | CUBIC_MODE | |
  37532. * | 4 | PROJECTION_MODE | |
  37533. * | 5 | SKYBOX_MODE | |
  37534. * | 6 | INVCUBIC_MODE | |
  37535. * | 7 | EQUIRECTANGULAR_MODE | |
  37536. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37537. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37538. */
  37539. coordinatesMode: number;
  37540. /**
  37541. * | Value | Type | Description |
  37542. * | ----- | ------------------ | ----------- |
  37543. * | 0 | CLAMP_ADDRESSMODE | |
  37544. * | 1 | WRAP_ADDRESSMODE | |
  37545. * | 2 | MIRROR_ADDRESSMODE | |
  37546. */
  37547. wrapU: number;
  37548. /**
  37549. * | Value | Type | Description |
  37550. * | ----- | ------------------ | ----------- |
  37551. * | 0 | CLAMP_ADDRESSMODE | |
  37552. * | 1 | WRAP_ADDRESSMODE | |
  37553. * | 2 | MIRROR_ADDRESSMODE | |
  37554. */
  37555. wrapV: number;
  37556. /**
  37557. * | Value | Type | Description |
  37558. * | ----- | ------------------ | ----------- |
  37559. * | 0 | CLAMP_ADDRESSMODE | |
  37560. * | 1 | WRAP_ADDRESSMODE | |
  37561. * | 2 | MIRROR_ADDRESSMODE | |
  37562. */
  37563. wrapR: number;
  37564. anisotropicFilteringLevel: number;
  37565. isCube: boolean;
  37566. is3D: boolean;
  37567. gammaSpace: boolean;
  37568. invertZ: boolean;
  37569. lodLevelInAlpha: boolean;
  37570. lodGenerationOffset: number;
  37571. lodGenerationScale: number;
  37572. isRenderTarget: boolean;
  37573. readonly uid: string;
  37574. toString(): string;
  37575. getClassName(): string;
  37576. animations: Animation[];
  37577. /**
  37578. * An event triggered when the texture is disposed.
  37579. * @type {BABYLON.Observable}
  37580. */
  37581. onDisposeObservable: Observable<BaseTexture>;
  37582. private _onDisposeObserver;
  37583. onDispose: () => void;
  37584. delayLoadState: number;
  37585. private _scene;
  37586. _texture: Nullable<InternalTexture>;
  37587. private _uid;
  37588. readonly isBlocking: boolean;
  37589. constructor(scene: Nullable<Scene>);
  37590. getScene(): Nullable<Scene>;
  37591. getTextureMatrix(): Matrix;
  37592. getReflectionTextureMatrix(): Matrix;
  37593. getInternalTexture(): Nullable<InternalTexture>;
  37594. isReadyOrNotBlocking(): boolean;
  37595. isReady(): boolean;
  37596. getSize(): ISize;
  37597. getBaseSize(): ISize;
  37598. scale(ratio: number): void;
  37599. readonly canRescale: boolean;
  37600. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  37601. _rebuild(): void;
  37602. delayLoad(): void;
  37603. clone(): Nullable<BaseTexture>;
  37604. readonly textureType: number;
  37605. readonly textureFormat: number;
  37606. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  37607. releaseInternalTexture(): void;
  37608. sphericalPolynomial: Nullable<SphericalPolynomial>;
  37609. readonly _lodTextureHigh: Nullable<BaseTexture>;
  37610. readonly _lodTextureMid: Nullable<BaseTexture>;
  37611. readonly _lodTextureLow: Nullable<BaseTexture>;
  37612. dispose(): void;
  37613. serialize(): any;
  37614. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37615. }
  37616. }
  37617. declare module BABYLON {
  37618. /**
  37619. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  37620. * It can help converting any input color in a desired output one. This can then be used to create effects
  37621. * from sepia, black and white to sixties or futuristic rendering...
  37622. *
  37623. * The only supported format is currently 3dl.
  37624. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  37625. */
  37626. class ColorGradingTexture extends BaseTexture {
  37627. /**
  37628. * The current texture matrix. (will always be identity in color grading texture)
  37629. */
  37630. private _textureMatrix;
  37631. /**
  37632. * The texture URL.
  37633. */
  37634. url: string;
  37635. /**
  37636. * Empty line regex stored for GC.
  37637. */
  37638. private static _noneEmptyLineRegex;
  37639. private _engine;
  37640. /**
  37641. * Instantiates a ColorGradingTexture from the following parameters.
  37642. *
  37643. * @param url The location of the color gradind data (currently only supporting 3dl)
  37644. * @param scene The scene the texture will be used in
  37645. */
  37646. constructor(url: string, scene: Scene);
  37647. /**
  37648. * Returns the texture matrix used in most of the material.
  37649. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  37650. */
  37651. getTextureMatrix(): Matrix;
  37652. /**
  37653. * Occurs when the file being loaded is a .3dl LUT file.
  37654. */
  37655. private load3dlTexture();
  37656. /**
  37657. * Starts the loading process of the texture.
  37658. */
  37659. private loadTexture();
  37660. /**
  37661. * Clones the color gradind texture.
  37662. */
  37663. clone(): ColorGradingTexture;
  37664. /**
  37665. * Called during delayed load for textures.
  37666. */
  37667. delayLoad(): void;
  37668. /**
  37669. * Parses a color grading texture serialized by Babylon.
  37670. * @param parsedTexture The texture information being parsedTexture
  37671. * @param scene The scene to load the texture in
  37672. * @param rootUrl The root url of the data assets to load
  37673. * @return A color gradind texture
  37674. */
  37675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  37676. /**
  37677. * Serializes the LUT texture to json format.
  37678. */
  37679. serialize(): any;
  37680. }
  37681. }
  37682. declare module BABYLON {
  37683. class CubeTexture extends BaseTexture {
  37684. url: string;
  37685. coordinatesMode: number;
  37686. /**
  37687. * Gets or sets the center of the bounding box associated with the cube texture
  37688. * It must define where the camera used to render the texture was set
  37689. */
  37690. boundingBoxPosition: Vector3;
  37691. private _boundingBoxSize;
  37692. /**
  37693. * Gets or sets the size of the bounding box associated with the cube texture
  37694. * When defined, the cubemap will switch to local mode
  37695. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37696. * @example https://www.babylonjs-playground.com/#RNASML
  37697. */
  37698. boundingBoxSize: Vector3;
  37699. private _noMipmap;
  37700. private _files;
  37701. private _extensions;
  37702. private _textureMatrix;
  37703. private _format;
  37704. private _prefiltered;
  37705. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  37706. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  37707. 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);
  37708. delayLoad(): void;
  37709. getReflectionTextureMatrix(): Matrix;
  37710. setReflectionTextureMatrix(value: Matrix): void;
  37711. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  37712. clone(): CubeTexture;
  37713. }
  37714. }
  37715. declare module BABYLON {
  37716. /**
  37717. * A class extending {BABYLON.Texture} allowing drawing on a texture
  37718. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37719. */
  37720. class DynamicTexture extends Texture {
  37721. private _generateMipMaps;
  37722. private _canvas;
  37723. private _context;
  37724. private _engine;
  37725. /**
  37726. * Creates a {BABYLON.DynamicTexture}
  37727. * @param name defines the name of the texture
  37728. * @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
  37729. * @param scene defines the scene where you want the texture
  37730. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37731. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37732. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  37733. */
  37734. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37735. /**
  37736. * Gets the current state of canRescale
  37737. */
  37738. readonly canRescale: boolean;
  37739. private _recreate(textureSize);
  37740. /**
  37741. * Scales the texture
  37742. * @param ratio the scale factor to apply to both width and height
  37743. */
  37744. scale(ratio: number): void;
  37745. /**
  37746. * Resizes the texture
  37747. * @param width the new width
  37748. * @param height the new height
  37749. */
  37750. scaleTo(width: number, height: number): void;
  37751. /**
  37752. * Gets the context of the canvas used by the texture
  37753. * @returns the canvas context of the dynamic texture
  37754. */
  37755. getContext(): CanvasRenderingContext2D;
  37756. /**
  37757. * Clears the texture
  37758. */
  37759. clear(): void;
  37760. /**
  37761. * Updates the texture
  37762. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37763. */
  37764. update(invertY?: boolean): void;
  37765. /**
  37766. * Draws text onto the texture
  37767. * @param text defines the text to be drawn
  37768. * @param x defines the placement of the text from the left
  37769. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37770. * @param font defines the font to be used with font-style, font-size, font-name
  37771. * @param color defines the color used for the text
  37772. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37773. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37774. * @param update defines whether texture is immediately update (default is true)
  37775. */
  37776. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37777. /**
  37778. * Clones the texture
  37779. * @returns the clone of the texture.
  37780. */
  37781. clone(): DynamicTexture;
  37782. /** @ignore */
  37783. _rebuild(): void;
  37784. }
  37785. }
  37786. declare module BABYLON {
  37787. /**
  37788. * This represents a texture coming from an HDR input.
  37789. *
  37790. * The only supported format is currently panorama picture stored in RGBE format.
  37791. * Example of such files can be found on HDRLib: http://hdrlib.com/
  37792. */
  37793. class HDRCubeTexture extends BaseTexture {
  37794. private static _facesMapping;
  37795. private _useInGammaSpace;
  37796. private _generateHarmonics;
  37797. private _noMipmap;
  37798. private _textureMatrix;
  37799. private _size;
  37800. private _usePMREMGenerator;
  37801. private _isBABYLONPreprocessed;
  37802. private _onLoad;
  37803. private _onError;
  37804. /**
  37805. * The texture URL.
  37806. */
  37807. url: string;
  37808. /**
  37809. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  37810. */
  37811. coordinatesMode: number;
  37812. /**
  37813. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  37814. * This is usefull at run time to apply the good shader.
  37815. */
  37816. isPMREM: boolean;
  37817. protected _isBlocking: boolean;
  37818. /**
  37819. * Gets wether or not the texture is blocking during loading.
  37820. */
  37821. /**
  37822. * Sets wether or not the texture is blocking during loading.
  37823. */
  37824. isBlocking: boolean;
  37825. /**
  37826. * Gets or sets the center of the bounding box associated with the cube texture
  37827. * It must define where the camera used to render the texture was set
  37828. */
  37829. boundingBoxPosition: Vector3;
  37830. private _boundingBoxSize;
  37831. /**
  37832. * Gets or sets the size of the bounding box associated with the cube texture
  37833. * When defined, the cubemap will switch to local mode
  37834. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37835. * @example https://www.babylonjs-playground.com/#RNASML
  37836. */
  37837. boundingBoxSize: Vector3;
  37838. /**
  37839. * Instantiates an HDRTexture from the following parameters.
  37840. *
  37841. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  37842. * @param scene The scene the texture will be used in
  37843. * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  37844. * @param noMipmap Forces to not generate the mipmap if true
  37845. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  37846. * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  37847. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  37848. */
  37849. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  37850. /**
  37851. * Occurs when the file is a preprocessed .babylon.hdr file.
  37852. */
  37853. private loadBabylonTexture();
  37854. /**
  37855. * Occurs when the file is raw .hdr file.
  37856. */
  37857. private loadHDRTexture();
  37858. /**
  37859. * Starts the loading process of the texture.
  37860. */
  37861. private loadTexture();
  37862. clone(): HDRCubeTexture;
  37863. delayLoad(): void;
  37864. getReflectionTextureMatrix(): Matrix;
  37865. setReflectionTextureMatrix(value: Matrix): void;
  37866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  37867. serialize(): any;
  37868. /**
  37869. * Saves as a file the data contained in the texture in a binary format.
  37870. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  37871. * as the spherical used in the lighting.
  37872. * @param url The HDR file url.
  37873. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  37874. * @param onError Method called if any error happens during download.
  37875. * @return The packed binary data.
  37876. */
  37877. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  37878. /**
  37879. * Serializes the data contained in the texture in a binary format.
  37880. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  37881. * as the spherical used in the lighting.
  37882. * @param url The HDR file url.
  37883. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  37884. * @param onError Method called if any error happens during download.
  37885. * @return The packed binary data.
  37886. */
  37887. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  37888. }
  37889. }
  37890. declare module BABYLON {
  37891. /**
  37892. * Class used to store data associated with WebGL texture data for the engine
  37893. * This class should not be used directly
  37894. */
  37895. class InternalTexture implements IInternalTextureTracker {
  37896. /**
  37897. * The source of the texture data is unknown
  37898. */
  37899. static DATASOURCE_UNKNOWN: number;
  37900. /**
  37901. * Texture data comes from an URL
  37902. */
  37903. static DATASOURCE_URL: number;
  37904. /**
  37905. * Texture data is only used for temporary storage
  37906. */
  37907. static DATASOURCE_TEMP: number;
  37908. /**
  37909. * Texture data comes from raw data (ArrayBuffer)
  37910. */
  37911. static DATASOURCE_RAW: number;
  37912. /**
  37913. * Texture content is dynamic (video or dynamic texture)
  37914. */
  37915. static DATASOURCE_DYNAMIC: number;
  37916. /**
  37917. * Texture content is generated by rendering to it
  37918. */
  37919. static DATASOURCE_RENDERTARGET: number;
  37920. /**
  37921. * Texture content is part of a multi render target process
  37922. */
  37923. static DATASOURCE_MULTIRENDERTARGET: number;
  37924. /**
  37925. * Texture data comes from a cube data file
  37926. */
  37927. static DATASOURCE_CUBE: number;
  37928. /**
  37929. * Texture data comes from a raw cube data
  37930. */
  37931. static DATASOURCE_CUBERAW: number;
  37932. /**
  37933. * Texture data come from a prefiltered cube data file
  37934. */
  37935. static DATASOURCE_CUBEPREFILTERED: number;
  37936. /**
  37937. * Texture content is raw 3D data
  37938. */
  37939. static DATASOURCE_RAW3D: number;
  37940. /**
  37941. * Texture content is a depth texture
  37942. */
  37943. static DATASOURCE_DEPTHTEXTURE: number;
  37944. /**
  37945. * Defines if the texture is ready
  37946. */
  37947. isReady: boolean;
  37948. /**
  37949. * Defines if the texture is a cube texture
  37950. */
  37951. isCube: boolean;
  37952. /**
  37953. * Defines if the texture contains 3D data
  37954. */
  37955. is3D: boolean;
  37956. /**
  37957. * Gets the URL used to load this texture
  37958. */
  37959. url: string;
  37960. /**
  37961. * Gets the sampling mode of the texture
  37962. */
  37963. samplingMode: number;
  37964. /**
  37965. * Gets a boolean indicating if the texture needs mipmaps generation
  37966. */
  37967. generateMipMaps: boolean;
  37968. /**
  37969. * Gets the number of samples used by the texture (WebGL2+ only)
  37970. */
  37971. samples: number;
  37972. /**
  37973. * Gets the type of the texture
  37974. */
  37975. type: number;
  37976. /**
  37977. * Gets the format of the texture
  37978. */
  37979. format: number;
  37980. /**
  37981. * Observable called when the texture is loaded
  37982. */
  37983. onLoadedObservable: Observable<InternalTexture>;
  37984. /**
  37985. * Gets the width of the texture
  37986. */
  37987. width: number;
  37988. /**
  37989. * Gets the height of the texture
  37990. */
  37991. height: number;
  37992. /**
  37993. * Gets the depth of the texture
  37994. */
  37995. depth: number;
  37996. /**
  37997. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37998. */
  37999. baseWidth: number;
  38000. /**
  38001. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38002. */
  38003. baseHeight: number;
  38004. /**
  38005. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38006. */
  38007. baseDepth: number;
  38008. /**
  38009. * Gets a boolean indicating if the texture is inverted on Y axis
  38010. */
  38011. invertY: boolean;
  38012. /**
  38013. * Gets or set the previous tracker in the list
  38014. */
  38015. previous: Nullable<IInternalTextureTracker>;
  38016. /**
  38017. * Gets or set the next tracker in the list
  38018. */
  38019. next: Nullable<IInternalTextureTracker>;
  38020. /** @ignore */
  38021. _initialSlot: number;
  38022. /** @ignore */
  38023. _designatedSlot: number;
  38024. /** @ignore */
  38025. _dataSource: number;
  38026. /** @ignore */
  38027. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  38028. /** @ignore */
  38029. _bufferView: Nullable<ArrayBufferView>;
  38030. /** @ignore */
  38031. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38032. /** @ignore */
  38033. _size: number;
  38034. /** @ignore */
  38035. _extension: string;
  38036. /** @ignore */
  38037. _files: Nullable<string[]>;
  38038. /** @ignore */
  38039. _workingCanvas: HTMLCanvasElement;
  38040. /** @ignore */
  38041. _workingContext: CanvasRenderingContext2D;
  38042. /** @ignore */
  38043. _framebuffer: Nullable<WebGLFramebuffer>;
  38044. /** @ignore */
  38045. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38046. /** @ignore */
  38047. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38048. /** @ignore */
  38049. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38050. /** @ignore */
  38051. _attachments: Nullable<number[]>;
  38052. /** @ignore */
  38053. _cachedCoordinatesMode: Nullable<number>;
  38054. /** @ignore */
  38055. _cachedWrapU: Nullable<number>;
  38056. /** @ignore */
  38057. _cachedWrapV: Nullable<number>;
  38058. /** @ignore */
  38059. _cachedWrapR: Nullable<number>;
  38060. /** @ignore */
  38061. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38062. /** @ignore */
  38063. _isDisabled: boolean;
  38064. /** @ignore */
  38065. _compression: Nullable<string>;
  38066. /** @ignore */
  38067. _generateStencilBuffer: boolean;
  38068. /** @ignore */
  38069. _generateDepthBuffer: boolean;
  38070. /** @ignore */
  38071. _comparisonFunction: number;
  38072. /** @ignore */
  38073. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38074. /** @ignore */
  38075. _lodGenerationScale: number;
  38076. /** @ignore */
  38077. _lodGenerationOffset: number;
  38078. /** @ignore */
  38079. _lodTextureHigh: BaseTexture;
  38080. /** @ignore */
  38081. _lodTextureMid: BaseTexture;
  38082. /** @ignore */
  38083. _lodTextureLow: BaseTexture;
  38084. /** @ignore */
  38085. _webGLTexture: Nullable<WebGLTexture>;
  38086. /** @ignore */
  38087. _references: number;
  38088. private _engine;
  38089. /**
  38090. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  38091. */
  38092. readonly dataSource: number;
  38093. /**
  38094. * Creates a new InternalTexture
  38095. * @param engine defines the engine to use
  38096. * @param dataSource defines the type of data that will be used
  38097. */
  38098. constructor(engine: Engine, dataSource: number);
  38099. /**
  38100. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  38101. */
  38102. incrementReferences(): void;
  38103. /**
  38104. * Change the size of the texture (not the size of the content)
  38105. * @param width defines the new width
  38106. * @param height defines the new height
  38107. * @param depth defines the new depth (1 by default)
  38108. */
  38109. updateSize(width: int, height: int, depth?: int): void;
  38110. /** @ignore */
  38111. _rebuild(): void;
  38112. private _swapAndDie(target);
  38113. /**
  38114. * Dispose the current allocated resources
  38115. */
  38116. dispose(): void;
  38117. }
  38118. }
  38119. declare module BABYLON {
  38120. /**
  38121. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  38122. */
  38123. interface IInternalTextureTracker {
  38124. /**
  38125. * Gets or set the previous tracker in the list
  38126. */
  38127. previous: Nullable<IInternalTextureTracker>;
  38128. /**
  38129. * Gets or set the next tracker in the list
  38130. */
  38131. next: Nullable<IInternalTextureTracker>;
  38132. }
  38133. /**
  38134. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  38135. */
  38136. class DummyInternalTextureTracker {
  38137. /**
  38138. * Gets or set the previous tracker in the list
  38139. */
  38140. previous: Nullable<IInternalTextureTracker>;
  38141. /**
  38142. * Gets or set the next tracker in the list
  38143. */
  38144. next: Nullable<IInternalTextureTracker>;
  38145. }
  38146. }
  38147. declare module BABYLON {
  38148. class MirrorTexture extends RenderTargetTexture {
  38149. mirrorPlane: Plane;
  38150. private _transformMatrix;
  38151. private _mirrorMatrix;
  38152. private _savedViewMatrix;
  38153. private _blurX;
  38154. private _blurY;
  38155. private _adaptiveBlurKernel;
  38156. private _blurKernelX;
  38157. private _blurKernelY;
  38158. private _blurRatio;
  38159. blurRatio: number;
  38160. adaptiveBlurKernel: number;
  38161. blurKernel: number;
  38162. blurKernelX: number;
  38163. blurKernelY: number;
  38164. private _autoComputeBlurKernel();
  38165. protected _onRatioRescale(): void;
  38166. constructor(name: string, size: number | {
  38167. width: number;
  38168. height: number;
  38169. } | {
  38170. ratio: number;
  38171. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  38172. private _preparePostProcesses();
  38173. clone(): MirrorTexture;
  38174. serialize(): any;
  38175. }
  38176. }
  38177. declare module BABYLON {
  38178. interface IMultiRenderTargetOptions {
  38179. generateMipMaps?: boolean;
  38180. types?: number[];
  38181. samplingModes?: number[];
  38182. generateDepthBuffer?: boolean;
  38183. generateStencilBuffer?: boolean;
  38184. generateDepthTexture?: boolean;
  38185. textureCount?: number;
  38186. doNotChangeAspectRatio?: boolean;
  38187. defaultType?: number;
  38188. }
  38189. class MultiRenderTarget extends RenderTargetTexture {
  38190. private _internalTextures;
  38191. private _textures;
  38192. readonly isSupported: boolean;
  38193. private _multiRenderTargetOptions;
  38194. readonly textures: Texture[];
  38195. readonly depthTexture: Texture;
  38196. wrapU: number;
  38197. wrapV: number;
  38198. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  38199. _rebuild(): void;
  38200. private _createInternalTextures();
  38201. private _createTextures();
  38202. samples: number;
  38203. resize(size: any): void;
  38204. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38205. dispose(): void;
  38206. releaseInternalTextures(): void;
  38207. }
  38208. }
  38209. declare module BABYLON {
  38210. class RawTexture extends Texture {
  38211. format: number;
  38212. private _engine;
  38213. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  38214. update(data: ArrayBufferView): void;
  38215. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38216. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38217. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38218. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38219. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38220. }
  38221. }
  38222. declare module BABYLON {
  38223. /**
  38224. * Creates a refraction texture used by refraction channel of the standard material.
  38225. * @param name the texture name
  38226. * @param size size of the underlying texture
  38227. * @param scene root scene
  38228. */
  38229. class RefractionTexture extends RenderTargetTexture {
  38230. refractionPlane: Plane;
  38231. depth: number;
  38232. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  38233. clone(): RefractionTexture;
  38234. serialize(): any;
  38235. }
  38236. }
  38237. declare module BABYLON {
  38238. class RenderTargetTexture extends Texture {
  38239. isCube: boolean;
  38240. static _REFRESHRATE_RENDER_ONCE: number;
  38241. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38242. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38243. static readonly REFRESHRATE_RENDER_ONCE: number;
  38244. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38245. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38246. /**
  38247. * Use this predicate to dynamically define the list of mesh you want to render.
  38248. * If set, the renderList property will be overwritten.
  38249. */
  38250. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38251. /**
  38252. * Use this list to define the list of mesh you want to render.
  38253. */
  38254. renderList: Nullable<Array<AbstractMesh>>;
  38255. renderParticles: boolean;
  38256. renderSprites: boolean;
  38257. coordinatesMode: number;
  38258. activeCamera: Nullable<Camera>;
  38259. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38260. useCameraPostProcesses: boolean;
  38261. ignoreCameraViewport: boolean;
  38262. private _postProcessManager;
  38263. private _postProcesses;
  38264. private _resizeObserver;
  38265. /**
  38266. * An event triggered when the texture is unbind.
  38267. * @type {BABYLON.Observable}
  38268. */
  38269. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38270. /**
  38271. * An event triggered when the texture is unbind.
  38272. * @type {BABYLON.Observable}
  38273. */
  38274. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38275. private _onAfterUnbindObserver;
  38276. onAfterUnbind: () => void;
  38277. /**
  38278. * An event triggered before rendering the texture
  38279. * @type {BABYLON.Observable}
  38280. */
  38281. onBeforeRenderObservable: Observable<number>;
  38282. private _onBeforeRenderObserver;
  38283. onBeforeRender: (faceIndex: number) => void;
  38284. /**
  38285. * An event triggered after rendering the texture
  38286. * @type {BABYLON.Observable}
  38287. */
  38288. onAfterRenderObservable: Observable<number>;
  38289. private _onAfterRenderObserver;
  38290. onAfterRender: (faceIndex: number) => void;
  38291. /**
  38292. * An event triggered after the texture clear
  38293. * @type {BABYLON.Observable}
  38294. */
  38295. onClearObservable: Observable<Engine>;
  38296. private _onClearObserver;
  38297. onClear: (Engine: Engine) => void;
  38298. clearColor: Color4;
  38299. protected _size: number | {
  38300. width: number;
  38301. height: number;
  38302. };
  38303. protected _initialSizeParameter: number | {
  38304. width: number;
  38305. height: number;
  38306. } | {
  38307. ratio: number;
  38308. };
  38309. protected _sizeRatio: Nullable<number>;
  38310. _generateMipMaps: boolean;
  38311. protected _renderingManager: RenderingManager;
  38312. _waitingRenderList: string[];
  38313. protected _doNotChangeAspectRatio: boolean;
  38314. protected _currentRefreshId: number;
  38315. protected _refreshRate: number;
  38316. protected _textureMatrix: Matrix;
  38317. protected _samples: number;
  38318. protected _renderTargetOptions: RenderTargetCreationOptions;
  38319. readonly renderTargetOptions: RenderTargetCreationOptions;
  38320. protected _engine: Engine;
  38321. protected _onRatioRescale(): void;
  38322. /**
  38323. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38324. * It must define where the camera used to render the texture is set
  38325. */
  38326. boundingBoxPosition: Vector3;
  38327. private _boundingBoxSize;
  38328. /**
  38329. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38330. * When defined, the cubemap will switch to local mode
  38331. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38332. * @example https://www.babylonjs-playground.com/#RNASML
  38333. */
  38334. boundingBoxSize: Vector3;
  38335. /**
  38336. * In case the RTT has been created with a depth texture, get the associated
  38337. * depth texture.
  38338. * Otherwise, return null.
  38339. */
  38340. depthStencilTexture: Nullable<InternalTexture>;
  38341. /**
  38342. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  38343. * or used a shadow, depth texture...
  38344. * @param name The friendly name of the texture
  38345. * @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)
  38346. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38347. * @param generateMipMaps True if mip maps need to be generated after render.
  38348. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38349. * @param type The type of the buffer in the RTT (int, half float, float...)
  38350. * @param isCube True if a cube texture needs to be created
  38351. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38352. * @param generateDepthBuffer True to generate a depth buffer
  38353. * @param generateStencilBuffer True to generate a stencil buffer
  38354. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38355. */
  38356. constructor(name: string, size: number | {
  38357. width: number;
  38358. height: number;
  38359. } | {
  38360. ratio: number;
  38361. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  38362. /**
  38363. * Creates a depth stencil texture.
  38364. * This is only available in WebGL 2 or with the depth texture extension available.
  38365. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38366. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38367. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38368. */
  38369. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  38370. private _processSizeParameter(size);
  38371. samples: number;
  38372. resetRefreshCounter(): void;
  38373. refreshRate: number;
  38374. addPostProcess(postProcess: PostProcess): void;
  38375. clearPostProcesses(dispose?: boolean): void;
  38376. removePostProcess(postProcess: PostProcess): void;
  38377. _shouldRender(): boolean;
  38378. getRenderSize(): number;
  38379. getRenderWidth(): number;
  38380. getRenderHeight(): number;
  38381. readonly canRescale: boolean;
  38382. scale(ratio: number): void;
  38383. getReflectionTextureMatrix(): Matrix;
  38384. resize(size: number | {
  38385. width: number;
  38386. height: number;
  38387. } | {
  38388. ratio: number;
  38389. }): void;
  38390. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38391. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  38392. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38393. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  38394. /**
  38395. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38396. * This allowed control for front to back rendering or reversly depending of the special needs.
  38397. *
  38398. * @param renderingGroupId The rendering group id corresponding to its index
  38399. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38400. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38401. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38402. */
  38403. 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;
  38404. /**
  38405. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38406. *
  38407. * @param renderingGroupId The rendering group id corresponding to its index
  38408. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38409. */
  38410. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38411. clone(): RenderTargetTexture;
  38412. serialize(): any;
  38413. disposeFramebufferObjects(): void;
  38414. dispose(): void;
  38415. _rebuild(): void;
  38416. /**
  38417. * Clear the info related to rendering groups preventing retention point in material dispose.
  38418. */
  38419. freeRenderingGroups(): void;
  38420. }
  38421. }
  38422. declare module BABYLON {
  38423. class Texture extends BaseTexture {
  38424. static NEAREST_SAMPLINGMODE: number;
  38425. static NEAREST_NEAREST_MIPLINEAR: number;
  38426. static BILINEAR_SAMPLINGMODE: number;
  38427. static LINEAR_LINEAR_MIPNEAREST: number;
  38428. static TRILINEAR_SAMPLINGMODE: number;
  38429. static LINEAR_LINEAR_MIPLINEAR: number;
  38430. static NEAREST_NEAREST_MIPNEAREST: number;
  38431. static NEAREST_LINEAR_MIPNEAREST: number;
  38432. static NEAREST_LINEAR_MIPLINEAR: number;
  38433. static NEAREST_LINEAR: number;
  38434. static NEAREST_NEAREST: number;
  38435. static LINEAR_NEAREST_MIPNEAREST: number;
  38436. static LINEAR_NEAREST_MIPLINEAR: number;
  38437. static LINEAR_LINEAR: number;
  38438. static LINEAR_NEAREST: number;
  38439. static EXPLICIT_MODE: number;
  38440. static SPHERICAL_MODE: number;
  38441. static PLANAR_MODE: number;
  38442. static CUBIC_MODE: number;
  38443. static PROJECTION_MODE: number;
  38444. static SKYBOX_MODE: number;
  38445. static INVCUBIC_MODE: number;
  38446. static EQUIRECTANGULAR_MODE: number;
  38447. static FIXED_EQUIRECTANGULAR_MODE: number;
  38448. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38449. static CLAMP_ADDRESSMODE: number;
  38450. static WRAP_ADDRESSMODE: number;
  38451. static MIRROR_ADDRESSMODE: number;
  38452. /**
  38453. * 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
  38454. */
  38455. static UseSerializedUrlIfAny: boolean;
  38456. url: Nullable<string>;
  38457. uOffset: number;
  38458. vOffset: number;
  38459. uScale: number;
  38460. vScale: number;
  38461. uAng: number;
  38462. vAng: number;
  38463. wAng: number;
  38464. readonly noMipmap: boolean;
  38465. private _noMipmap;
  38466. _invertY: boolean;
  38467. private _rowGenerationMatrix;
  38468. private _cachedTextureMatrix;
  38469. private _projectionModeMatrix;
  38470. private _t0;
  38471. private _t1;
  38472. private _t2;
  38473. private _cachedUOffset;
  38474. private _cachedVOffset;
  38475. private _cachedUScale;
  38476. private _cachedVScale;
  38477. private _cachedUAng;
  38478. private _cachedVAng;
  38479. private _cachedWAng;
  38480. private _cachedProjectionMatrixId;
  38481. private _cachedCoordinatesMode;
  38482. _samplingMode: number;
  38483. private _buffer;
  38484. private _deleteBuffer;
  38485. protected _format: Nullable<number>;
  38486. private _delayedOnLoad;
  38487. private _delayedOnError;
  38488. protected _onLoadObservable: Nullable<Observable<Texture>>;
  38489. protected _isBlocking: boolean;
  38490. isBlocking: boolean;
  38491. readonly samplingMode: number;
  38492. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  38493. updateURL(url: string): void;
  38494. delayLoad(): void;
  38495. updateSamplingMode(samplingMode: number): void;
  38496. private _prepareRowForTextureGeneration(x, y, z, t);
  38497. getTextureMatrix(): Matrix;
  38498. getReflectionTextureMatrix(): Matrix;
  38499. clone(): Texture;
  38500. readonly onLoadObservable: Observable<Texture>;
  38501. serialize(): any;
  38502. getClassName(): string;
  38503. dispose(): void;
  38504. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  38505. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  38506. 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;
  38507. }
  38508. }
  38509. declare module BABYLON {
  38510. /**
  38511. * Settings for finer control over video usage
  38512. */
  38513. interface VideoTextureSettings {
  38514. /**
  38515. * Applies `autoplay` to video, if specified
  38516. */
  38517. autoPlay?: boolean;
  38518. /**
  38519. * Applies `loop` to video, if specified
  38520. */
  38521. loop?: boolean;
  38522. /**
  38523. * Automatically updates internal texture from video at every frame in the render loop
  38524. */
  38525. autoUpdateTexture: boolean;
  38526. }
  38527. class VideoTexture extends Texture {
  38528. /**
  38529. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38530. */
  38531. readonly autoUpdateTexture: boolean;
  38532. /**
  38533. * The video instance used by the texture internally
  38534. */
  38535. readonly video: HTMLVideoElement;
  38536. private _generateMipMaps;
  38537. private _engine;
  38538. /**
  38539. * Creates a video texture.
  38540. * Sample : https://doc.babylonjs.com/how_to/video_texture
  38541. * @param {string | null} name optional name, will detect from video source, if not defined
  38542. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  38543. * @param {BABYLON.Scene} scene is obviously the current scene.
  38544. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38545. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  38546. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38547. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  38548. */
  38549. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38550. private _getName(src);
  38551. private _getVideo(src);
  38552. private _createInternalTexture;
  38553. private reset;
  38554. /**
  38555. * Internal method to initiate `update`.
  38556. */
  38557. _rebuild(): void;
  38558. /**
  38559. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38560. */
  38561. update(): void;
  38562. /**
  38563. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38564. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38565. */
  38566. updateTexture(isVisible: boolean): void;
  38567. protected _updateInternalTexture: (e?: Event | undefined) => void;
  38568. /**
  38569. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38570. * @param url New url.
  38571. */
  38572. updateURL(url: string): void;
  38573. dispose(): void;
  38574. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38575. minWidth: number;
  38576. maxWidth: number;
  38577. minHeight: number;
  38578. maxHeight: number;
  38579. deviceId: string;
  38580. }): void;
  38581. }
  38582. }
  38583. declare module BABYLON {
  38584. /**
  38585. * The Physically based material base class of BJS.
  38586. *
  38587. * This offers the main features of a standard PBR material.
  38588. * For more information, please refer to the documentation :
  38589. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  38590. */
  38591. abstract class PBRBaseMaterial extends PushMaterial {
  38592. /**
  38593. * Intensity of the direct lights e.g. the four lights available in your scene.
  38594. * This impacts both the direct diffuse and specular highlights.
  38595. */
  38596. protected _directIntensity: number;
  38597. /**
  38598. * Intensity of the emissive part of the material.
  38599. * This helps controlling the emissive effect without modifying the emissive color.
  38600. */
  38601. protected _emissiveIntensity: number;
  38602. /**
  38603. * Intensity of the environment e.g. how much the environment will light the object
  38604. * either through harmonics for rough material or through the refelction for shiny ones.
  38605. */
  38606. protected _environmentIntensity: number;
  38607. /**
  38608. * This is a special control allowing the reduction of the specular highlights coming from the
  38609. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  38610. */
  38611. protected _specularIntensity: number;
  38612. /**
  38613. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  38614. */
  38615. private _lightingInfos;
  38616. /**
  38617. * Debug Control allowing disabling the bump map on this material.
  38618. */
  38619. protected _disableBumpMap: boolean;
  38620. /**
  38621. * AKA Diffuse Texture in standard nomenclature.
  38622. */
  38623. protected _albedoTexture: BaseTexture;
  38624. /**
  38625. * AKA Occlusion Texture in other nomenclature.
  38626. */
  38627. protected _ambientTexture: BaseTexture;
  38628. /**
  38629. * AKA Occlusion Texture Intensity in other nomenclature.
  38630. */
  38631. protected _ambientTextureStrength: number;
  38632. /**
  38633. * Stores the alpha values in a texture.
  38634. */
  38635. protected _opacityTexture: BaseTexture;
  38636. /**
  38637. * Stores the reflection values in a texture.
  38638. */
  38639. protected _reflectionTexture: BaseTexture;
  38640. /**
  38641. * Stores the refraction values in a texture.
  38642. */
  38643. protected _refractionTexture: BaseTexture;
  38644. /**
  38645. * Stores the emissive values in a texture.
  38646. */
  38647. protected _emissiveTexture: BaseTexture;
  38648. /**
  38649. * AKA Specular texture in other nomenclature.
  38650. */
  38651. protected _reflectivityTexture: BaseTexture;
  38652. /**
  38653. * Used to switch from specular/glossiness to metallic/roughness workflow.
  38654. */
  38655. protected _metallicTexture: BaseTexture;
  38656. /**
  38657. * Specifies the metallic scalar of the metallic/roughness workflow.
  38658. * Can also be used to scale the metalness values of the metallic texture.
  38659. */
  38660. protected _metallic: number;
  38661. /**
  38662. * Specifies the roughness scalar of the metallic/roughness workflow.
  38663. * Can also be used to scale the roughness values of the metallic texture.
  38664. */
  38665. protected _roughness: number;
  38666. /**
  38667. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  38668. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  38669. */
  38670. protected _microSurfaceTexture: BaseTexture;
  38671. /**
  38672. * Stores surface normal data used to displace a mesh in a texture.
  38673. */
  38674. protected _bumpTexture: BaseTexture;
  38675. /**
  38676. * Stores the pre-calculated light information of a mesh in a texture.
  38677. */
  38678. protected _lightmapTexture: BaseTexture;
  38679. /**
  38680. * The color of a material in ambient lighting.
  38681. */
  38682. protected _ambientColor: Color3;
  38683. /**
  38684. * AKA Diffuse Color in other nomenclature.
  38685. */
  38686. protected _albedoColor: Color3;
  38687. /**
  38688. * AKA Specular Color in other nomenclature.
  38689. */
  38690. protected _reflectivityColor: Color3;
  38691. /**
  38692. * The color applied when light is reflected from a material.
  38693. */
  38694. protected _reflectionColor: Color3;
  38695. /**
  38696. * The color applied when light is emitted from a material.
  38697. */
  38698. protected _emissiveColor: Color3;
  38699. /**
  38700. * AKA Glossiness in other nomenclature.
  38701. */
  38702. protected _microSurface: number;
  38703. /**
  38704. * source material index of refraction (IOR)' / 'destination material IOR.
  38705. */
  38706. protected _indexOfRefraction: number;
  38707. /**
  38708. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  38709. */
  38710. protected _invertRefractionY: boolean;
  38711. /**
  38712. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  38713. * Materials half opaque for instance using refraction could benefit from this control.
  38714. */
  38715. protected _linkRefractionWithTransparency: boolean;
  38716. /**
  38717. * Specifies that the material will use the light map as a show map.
  38718. */
  38719. protected _useLightmapAsShadowmap: boolean;
  38720. /**
  38721. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  38722. * makes the reflect vector face the model (under horizon).
  38723. */
  38724. protected _useHorizonOcclusion: boolean;
  38725. /**
  38726. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  38727. * too much the area relying on ambient texture to define their ambient occlusion.
  38728. */
  38729. protected _useRadianceOcclusion: boolean;
  38730. /**
  38731. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  38732. */
  38733. protected _useAlphaFromAlbedoTexture: boolean;
  38734. /**
  38735. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  38736. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38737. */
  38738. protected _useSpecularOverAlpha: boolean;
  38739. /**
  38740. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  38741. */
  38742. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  38743. /**
  38744. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  38745. */
  38746. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  38747. /**
  38748. * Specifies if the metallic texture contains the roughness information in its green channel.
  38749. */
  38750. protected _useRoughnessFromMetallicTextureGreen: boolean;
  38751. /**
  38752. * Specifies if the metallic texture contains the metallness information in its blue channel.
  38753. */
  38754. protected _useMetallnessFromMetallicTextureBlue: boolean;
  38755. /**
  38756. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  38757. */
  38758. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  38759. /**
  38760. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  38761. */
  38762. protected _useAmbientInGrayScale: boolean;
  38763. /**
  38764. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  38765. * The material will try to infer what glossiness each pixel should be.
  38766. */
  38767. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  38768. /**
  38769. * BJS is using an harcoded light falloff based on a manually sets up range.
  38770. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  38771. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  38772. */
  38773. protected _usePhysicalLightFalloff: boolean;
  38774. /**
  38775. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38776. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38777. */
  38778. protected _useRadianceOverAlpha: boolean;
  38779. /**
  38780. * Allows using an object space normal map (instead of tangent space).
  38781. */
  38782. protected _useObjectSpaceNormalMap: boolean;
  38783. /**
  38784. * Allows using the bump map in parallax mode.
  38785. */
  38786. protected _useParallax: boolean;
  38787. /**
  38788. * Allows using the bump map in parallax occlusion mode.
  38789. */
  38790. protected _useParallaxOcclusion: boolean;
  38791. /**
  38792. * Controls the scale bias of the parallax mode.
  38793. */
  38794. protected _parallaxScaleBias: number;
  38795. /**
  38796. * If sets to true, disables all the lights affecting the material.
  38797. */
  38798. protected _disableLighting: boolean;
  38799. /**
  38800. * Number of Simultaneous lights allowed on the material.
  38801. */
  38802. protected _maxSimultaneousLights: number;
  38803. /**
  38804. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  38805. */
  38806. protected _invertNormalMapX: boolean;
  38807. /**
  38808. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  38809. */
  38810. protected _invertNormalMapY: boolean;
  38811. /**
  38812. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38813. */
  38814. protected _twoSidedLighting: boolean;
  38815. /**
  38816. * Defines the alpha limits in alpha test mode.
  38817. */
  38818. protected _alphaCutOff: number;
  38819. /**
  38820. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  38821. */
  38822. protected _forceAlphaTest: boolean;
  38823. /**
  38824. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  38825. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  38826. */
  38827. protected _useAlphaFresnel: boolean;
  38828. /**
  38829. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  38830. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  38831. */
  38832. protected _useLinearAlphaFresnel: boolean;
  38833. /**
  38834. * The transparency mode of the material.
  38835. */
  38836. protected _transparencyMode: Nullable<number>;
  38837. /**
  38838. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  38839. * from cos thetav and roughness:
  38840. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  38841. */
  38842. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  38843. /**
  38844. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  38845. */
  38846. protected _forceIrradianceInFragment: boolean;
  38847. /**
  38848. * Force normal to face away from face.
  38849. */
  38850. protected _forceNormalForward: boolean;
  38851. /**
  38852. * Default configuration related to image processing available in the PBR Material.
  38853. */
  38854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38855. /**
  38856. * Keep track of the image processing observer to allow dispose and replace.
  38857. */
  38858. private _imageProcessingObserver;
  38859. /**
  38860. * Attaches a new image processing configuration to the PBR Material.
  38861. * @param configuration
  38862. */
  38863. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38864. /**
  38865. * Stores the available render targets.
  38866. */
  38867. private _renderTargets;
  38868. /**
  38869. * Sets the global ambient color for the material used in lighting calculations.
  38870. */
  38871. private _globalAmbientColor;
  38872. /**
  38873. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  38874. */
  38875. private _useLogarithmicDepth;
  38876. /**
  38877. * If set to true, no lighting calculations will be applied.
  38878. */
  38879. private _unlit;
  38880. /**
  38881. * Instantiates a new PBRMaterial instance.
  38882. *
  38883. * @param name The material name
  38884. * @param scene The scene the material will be use in.
  38885. */
  38886. constructor(name: string, scene: Scene);
  38887. /**
  38888. * Gets the name of the material class.
  38889. */
  38890. getClassName(): string;
  38891. /**
  38892. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  38893. */
  38894. /**
  38895. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  38896. */
  38897. useLogarithmicDepth: boolean;
  38898. /**
  38899. * Gets the current transparency mode.
  38900. */
  38901. /**
  38902. * Sets the transparency mode of the material.
  38903. */
  38904. transparencyMode: Nullable<number>;
  38905. /**
  38906. * Returns true if alpha blending should be disabled.
  38907. */
  38908. private readonly _disableAlphaBlending;
  38909. /**
  38910. * Specifies whether or not this material should be rendered in alpha blend mode.
  38911. */
  38912. needAlphaBlending(): boolean;
  38913. /**
  38914. * Specifies if the mesh will require alpha blending.
  38915. * @param mesh - BJS mesh.
  38916. */
  38917. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  38918. /**
  38919. * Specifies whether or not this material should be rendered in alpha test mode.
  38920. */
  38921. needAlphaTesting(): boolean;
  38922. /**
  38923. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  38924. */
  38925. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  38926. /**
  38927. * Gets the texture used for the alpha test.
  38928. */
  38929. getAlphaTestTexture(): BaseTexture;
  38930. /**
  38931. * Stores the reflectivity values based on metallic roughness workflow.
  38932. */
  38933. private static _scaledReflectivity;
  38934. /**
  38935. * Specifies that the submesh is ready to be used.
  38936. * @param mesh - BJS mesh.
  38937. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  38938. * @param useInstances - Specifies that instances should be used.
  38939. * @returns - boolean indicating that the submesh is ready or not.
  38940. */
  38941. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38942. /**
  38943. * Specifies if the material uses metallic roughness workflow.
  38944. * @returns boolean specifiying if the material uses metallic roughness workflow.
  38945. */
  38946. isMetallicWorkflow(): boolean;
  38947. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  38948. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  38949. /**
  38950. * Force shader compilation
  38951. */
  38952. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  38953. clipPlane: boolean;
  38954. }>): void;
  38955. /**
  38956. * Initializes the uniform buffer layout for the shader.
  38957. */
  38958. buildUniformLayout(): void;
  38959. /**
  38960. * Unbinds the textures.
  38961. */
  38962. unbind(): void;
  38963. /**
  38964. * Binds the submesh data.
  38965. * @param world - The world matrix.
  38966. * @param mesh - The BJS mesh.
  38967. * @param subMesh - A submesh of the BJS mesh.
  38968. */
  38969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38970. /**
  38971. * Returns the animatable textures.
  38972. * @returns - Array of animatable textures.
  38973. */
  38974. getAnimatables(): IAnimatable[];
  38975. /**
  38976. * Returns the texture used for reflections.
  38977. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  38978. */
  38979. private _getReflectionTexture();
  38980. /**
  38981. * Returns the texture used for refraction or null if none is used.
  38982. * @returns - Refection texture if present. If no refraction texture and refraction
  38983. * is linked with transparency, returns environment texture. Otherwise, returns null.
  38984. */
  38985. private _getRefractionTexture();
  38986. /**
  38987. * Disposes the resources of the material.
  38988. * @param forceDisposeEffect - Forces the disposal of effects.
  38989. * @param forceDisposeTextures - Forces the disposal of all textures.
  38990. */
  38991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38992. }
  38993. }
  38994. declare module BABYLON {
  38995. /**
  38996. * The Physically based simple base material of BJS.
  38997. *
  38998. * This enables better naming and convention enforcements on top of the pbrMaterial.
  38999. * It is used as the base class for both the specGloss and metalRough conventions.
  39000. */
  39001. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  39002. /**
  39003. * Number of Simultaneous lights allowed on the material.
  39004. */
  39005. maxSimultaneousLights: number;
  39006. /**
  39007. * If sets to true, disables all the lights affecting the material.
  39008. */
  39009. disableLighting: boolean;
  39010. /**
  39011. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  39012. */
  39013. environmentTexture: BaseTexture;
  39014. /**
  39015. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39016. */
  39017. invertNormalMapX: boolean;
  39018. /**
  39019. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39020. */
  39021. invertNormalMapY: boolean;
  39022. /**
  39023. * Normal map used in the model.
  39024. */
  39025. normalTexture: BaseTexture;
  39026. /**
  39027. * Emissivie color used to self-illuminate the model.
  39028. */
  39029. emissiveColor: Color3;
  39030. /**
  39031. * Emissivie texture used to self-illuminate the model.
  39032. */
  39033. emissiveTexture: BaseTexture;
  39034. /**
  39035. * Occlusion Channel Strenght.
  39036. */
  39037. occlusionStrength: number;
  39038. /**
  39039. * Occlusion Texture of the material (adding extra occlusion effects).
  39040. */
  39041. occlusionTexture: BaseTexture;
  39042. /**
  39043. * Defines the alpha limits in alpha test mode.
  39044. */
  39045. alphaCutOff: number;
  39046. /**
  39047. * Gets the current double sided mode.
  39048. */
  39049. /**
  39050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39051. */
  39052. doubleSided: boolean;
  39053. lightmapTexture: BaseTexture;
  39054. useLightmapAsShadowmap: boolean;
  39055. /**
  39056. * Return the active textures of the material.
  39057. */
  39058. getActiveTextures(): BaseTexture[];
  39059. hasTexture(texture: BaseTexture): boolean;
  39060. /**
  39061. * Instantiates a new PBRMaterial instance.
  39062. *
  39063. * @param name The material name
  39064. * @param scene The scene the material will be use in.
  39065. */
  39066. constructor(name: string, scene: Scene);
  39067. getClassName(): string;
  39068. }
  39069. }
  39070. declare module BABYLON {
  39071. /**
  39072. * The Physically based material of BJS.
  39073. *
  39074. * This offers the main features of a standard PBR material.
  39075. * For more information, please refer to the documentation :
  39076. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  39077. */
  39078. class PBRMaterial extends PBRBaseMaterial {
  39079. private static _PBRMATERIAL_OPAQUE;
  39080. /**
  39081. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  39082. */
  39083. static readonly PBRMATERIAL_OPAQUE: number;
  39084. /**
  39085. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  39086. */
  39087. private static _PBRMATERIAL_ALPHATEST;
  39088. /**
  39089. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  39090. */
  39091. static readonly PBRMATERIAL_ALPHATEST: number;
  39092. /**
  39093. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  39094. */
  39095. private static _PBRMATERIAL_ALPHABLEND;
  39096. /**
  39097. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  39098. */
  39099. static readonly PBRMATERIAL_ALPHABLEND: number;
  39100. /**
  39101. * 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.
  39102. * They are also discarded below the alpha cutoff threshold to improve performances.
  39103. */
  39104. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  39105. /**
  39106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  39107. * They are also discarded below the alpha cutoff threshold to improve performances.
  39108. */
  39109. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  39110. /**
  39111. * Intensity of the direct lights e.g. the four lights available in your scene.
  39112. * This impacts both the direct diffuse and specular highlights.
  39113. */
  39114. directIntensity: number;
  39115. /**
  39116. * Intensity of the emissive part of the material.
  39117. * This helps controlling the emissive effect without modifying the emissive color.
  39118. */
  39119. emissiveIntensity: number;
  39120. /**
  39121. * Intensity of the environment e.g. how much the environment will light the object
  39122. * either through harmonics for rough material or through the refelction for shiny ones.
  39123. */
  39124. environmentIntensity: number;
  39125. /**
  39126. * This is a special control allowing the reduction of the specular highlights coming from the
  39127. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  39128. */
  39129. specularIntensity: number;
  39130. /**
  39131. * Debug Control allowing disabling the bump map on this material.
  39132. */
  39133. disableBumpMap: boolean;
  39134. /**
  39135. * AKA Diffuse Texture in standard nomenclature.
  39136. */
  39137. albedoTexture: BaseTexture;
  39138. /**
  39139. * AKA Occlusion Texture in other nomenclature.
  39140. */
  39141. ambientTexture: BaseTexture;
  39142. /**
  39143. * AKA Occlusion Texture Intensity in other nomenclature.
  39144. */
  39145. ambientTextureStrength: number;
  39146. /**
  39147. * Stores the alpha values in a texture.
  39148. */
  39149. opacityTexture: BaseTexture;
  39150. /**
  39151. * Stores the reflection values in a texture.
  39152. */
  39153. reflectionTexture: Nullable<BaseTexture>;
  39154. /**
  39155. * Stores the emissive values in a texture.
  39156. */
  39157. emissiveTexture: BaseTexture;
  39158. /**
  39159. * AKA Specular texture in other nomenclature.
  39160. */
  39161. reflectivityTexture: BaseTexture;
  39162. /**
  39163. * Used to switch from specular/glossiness to metallic/roughness workflow.
  39164. */
  39165. metallicTexture: BaseTexture;
  39166. /**
  39167. * Specifies the metallic scalar of the metallic/roughness workflow.
  39168. * Can also be used to scale the metalness values of the metallic texture.
  39169. */
  39170. metallic: number;
  39171. /**
  39172. * Specifies the roughness scalar of the metallic/roughness workflow.
  39173. * Can also be used to scale the roughness values of the metallic texture.
  39174. */
  39175. roughness: number;
  39176. /**
  39177. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  39178. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  39179. */
  39180. microSurfaceTexture: BaseTexture;
  39181. /**
  39182. * Stores surface normal data used to displace a mesh in a texture.
  39183. */
  39184. bumpTexture: BaseTexture;
  39185. /**
  39186. * Stores the pre-calculated light information of a mesh in a texture.
  39187. */
  39188. lightmapTexture: BaseTexture;
  39189. /**
  39190. * Stores the refracted light information in a texture.
  39191. */
  39192. refractionTexture: BaseTexture;
  39193. /**
  39194. * The color of a material in ambient lighting.
  39195. */
  39196. ambientColor: Color3;
  39197. /**
  39198. * AKA Diffuse Color in other nomenclature.
  39199. */
  39200. albedoColor: Color3;
  39201. /**
  39202. * AKA Specular Color in other nomenclature.
  39203. */
  39204. reflectivityColor: Color3;
  39205. /**
  39206. * The color reflected from the material.
  39207. */
  39208. reflectionColor: Color3;
  39209. /**
  39210. * The color emitted from the material.
  39211. */
  39212. emissiveColor: Color3;
  39213. /**
  39214. * AKA Glossiness in other nomenclature.
  39215. */
  39216. microSurface: number;
  39217. /**
  39218. * source material index of refraction (IOR)' / 'destination material IOR.
  39219. */
  39220. indexOfRefraction: number;
  39221. /**
  39222. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  39223. */
  39224. invertRefractionY: boolean;
  39225. /**
  39226. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  39227. * Materials half opaque for instance using refraction could benefit from this control.
  39228. */
  39229. linkRefractionWithTransparency: boolean;
  39230. useLightmapAsShadowmap: boolean;
  39231. /**
  39232. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  39233. */
  39234. useAlphaFromAlbedoTexture: boolean;
  39235. /**
  39236. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  39237. */
  39238. forceAlphaTest: boolean;
  39239. /**
  39240. * Defines the alpha limits in alpha test mode.
  39241. */
  39242. alphaCutOff: number;
  39243. /**
  39244. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  39245. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39246. */
  39247. useSpecularOverAlpha: boolean;
  39248. /**
  39249. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  39250. */
  39251. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  39252. /**
  39253. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  39254. */
  39255. useRoughnessFromMetallicTextureAlpha: boolean;
  39256. /**
  39257. * Specifies if the metallic texture contains the roughness information in its green channel.
  39258. */
  39259. useRoughnessFromMetallicTextureGreen: boolean;
  39260. /**
  39261. * Specifies if the metallic texture contains the metallness information in its blue channel.
  39262. */
  39263. useMetallnessFromMetallicTextureBlue: boolean;
  39264. /**
  39265. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  39266. */
  39267. useAmbientOcclusionFromMetallicTextureRed: boolean;
  39268. /**
  39269. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  39270. */
  39271. useAmbientInGrayScale: boolean;
  39272. /**
  39273. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  39274. * The material will try to infer what glossiness each pixel should be.
  39275. */
  39276. useAutoMicroSurfaceFromReflectivityMap: boolean;
  39277. /**
  39278. * BJS is using an harcoded light falloff based on a manually sets up range.
  39279. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  39280. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  39281. */
  39282. usePhysicalLightFalloff: boolean;
  39283. /**
  39284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39286. */
  39287. useRadianceOverAlpha: boolean;
  39288. /**
  39289. * Allows using an object space normal map (instead of tangent space).
  39290. */
  39291. useObjectSpaceNormalMap: boolean;
  39292. /**
  39293. * Allows using the bump map in parallax mode.
  39294. */
  39295. useParallax: boolean;
  39296. /**
  39297. * Allows using the bump map in parallax occlusion mode.
  39298. */
  39299. useParallaxOcclusion: boolean;
  39300. /**
  39301. * Controls the scale bias of the parallax mode.
  39302. */
  39303. parallaxScaleBias: number;
  39304. /**
  39305. * If sets to true, disables all the lights affecting the material.
  39306. */
  39307. disableLighting: boolean;
  39308. /**
  39309. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  39310. */
  39311. forceIrradianceInFragment: boolean;
  39312. /**
  39313. * Number of Simultaneous lights allowed on the material.
  39314. */
  39315. maxSimultaneousLights: number;
  39316. /**
  39317. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39318. */
  39319. invertNormalMapX: boolean;
  39320. /**
  39321. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39322. */
  39323. invertNormalMapY: boolean;
  39324. /**
  39325. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39326. */
  39327. twoSidedLighting: boolean;
  39328. /**
  39329. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  39330. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  39331. */
  39332. useAlphaFresnel: boolean;
  39333. /**
  39334. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  39335. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  39336. */
  39337. useLinearAlphaFresnel: boolean;
  39338. /**
  39339. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  39340. * And/Or occlude the blended part.
  39341. */
  39342. environmentBRDFTexture: Nullable<BaseTexture>;
  39343. /**
  39344. * Force normal to face away from face.
  39345. */
  39346. forceNormalForward: boolean;
  39347. /**
  39348. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  39349. * makes the reflect vector face the model (under horizon).
  39350. */
  39351. useHorizonOcclusion: boolean;
  39352. /**
  39353. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  39354. * too much the area relying on ambient texture to define their ambient occlusion.
  39355. */
  39356. useRadianceOcclusion: boolean;
  39357. /**
  39358. * If set to true, no lighting calculations will be applied.
  39359. */
  39360. unlit: boolean;
  39361. /**
  39362. * Gets the image processing configuration used either in this material.
  39363. */
  39364. /**
  39365. * Sets the Default image processing configuration used either in the this material.
  39366. *
  39367. * If sets to null, the scene one is in use.
  39368. */
  39369. imageProcessingConfiguration: ImageProcessingConfiguration;
  39370. /**
  39371. * Gets wether the color curves effect is enabled.
  39372. */
  39373. /**
  39374. * Sets wether the color curves effect is enabled.
  39375. */
  39376. cameraColorCurvesEnabled: boolean;
  39377. /**
  39378. * Gets wether the color grading effect is enabled.
  39379. */
  39380. /**
  39381. * Gets wether the color grading effect is enabled.
  39382. */
  39383. cameraColorGradingEnabled: boolean;
  39384. /**
  39385. * Gets wether tonemapping is enabled or not.
  39386. */
  39387. /**
  39388. * Sets wether tonemapping is enabled or not
  39389. */
  39390. cameraToneMappingEnabled: boolean;
  39391. /**
  39392. * The camera exposure used on this material.
  39393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39394. * This corresponds to a photographic exposure.
  39395. */
  39396. /**
  39397. * The camera exposure used on this material.
  39398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39399. * This corresponds to a photographic exposure.
  39400. */
  39401. cameraExposure: number;
  39402. /**
  39403. * Gets The camera contrast used on this material.
  39404. */
  39405. /**
  39406. * Sets The camera contrast used on this material.
  39407. */
  39408. cameraContrast: number;
  39409. /**
  39410. * Gets the Color Grading 2D Lookup Texture.
  39411. */
  39412. /**
  39413. * Sets the Color Grading 2D Lookup Texture.
  39414. */
  39415. cameraColorGradingTexture: Nullable<BaseTexture>;
  39416. /**
  39417. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39418. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39419. * 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;
  39420. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39421. */
  39422. /**
  39423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39425. * 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;
  39426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39427. */
  39428. cameraColorCurves: Nullable<ColorCurves>;
  39429. /**
  39430. * Instantiates a new PBRMaterial instance.
  39431. *
  39432. * @param name The material name
  39433. * @param scene The scene the material will be use in.
  39434. */
  39435. constructor(name: string, scene: Scene);
  39436. /**
  39437. * Returns the name of this material class.
  39438. */
  39439. getClassName(): string;
  39440. /**
  39441. * Returns an array of the actively used textures.
  39442. * @returns - Array of BaseTextures
  39443. */
  39444. getActiveTextures(): BaseTexture[];
  39445. /**
  39446. * Checks to see if a texture is used in the material.
  39447. * @param texture - Base texture to use.
  39448. * @returns - Boolean specifying if a texture is used in the material.
  39449. */
  39450. hasTexture(texture: BaseTexture): boolean;
  39451. /**
  39452. * Makes a duplicate of the current material.
  39453. * @param name - name to use for the new material.
  39454. */
  39455. clone(name: string): PBRMaterial;
  39456. /**
  39457. * Serializes this PBR Material.
  39458. * @returns - An object with the serialized material.
  39459. */
  39460. serialize(): any;
  39461. /**
  39462. * Parses a PBR Material from a serialized object.
  39463. * @param source - Serialized object.
  39464. * @param scene - BJS scene instance.
  39465. * @param rootUrl - url for the scene object
  39466. * @returns - PBRMaterial
  39467. */
  39468. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  39469. }
  39470. }
  39471. declare module BABYLON {
  39472. /**
  39473. * The PBR material of BJS following the metal roughness convention.
  39474. *
  39475. * This fits to the PBR convention in the GLTF definition:
  39476. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  39477. */
  39478. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  39479. /**
  39480. * The base color has two different interpretations depending on the value of metalness.
  39481. * When the material is a metal, the base color is the specific measured reflectance value
  39482. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  39483. * of the material.
  39484. */
  39485. baseColor: Color3;
  39486. /**
  39487. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  39488. * well as opacity information in the alpha channel.
  39489. */
  39490. baseTexture: BaseTexture;
  39491. /**
  39492. * Specifies the metallic scalar value of the material.
  39493. * Can also be used to scale the metalness values of the metallic texture.
  39494. */
  39495. metallic: number;
  39496. /**
  39497. * Specifies the roughness scalar value of the material.
  39498. * Can also be used to scale the roughness values of the metallic texture.
  39499. */
  39500. roughness: number;
  39501. /**
  39502. * Texture containing both the metallic value in the B channel and the
  39503. * roughness value in the G channel to keep better precision.
  39504. */
  39505. metallicRoughnessTexture: BaseTexture;
  39506. /**
  39507. * Instantiates a new PBRMetalRoughnessMaterial instance.
  39508. *
  39509. * @param name The material name
  39510. * @param scene The scene the material will be use in.
  39511. */
  39512. constructor(name: string, scene: Scene);
  39513. /**
  39514. * Return the currrent class name of the material.
  39515. */
  39516. getClassName(): string;
  39517. /**
  39518. * Return the active textures of the material.
  39519. */
  39520. getActiveTextures(): BaseTexture[];
  39521. /**
  39522. * Checks to see if a texture is used in the material.
  39523. * @param texture - Base texture to use.
  39524. * @returns - Boolean specifying if a texture is used in the material.
  39525. */
  39526. hasTexture(texture: BaseTexture): boolean;
  39527. /**
  39528. * Makes a duplicate of the current material.
  39529. * @param name - name to use for the new material.
  39530. */
  39531. clone(name: string): PBRMetallicRoughnessMaterial;
  39532. /**
  39533. * Serialize the material to a parsable JSON object.
  39534. */
  39535. serialize(): any;
  39536. /**
  39537. * Parses a JSON object correponding to the serialize function.
  39538. */
  39539. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  39540. }
  39541. }
  39542. declare module BABYLON {
  39543. /**
  39544. * The PBR material of BJS following the specular glossiness convention.
  39545. *
  39546. * This fits to the PBR convention in the GLTF definition:
  39547. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  39548. */
  39549. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  39550. /**
  39551. * Specifies the diffuse color of the material.
  39552. */
  39553. diffuseColor: Color3;
  39554. /**
  39555. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  39556. * channel.
  39557. */
  39558. diffuseTexture: BaseTexture;
  39559. /**
  39560. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  39561. */
  39562. specularColor: Color3;
  39563. /**
  39564. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  39565. */
  39566. glossiness: number;
  39567. /**
  39568. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  39569. */
  39570. specularGlossinessTexture: BaseTexture;
  39571. /**
  39572. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  39573. *
  39574. * @param name The material name
  39575. * @param scene The scene the material will be use in.
  39576. */
  39577. constructor(name: string, scene: Scene);
  39578. /**
  39579. * Return the currrent class name of the material.
  39580. */
  39581. getClassName(): string;
  39582. /**
  39583. * Return the active textures of the material.
  39584. */
  39585. getActiveTextures(): BaseTexture[];
  39586. /**
  39587. * Checks to see if a texture is used in the material.
  39588. * @param texture - Base texture to use.
  39589. * @returns - Boolean specifying if a texture is used in the material.
  39590. */
  39591. hasTexture(texture: BaseTexture): boolean;
  39592. /**
  39593. * Makes a duplicate of the current material.
  39594. * @param name - name to use for the new material.
  39595. */
  39596. clone(name: string): PBRSpecularGlossinessMaterial;
  39597. /**
  39598. * Serialize the material to a parsable JSON object.
  39599. */
  39600. serialize(): any;
  39601. /**
  39602. * Parses a JSON object correponding to the serialize function.
  39603. */
  39604. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  39605. }
  39606. }
  39607. declare module BABYLON {
  39608. /**
  39609. * Particle emitter emitting particles from the inside of a box.
  39610. * It emits the particles randomly between 2 given directions.
  39611. */
  39612. class BoxParticleEmitter implements IParticleEmitterType {
  39613. /**
  39614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  39615. */
  39616. direction1: Vector3;
  39617. /**
  39618. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  39619. */
  39620. direction2: Vector3;
  39621. /**
  39622. * 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.
  39623. */
  39624. minEmitBox: Vector3;
  39625. /**
  39626. * 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.
  39627. */
  39628. maxEmitBox: Vector3;
  39629. /**
  39630. * Creates a new instance BoxParticleEmitter
  39631. */
  39632. constructor();
  39633. /**
  39634. * Called by the particle System when the direction is computed for the created particle.
  39635. * @param emitPower is the power of the particle (speed)
  39636. * @param worldMatrix is the world matrix of the particle system
  39637. * @param directionToUpdate is the direction vector to update with the result
  39638. * @param particle is the particle we are computed the direction for
  39639. */
  39640. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39641. /**
  39642. * Called by the particle System when the position is computed for the created particle.
  39643. * @param worldMatrix is the world matrix of the particle system
  39644. * @param positionToUpdate is the position vector to update with the result
  39645. * @param particle is the particle we are computed the position for
  39646. */
  39647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39648. /**
  39649. * Clones the current emitter and returns a copy of it
  39650. * @returns the new emitter
  39651. */
  39652. clone(): BoxParticleEmitter;
  39653. /**
  39654. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39655. * @param effect defines the update shader
  39656. */
  39657. applyToShader(effect: Effect): void;
  39658. /**
  39659. * Returns a string to use to update the GPU particles update shader
  39660. * @returns a string containng the defines string
  39661. */
  39662. getEffectDefines(): string;
  39663. /**
  39664. * Returns the string "BoxEmitter"
  39665. * @returns a string containing the class name
  39666. */
  39667. getClassName(): string;
  39668. /**
  39669. * Serializes the particle system to a JSON object.
  39670. * @returns the JSON object
  39671. */
  39672. serialize(): any;
  39673. /**
  39674. * Parse properties from a JSON object
  39675. * @param serializationObject defines the JSON object
  39676. */
  39677. parse(serializationObject: any): void;
  39678. }
  39679. }
  39680. declare module BABYLON {
  39681. /**
  39682. * Particle emitter emitting particles from the inside of a cone.
  39683. * It emits the particles alongside the cone volume from the base to the particle.
  39684. * The emission direction might be randomized.
  39685. */
  39686. class ConeParticleEmitter implements IParticleEmitterType {
  39687. /**
  39688. * The radius of the emission cone.
  39689. */
  39690. angle: number;
  39691. /**
  39692. * The cone base angle.
  39693. */
  39694. directionRandomizer: number;
  39695. private _radius;
  39696. private _height;
  39697. /**
  39698. * Gets the radius of the emission cone.
  39699. */
  39700. /**
  39701. * Sets the radius of the emission cone.
  39702. */
  39703. radius: number;
  39704. /**
  39705. * Creates a new instance ConeParticleEmitter
  39706. * @param radius the radius of the emission cone (1 by default)
  39707. * @param angles the cone base angle (PI by default)
  39708. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  39709. */
  39710. constructor(radius?: number,
  39711. /**
  39712. * The radius of the emission cone.
  39713. */
  39714. angle?: number,
  39715. /**
  39716. * The cone base angle.
  39717. */
  39718. directionRandomizer?: number);
  39719. /**
  39720. * Called by the particle System when the direction is computed for the created particle.
  39721. * @param emitPower is the power of the particle (speed)
  39722. * @param worldMatrix is the world matrix of the particle system
  39723. * @param directionToUpdate is the direction vector to update with the result
  39724. * @param particle is the particle we are computed the direction for
  39725. */
  39726. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39727. /**
  39728. * Called by the particle System when the position is computed for the created particle.
  39729. * @param worldMatrix is the world matrix of the particle system
  39730. * @param positionToUpdate is the position vector to update with the result
  39731. * @param particle is the particle we are computed the position for
  39732. */
  39733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39734. /**
  39735. * Clones the current emitter and returns a copy of it
  39736. * @returns the new emitter
  39737. */
  39738. clone(): ConeParticleEmitter;
  39739. /**
  39740. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39741. * @param effect defines the update shader
  39742. */
  39743. applyToShader(effect: Effect): void;
  39744. /**
  39745. * Returns a string to use to update the GPU particles update shader
  39746. * @returns a string containng the defines string
  39747. */
  39748. getEffectDefines(): string;
  39749. /**
  39750. * Returns the string "BoxEmitter"
  39751. * @returns a string containing the class name
  39752. */
  39753. getClassName(): string;
  39754. /**
  39755. * Serializes the particle system to a JSON object.
  39756. * @returns the JSON object
  39757. */
  39758. serialize(): any;
  39759. /**
  39760. * Parse properties from a JSON object
  39761. * @param serializationObject defines the JSON object
  39762. */
  39763. parse(serializationObject: any): void;
  39764. }
  39765. }
  39766. declare module BABYLON {
  39767. /**
  39768. * Particle emitter represents a volume emitting particles.
  39769. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  39770. */
  39771. interface IParticleEmitterType {
  39772. /**
  39773. * Called by the particle System when the direction is computed for the created particle.
  39774. * @param emitPower is the power of the particle (speed)
  39775. * @param worldMatrix is the world matrix of the particle system
  39776. * @param directionToUpdate is the direction vector to update with the result
  39777. * @param particle is the particle we are computed the direction for
  39778. */
  39779. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39780. /**
  39781. * Called by the particle System when the position is computed for the created particle.
  39782. * @param worldMatrix is the world matrix of the particle system
  39783. * @param positionToUpdate is the position vector to update with the result
  39784. * @param particle is the particle we are computed the position for
  39785. */
  39786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39787. /**
  39788. * Clones the current emitter and returns a copy of it
  39789. * @returns the new emitter
  39790. */
  39791. clone(): IParticleEmitterType;
  39792. /**
  39793. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39794. * @param effect defines the update shader
  39795. */
  39796. applyToShader(effect: Effect): void;
  39797. /**
  39798. * Returns a string to use to update the GPU particles update shader
  39799. * @returns the effect defines string
  39800. */
  39801. getEffectDefines(): string;
  39802. /**
  39803. * Returns a string representing the class name
  39804. * @returns a string containing the class name
  39805. */
  39806. getClassName(): string;
  39807. /**
  39808. * Serializes the particle system to a JSON object.
  39809. * @returns the JSON object
  39810. */
  39811. serialize(): any;
  39812. /**
  39813. * Parse properties from a JSON object
  39814. * @param serializationObject defines the JSON object
  39815. */
  39816. parse(serializationObject: any): void;
  39817. }
  39818. }
  39819. declare module BABYLON {
  39820. /**
  39821. * Particle emitter emitting particles from the inside of a sphere.
  39822. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  39823. */
  39824. class SphereParticleEmitter implements IParticleEmitterType {
  39825. /**
  39826. * The radius of the emission sphere.
  39827. */
  39828. radius: number;
  39829. /**
  39830. * How much to randomize the particle direction [0-1].
  39831. */
  39832. directionRandomizer: number;
  39833. /**
  39834. * Creates a new instance SphereParticleEmitter
  39835. * @param radius the radius of the emission sphere (1 by default)
  39836. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  39837. */
  39838. constructor(
  39839. /**
  39840. * The radius of the emission sphere.
  39841. */
  39842. radius?: number,
  39843. /**
  39844. * How much to randomize the particle direction [0-1].
  39845. */
  39846. directionRandomizer?: number);
  39847. /**
  39848. * Called by the particle System when the direction is computed for the created particle.
  39849. * @param emitPower is the power of the particle (speed)
  39850. * @param worldMatrix is the world matrix of the particle system
  39851. * @param directionToUpdate is the direction vector to update with the result
  39852. * @param particle is the particle we are computed the direction for
  39853. */
  39854. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39855. /**
  39856. * Called by the particle System when the position is computed for the created particle.
  39857. * @param worldMatrix is the world matrix of the particle system
  39858. * @param positionToUpdate is the position vector to update with the result
  39859. * @param particle is the particle we are computed the position for
  39860. */
  39861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39862. /**
  39863. * Clones the current emitter and returns a copy of it
  39864. * @returns the new emitter
  39865. */
  39866. clone(): SphereParticleEmitter;
  39867. /**
  39868. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39869. * @param effect defines the update shader
  39870. */
  39871. applyToShader(effect: Effect): void;
  39872. /**
  39873. * Returns a string to use to update the GPU particles update shader
  39874. * @returns a string containng the defines string
  39875. */
  39876. getEffectDefines(): string;
  39877. /**
  39878. * Returns the string "SphereParticleEmitter"
  39879. * @returns a string containing the class name
  39880. */
  39881. getClassName(): string;
  39882. /**
  39883. * Serializes the particle system to a JSON object.
  39884. * @returns the JSON object
  39885. */
  39886. serialize(): any;
  39887. /**
  39888. * Parse properties from a JSON object
  39889. * @param serializationObject defines the JSON object
  39890. */
  39891. parse(serializationObject: any): void;
  39892. }
  39893. /**
  39894. * Particle emitter emitting particles from the inside of a sphere.
  39895. * It emits the particles randomly between two vectors.
  39896. */
  39897. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  39898. /**
  39899. * The min limit of the emission direction.
  39900. */
  39901. direction1: Vector3;
  39902. /**
  39903. * The max limit of the emission direction.
  39904. */
  39905. direction2: Vector3;
  39906. /**
  39907. * Creates a new instance SphereDirectedParticleEmitter
  39908. * @param radius the radius of the emission sphere (1 by default)
  39909. * @param direction1 the min limit of the emission direction (up vector by default)
  39910. * @param direction2 the max limit of the emission direction (up vector by default)
  39911. */
  39912. constructor(radius?: number,
  39913. /**
  39914. * The min limit of the emission direction.
  39915. */
  39916. direction1?: Vector3,
  39917. /**
  39918. * The max limit of the emission direction.
  39919. */
  39920. direction2?: Vector3);
  39921. /**
  39922. * Called by the particle System when the direction is computed for the created particle.
  39923. * @param emitPower is the power of the particle (speed)
  39924. * @param worldMatrix is the world matrix of the particle system
  39925. * @param directionToUpdate is the direction vector to update with the result
  39926. * @param particle is the particle we are computed the direction for
  39927. */
  39928. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39929. /**
  39930. * Clones the current emitter and returns a copy of it
  39931. * @returns the new emitter
  39932. */
  39933. clone(): SphereDirectedParticleEmitter;
  39934. /**
  39935. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39936. * @param effect defines the update shader
  39937. */
  39938. applyToShader(effect: Effect): void;
  39939. /**
  39940. * Returns a string to use to update the GPU particles update shader
  39941. * @returns a string containng the defines string
  39942. */
  39943. getEffectDefines(): string;
  39944. /**
  39945. * Returns the string "SphereDirectedParticleEmitter"
  39946. * @returns a string containing the class name
  39947. */
  39948. getClassName(): string;
  39949. /**
  39950. * Serializes the particle system to a JSON object.
  39951. * @returns the JSON object
  39952. */
  39953. serialize(): any;
  39954. /**
  39955. * Parse properties from a JSON object
  39956. * @param serializationObject defines the JSON object
  39957. */
  39958. parse(serializationObject: any): void;
  39959. }
  39960. }
  39961. declare module BABYLON {
  39962. class CannonJSPlugin implements IPhysicsEnginePlugin {
  39963. private _useDeltaForWorldStep;
  39964. world: any;
  39965. name: string;
  39966. private _physicsMaterials;
  39967. private _fixedTimeStep;
  39968. BJSCANNON: any;
  39969. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  39970. setGravity(gravity: Vector3): void;
  39971. setTimeStep(timeStep: number): void;
  39972. getTimeStep(): number;
  39973. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  39974. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39975. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39976. generatePhysicsBody(impostor: PhysicsImpostor): void;
  39977. private _processChildMeshes(mainImpostor);
  39978. removePhysicsBody(impostor: PhysicsImpostor): void;
  39979. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  39980. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  39981. private _addMaterial(name, friction, restitution);
  39982. private _checkWithEpsilon(value);
  39983. private _createShape(impostor);
  39984. private _createHeightmap(object, pointDepth?);
  39985. private _minus90X;
  39986. private _plus90X;
  39987. private _tmpPosition;
  39988. private _tmpDeltaPosition;
  39989. private _tmpUnityRotation;
  39990. private _updatePhysicsBodyTransformation(impostor);
  39991. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  39992. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  39993. isSupported(): boolean;
  39994. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39995. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39996. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39997. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  39999. getBodyMass(impostor: PhysicsImpostor): number;
  40000. getBodyFriction(impostor: PhysicsImpostor): number;
  40001. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  40002. getBodyRestitution(impostor: PhysicsImpostor): number;
  40003. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  40004. sleepBody(impostor: PhysicsImpostor): void;
  40005. wakeUpBody(impostor: PhysicsImpostor): void;
  40006. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  40007. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  40008. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  40009. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  40010. getRadius(impostor: PhysicsImpostor): number;
  40011. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  40012. dispose(): void;
  40013. private _extendNamespace();
  40014. }
  40015. }
  40016. declare module BABYLON {
  40017. class OimoJSPlugin implements IPhysicsEnginePlugin {
  40018. world: any;
  40019. name: string;
  40020. BJSOIMO: any;
  40021. constructor(iterations?: number);
  40022. setGravity(gravity: Vector3): void;
  40023. setTimeStep(timeStep: number): void;
  40024. getTimeStep(): number;
  40025. private _tmpImpostorsArray;
  40026. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  40027. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  40028. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  40029. generatePhysicsBody(impostor: PhysicsImpostor): void;
  40030. private _tmpPositionVector;
  40031. removePhysicsBody(impostor: PhysicsImpostor): void;
  40032. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  40033. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  40034. isSupported(): boolean;
  40035. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  40036. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  40037. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  40038. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  40039. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  40040. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  40041. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  40042. getBodyMass(impostor: PhysicsImpostor): number;
  40043. getBodyFriction(impostor: PhysicsImpostor): number;
  40044. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  40045. getBodyRestitution(impostor: PhysicsImpostor): number;
  40046. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  40047. sleepBody(impostor: PhysicsImpostor): void;
  40048. wakeUpBody(impostor: PhysicsImpostor): void;
  40049. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  40050. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  40051. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  40052. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  40053. getRadius(impostor: PhysicsImpostor): number;
  40054. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  40055. dispose(): void;
  40056. }
  40057. }
  40058. declare module BABYLON {
  40059. /**
  40060. * This represents a set of one or more post processes in Babylon.
  40061. * A post process can be used to apply a shader to a texture after it is rendered.
  40062. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  40063. */
  40064. class PostProcessRenderEffect {
  40065. private _postProcesses;
  40066. private _getPostProcesses;
  40067. private _singleInstance;
  40068. private _cameras;
  40069. private _indicesForCamera;
  40070. /**
  40071. * Name of the effect
  40072. */
  40073. _name: string;
  40074. /**
  40075. * Instantiates a post process render effect.
  40076. * A post process can be used to apply a shader to a texture after it is rendered.
  40077. * @param engine The engine the effect is tied to
  40078. * @param name The name of the effect
  40079. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  40080. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  40081. */
  40082. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  40083. /**
  40084. * Checks if all the post processes in the effect are supported.
  40085. */
  40086. readonly isSupported: boolean;
  40087. /**
  40088. * Updates the current state of the effect
  40089. */
  40090. _update(): void;
  40091. /**
  40092. * Attaches the effect on cameras
  40093. * @param cameras The camera to attach to.
  40094. */
  40095. _attachCameras(cameras: Camera): void;
  40096. /**
  40097. * Attaches the effect on cameras
  40098. * @param cameras The camera to attach to.
  40099. */
  40100. _attachCameras(cameras: Camera[]): void;
  40101. /**
  40102. * Detatches the effect on cameras
  40103. * @param cameras The camera to detatch from.
  40104. */
  40105. _detachCameras(cameras: Camera): void;
  40106. /**
  40107. * Detatches the effect on cameras
  40108. * @param cameras The camera to detatch from.
  40109. */
  40110. _detachCameras(cameras: Camera[]): void;
  40111. /**
  40112. * Enables the effect on given cameras
  40113. * @param cameras The camera to enable.
  40114. */
  40115. _enable(cameras: Camera): void;
  40116. /**
  40117. * Enables the effect on given cameras
  40118. * @param cameras The camera to enable.
  40119. */
  40120. _enable(cameras: Nullable<Camera[]>): void;
  40121. /**
  40122. * Disables the effect on the given cameras
  40123. * @param cameras The camera to disable.
  40124. */
  40125. _disable(cameras: Camera): void;
  40126. /**
  40127. * Disables the effect on the given cameras
  40128. * @param cameras The camera to disable.
  40129. */
  40130. _disable(cameras: Nullable<Camera[]>): void;
  40131. /**
  40132. * Gets a list of the post processes contained in the effect.
  40133. * @param camera The camera to get the post processes on.
  40134. * @returns The list of the post processes in the effect.
  40135. */
  40136. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  40137. }
  40138. }
  40139. declare module BABYLON {
  40140. class PostProcessRenderPipeline {
  40141. private engine;
  40142. private _renderEffects;
  40143. private _renderEffectsForIsolatedPass;
  40144. protected _cameras: Camera[];
  40145. _name: string;
  40146. constructor(engine: Engine, name: string);
  40147. getClassName(): string;
  40148. readonly isSupported: boolean;
  40149. addEffect(renderEffect: PostProcessRenderEffect): void;
  40150. _rebuild(): void;
  40151. _enableEffect(renderEffectName: string, cameras: Camera): void;
  40152. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  40153. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  40154. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  40155. _attachCameras(cameras: Camera, unique: boolean): void;
  40156. _attachCameras(cameras: Camera[], unique: boolean): void;
  40157. _detachCameras(cameras: Camera): void;
  40158. _detachCameras(cameras: Nullable<Camera[]>): void;
  40159. _update(): void;
  40160. _reset(): void;
  40161. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  40162. dispose(): void;
  40163. }
  40164. }
  40165. declare module BABYLON {
  40166. class PostProcessRenderPipelineManager {
  40167. private _renderPipelines;
  40168. constructor();
  40169. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  40170. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  40171. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  40172. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  40173. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  40174. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  40175. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  40176. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  40177. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  40178. update(): void;
  40179. _rebuild(): void;
  40180. dispose(): void;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. /**
  40185. * Helper class dealing with the extraction of spherical polynomial dataArray
  40186. * from a cube map.
  40187. */
  40188. class CubeMapToSphericalPolynomialTools {
  40189. private static FileFaces;
  40190. /**
  40191. * Converts a texture to the according Spherical Polynomial data.
  40192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  40193. *
  40194. * @param texture The texture to extract the information from.
  40195. * @return The Spherical Polynomial data.
  40196. */
  40197. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  40198. /**
  40199. * Converts a cubemap to the according Spherical Polynomial data.
  40200. * This extracts the first 3 orders only as they are the only one used in the lighting.
  40201. *
  40202. * @param cubeInfo The Cube map to extract the information from.
  40203. * @return The Spherical Polynomial data.
  40204. */
  40205. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  40206. }
  40207. }
  40208. declare module BABYLON {
  40209. /**
  40210. * Header information of HDR texture files.
  40211. */
  40212. interface HDRInfo {
  40213. /**
  40214. * The height of the texture in pixels.
  40215. */
  40216. height: number;
  40217. /**
  40218. * The width of the texture in pixels.
  40219. */
  40220. width: number;
  40221. /**
  40222. * The index of the beginning of the data in the binary file.
  40223. */
  40224. dataPosition: number;
  40225. }
  40226. /**
  40227. * This groups tools to convert HDR texture to native colors array.
  40228. */
  40229. class HDRTools {
  40230. private static Ldexp(mantissa, exponent);
  40231. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  40232. private static readStringLine(uint8array, startIndex);
  40233. /**
  40234. * Reads header information from an RGBE texture stored in a native array.
  40235. * More information on this format are available here:
  40236. * https://en.wikipedia.org/wiki/RGBE_image_format
  40237. *
  40238. * @param uint8array The binary file stored in native array.
  40239. * @return The header information.
  40240. */
  40241. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  40242. /**
  40243. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  40244. * This RGBE texture needs to store the information as a panorama.
  40245. *
  40246. * More information on this format are available here:
  40247. * https://en.wikipedia.org/wiki/RGBE_image_format
  40248. *
  40249. * @param buffer The binary file stored in an array buffer.
  40250. * @param size The expected size of the extracted cubemap.
  40251. * @return The Cube Map information.
  40252. */
  40253. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  40254. /**
  40255. * Returns the pixels data extracted from an RGBE texture.
  40256. * This pixels will be stored left to right up to down in the R G B order in one array.
  40257. *
  40258. * More information on this format are available here:
  40259. * https://en.wikipedia.org/wiki/RGBE_image_format
  40260. *
  40261. * @param uint8array The binary file stored in an array buffer.
  40262. * @param hdrInfo The header information of the file.
  40263. * @return The pixels data in RGB right to left up to down order.
  40264. */
  40265. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  40266. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  40267. }
  40268. }
  40269. declare module BABYLON {
  40270. /**
  40271. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  40272. */
  40273. interface CubeMapInfo {
  40274. /**
  40275. * The pixel array for the front face.
  40276. * This is stored in format, left to right, up to down format.
  40277. */
  40278. front: Nullable<ArrayBufferView>;
  40279. /**
  40280. * The pixel array for the back face.
  40281. * This is stored in format, left to right, up to down format.
  40282. */
  40283. back: Nullable<ArrayBufferView>;
  40284. /**
  40285. * The pixel array for the left face.
  40286. * This is stored in format, left to right, up to down format.
  40287. */
  40288. left: Nullable<ArrayBufferView>;
  40289. /**
  40290. * The pixel array for the right face.
  40291. * This is stored in format, left to right, up to down format.
  40292. */
  40293. right: Nullable<ArrayBufferView>;
  40294. /**
  40295. * The pixel array for the up face.
  40296. * This is stored in format, left to right, up to down format.
  40297. */
  40298. up: Nullable<ArrayBufferView>;
  40299. /**
  40300. * The pixel array for the down face.
  40301. * This is stored in format, left to right, up to down format.
  40302. */
  40303. down: Nullable<ArrayBufferView>;
  40304. /**
  40305. * The size of the cubemap stored.
  40306. *
  40307. * Each faces will be size * size pixels.
  40308. */
  40309. size: number;
  40310. /**
  40311. * The format of the texture.
  40312. *
  40313. * RGBA, RGB.
  40314. */
  40315. format: number;
  40316. /**
  40317. * The type of the texture data.
  40318. *
  40319. * UNSIGNED_INT, FLOAT.
  40320. */
  40321. type: number;
  40322. /**
  40323. * Specifies whether the texture is in gamma space.
  40324. */
  40325. gammaSpace: boolean;
  40326. }
  40327. /**
  40328. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  40329. */
  40330. class PanoramaToCubeMapTools {
  40331. private static FACE_FRONT;
  40332. private static FACE_BACK;
  40333. private static FACE_RIGHT;
  40334. private static FACE_LEFT;
  40335. private static FACE_DOWN;
  40336. private static FACE_UP;
  40337. /**
  40338. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  40339. *
  40340. * @param float32Array The source data.
  40341. * @param inputWidth The width of the input panorama.
  40342. * @param inputhHeight The height of the input panorama.
  40343. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  40344. * @return The cubemap data
  40345. */
  40346. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  40347. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  40348. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  40349. }
  40350. }
  40351. declare module BABYLON {
  40352. class CustomProceduralTexture extends ProceduralTexture {
  40353. private _animate;
  40354. private _time;
  40355. private _config;
  40356. private _texturePath;
  40357. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  40358. private loadJson(jsonUrl);
  40359. isReady(): boolean;
  40360. render(useCameraPostProcess?: boolean): void;
  40361. updateTextures(): void;
  40362. updateShaderUniforms(): void;
  40363. animate: boolean;
  40364. }
  40365. }
  40366. declare module BABYLON {
  40367. class ProceduralTexture extends Texture {
  40368. isCube: boolean;
  40369. private _size;
  40370. _generateMipMaps: boolean;
  40371. isEnabled: boolean;
  40372. private _currentRefreshId;
  40373. private _refreshRate;
  40374. onGenerated: () => void;
  40375. private _vertexBuffers;
  40376. private _indexBuffer;
  40377. private _effect;
  40378. private _uniforms;
  40379. private _samplers;
  40380. private _fragment;
  40381. _textures: {
  40382. [key: string]: Texture;
  40383. };
  40384. private _floats;
  40385. private _floatsArrays;
  40386. private _colors3;
  40387. private _colors4;
  40388. private _vectors2;
  40389. private _vectors3;
  40390. private _matrices;
  40391. private _fallbackTexture;
  40392. private _fallbackTextureUsed;
  40393. private _engine;
  40394. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  40395. private _createIndexBuffer();
  40396. _rebuild(): void;
  40397. reset(): void;
  40398. isReady(): boolean;
  40399. resetRefreshCounter(): void;
  40400. setFragment(fragment: any): void;
  40401. refreshRate: number;
  40402. _shouldRender(): boolean;
  40403. getRenderSize(): number;
  40404. resize(size: number, generateMipMaps: boolean): void;
  40405. private _checkUniform(uniformName);
  40406. setTexture(name: string, texture: Texture): ProceduralTexture;
  40407. setFloat(name: string, value: number): ProceduralTexture;
  40408. setFloats(name: string, value: number[]): ProceduralTexture;
  40409. setColor3(name: string, value: Color3): ProceduralTexture;
  40410. setColor4(name: string, value: Color4): ProceduralTexture;
  40411. setVector2(name: string, value: Vector2): ProceduralTexture;
  40412. setVector3(name: string, value: Vector3): ProceduralTexture;
  40413. setMatrix(name: string, value: Matrix): ProceduralTexture;
  40414. render(useCameraPostProcess?: boolean): void;
  40415. clone(): ProceduralTexture;
  40416. dispose(): void;
  40417. }
  40418. }
  40419. declare module BABYLON {
  40420. /**
  40421. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  40422. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  40423. */
  40424. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  40425. private _scene;
  40426. private _originalCameras;
  40427. /**
  40428. * ID of the sharpen post process,
  40429. */
  40430. private readonly SharpenPostProcessId;
  40431. /**
  40432. * ID of the image processing post process;
  40433. */
  40434. readonly ImageProcessingPostProcessId: string;
  40435. /**
  40436. * ID of the Fast Approximate Anti-Aliasing post process;
  40437. */
  40438. readonly FxaaPostProcessId: string;
  40439. /**
  40440. * ID of the chromatic aberration post process,
  40441. */
  40442. private readonly ChromaticAberrationPostProcessId;
  40443. /**
  40444. * ID of the grain post process
  40445. */
  40446. private readonly GrainPostProcessId;
  40447. /**
  40448. * Sharpen post process which will apply a sharpen convolution to enhance edges
  40449. */
  40450. sharpen: SharpenPostProcess;
  40451. private _sharpenEffect;
  40452. private bloom;
  40453. /**
  40454. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  40455. */
  40456. depthOfField: DepthOfFieldEffect;
  40457. /**
  40458. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  40459. */
  40460. fxaa: FxaaPostProcess;
  40461. /**
  40462. * Image post processing pass used to perform operations such as tone mapping or color grading.
  40463. */
  40464. imageProcessing: ImageProcessingPostProcess;
  40465. /**
  40466. * Chromatic aberration post process which will shift rgb colors in the image
  40467. */
  40468. chromaticAberration: ChromaticAberrationPostProcess;
  40469. private _chromaticAberrationEffect;
  40470. /**
  40471. * Grain post process which add noise to the image
  40472. */
  40473. grain: GrainPostProcess;
  40474. private _grainEffect;
  40475. /**
  40476. * Animations which can be used to tweak settings over a period of time
  40477. */
  40478. animations: Animation[];
  40479. private _imageProcessingConfigurationObserver;
  40480. private _sharpenEnabled;
  40481. private _bloomEnabled;
  40482. private _depthOfFieldEnabled;
  40483. private _depthOfFieldBlurLevel;
  40484. private _fxaaEnabled;
  40485. private _imageProcessingEnabled;
  40486. private _defaultPipelineTextureType;
  40487. private _bloomScale;
  40488. private _chromaticAberrationEnabled;
  40489. private _grainEnabled;
  40490. private _buildAllowed;
  40491. /**
  40492. * Enable or disable the sharpen process from the pipeline
  40493. */
  40494. sharpenEnabled: boolean;
  40495. private _resizeObserver;
  40496. private _hardwareScaleLevel;
  40497. private _bloomKernel;
  40498. /**
  40499. * Specifies the size of the bloom blur kernel, relative to the final output size
  40500. */
  40501. bloomKernel: number;
  40502. /**
  40503. * Specifies the weight of the bloom in the final rendering
  40504. */
  40505. private _bloomWeight;
  40506. /**
  40507. * Specifies the luma threshold for the area that will be blurred by the bloom
  40508. */
  40509. private _bloomThreshold;
  40510. private _hdr;
  40511. /**
  40512. * The strength of the bloom.
  40513. */
  40514. bloomWeight: number;
  40515. /**
  40516. * The strength of the bloom.
  40517. */
  40518. bloomThreshold: number;
  40519. /**
  40520. * The scale of the bloom, lower value will provide better performance.
  40521. */
  40522. bloomScale: number;
  40523. /**
  40524. * Enable or disable the bloom from the pipeline
  40525. */
  40526. bloomEnabled: boolean;
  40527. private _rebuildBloom();
  40528. /**
  40529. * If the depth of field is enabled.
  40530. */
  40531. depthOfFieldEnabled: boolean;
  40532. /**
  40533. * Blur level of the depth of field effect. (Higher blur will effect performance)
  40534. */
  40535. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  40536. /**
  40537. * If the anti aliasing is enabled.
  40538. */
  40539. fxaaEnabled: boolean;
  40540. private _samples;
  40541. /**
  40542. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  40543. */
  40544. samples: number;
  40545. /**
  40546. * If image processing is enabled.
  40547. */
  40548. imageProcessingEnabled: boolean;
  40549. /**
  40550. * Enable or disable the chromaticAberration process from the pipeline
  40551. */
  40552. chromaticAberrationEnabled: boolean;
  40553. /**
  40554. * Enable or disable the grain process from the pipeline
  40555. */
  40556. grainEnabled: boolean;
  40557. /**
  40558. * @constructor
  40559. * @param {string} name - The rendering pipeline name
  40560. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40561. * @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)
  40562. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40563. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  40564. */
  40565. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  40566. /**
  40567. * Force the compilation of the entire pipeline.
  40568. */
  40569. prepare(): void;
  40570. private _hasCleared;
  40571. private _prevPostProcess;
  40572. private _prevPrevPostProcess;
  40573. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  40574. private _buildPipeline();
  40575. private _disposePostProcesses(disposeNonRecreated?);
  40576. /**
  40577. * Dispose of the pipeline and stop all post processes
  40578. */
  40579. dispose(): void;
  40580. /**
  40581. * Serialize the rendering pipeline (Used when exporting)
  40582. * @returns the serialized object
  40583. */
  40584. serialize(): any;
  40585. /**
  40586. * Parse the serialized pipeline
  40587. * @param source Source pipeline.
  40588. * @param scene The scene to load the pipeline to.
  40589. * @param rootUrl The URL of the serialized pipeline.
  40590. * @returns An instantiated pipeline from the serialized object.
  40591. */
  40592. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  40593. }
  40594. }
  40595. declare module BABYLON {
  40596. class LensRenderingPipeline extends PostProcessRenderPipeline {
  40597. /**
  40598. * The chromatic aberration PostProcess id in the pipeline
  40599. * @type {string}
  40600. */
  40601. LensChromaticAberrationEffect: string;
  40602. /**
  40603. * The highlights enhancing PostProcess id in the pipeline
  40604. * @type {string}
  40605. */
  40606. HighlightsEnhancingEffect: string;
  40607. /**
  40608. * The depth-of-field PostProcess id in the pipeline
  40609. * @type {string}
  40610. */
  40611. LensDepthOfFieldEffect: string;
  40612. private _scene;
  40613. private _depthTexture;
  40614. private _grainTexture;
  40615. private _chromaticAberrationPostProcess;
  40616. private _highlightsPostProcess;
  40617. private _depthOfFieldPostProcess;
  40618. private _edgeBlur;
  40619. private _grainAmount;
  40620. private _chromaticAberration;
  40621. private _distortion;
  40622. private _highlightsGain;
  40623. private _highlightsThreshold;
  40624. private _dofDistance;
  40625. private _dofAperture;
  40626. private _dofDarken;
  40627. private _dofPentagon;
  40628. private _blurNoise;
  40629. /**
  40630. * @constructor
  40631. *
  40632. * Effect parameters are as follow:
  40633. * {
  40634. * chromatic_aberration: number; // from 0 to x (1 for realism)
  40635. * edge_blur: number; // from 0 to x (1 for realism)
  40636. * distortion: number; // from 0 to x (1 for realism)
  40637. * grain_amount: number; // from 0 to 1
  40638. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  40639. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  40640. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  40641. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  40642. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  40643. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  40644. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  40645. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  40646. * }
  40647. * Note: if an effect parameter is unset, effect is disabled
  40648. *
  40649. * @param {string} name - The rendering pipeline name
  40650. * @param {object} parameters - An object containing all parameters (see above)
  40651. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40652. * @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)
  40653. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40654. */
  40655. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  40656. setEdgeBlur(amount: number): void;
  40657. disableEdgeBlur(): void;
  40658. setGrainAmount(amount: number): void;
  40659. disableGrain(): void;
  40660. setChromaticAberration(amount: number): void;
  40661. disableChromaticAberration(): void;
  40662. setEdgeDistortion(amount: number): void;
  40663. disableEdgeDistortion(): void;
  40664. setFocusDistance(amount: number): void;
  40665. disableDepthOfField(): void;
  40666. setAperture(amount: number): void;
  40667. setDarkenOutOfFocus(amount: number): void;
  40668. enablePentagonBokeh(): void;
  40669. disablePentagonBokeh(): void;
  40670. enableNoiseBlur(): void;
  40671. disableNoiseBlur(): void;
  40672. setHighlightsGain(amount: number): void;
  40673. setHighlightsThreshold(amount: number): void;
  40674. disableHighlights(): void;
  40675. /**
  40676. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  40677. */
  40678. dispose(disableDepthRender?: boolean): void;
  40679. private _createChromaticAberrationPostProcess(ratio);
  40680. private _createHighlightsPostProcess(ratio);
  40681. private _createDepthOfFieldPostProcess(ratio);
  40682. private _createGrainTexture();
  40683. }
  40684. }
  40685. declare module BABYLON {
  40686. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  40687. /**
  40688. * The PassPostProcess id in the pipeline that contains the original scene color
  40689. * @type {string}
  40690. */
  40691. SSAOOriginalSceneColorEffect: string;
  40692. /**
  40693. * The SSAO PostProcess id in the pipeline
  40694. * @type {string}
  40695. */
  40696. SSAORenderEffect: string;
  40697. /**
  40698. * The horizontal blur PostProcess id in the pipeline
  40699. * @type {string}
  40700. */
  40701. SSAOBlurHRenderEffect: string;
  40702. /**
  40703. * The vertical blur PostProcess id in the pipeline
  40704. * @type {string}
  40705. */
  40706. SSAOBlurVRenderEffect: string;
  40707. /**
  40708. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  40709. * @type {string}
  40710. */
  40711. SSAOCombineRenderEffect: string;
  40712. /**
  40713. * The output strength of the SSAO post-process. Default value is 1.0.
  40714. * @type {number}
  40715. */
  40716. totalStrength: number;
  40717. /**
  40718. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  40719. * @type {number}
  40720. */
  40721. maxZ: number;
  40722. /**
  40723. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  40724. * @type {number}
  40725. */
  40726. minZAspect: number;
  40727. /**
  40728. * Number of samples used for the SSAO calculations. Default value is 8
  40729. * @type {number}
  40730. */
  40731. private _samples;
  40732. /**
  40733. * Dynamically generated sphere sampler.
  40734. * @type {number[]}
  40735. */
  40736. private _sampleSphere;
  40737. /**
  40738. * Blur filter offsets
  40739. * @type {number[]}
  40740. */
  40741. private _samplerOffsets;
  40742. samples: number;
  40743. /**
  40744. * Are we using bilateral blur ?
  40745. * @type {boolean}
  40746. */
  40747. private _expensiveBlur;
  40748. expensiveBlur: boolean;
  40749. /**
  40750. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  40751. * @type {number}
  40752. */
  40753. radius: number;
  40754. /**
  40755. * The base color of the SSAO post-process
  40756. * The final result is "base + ssao" between [0, 1]
  40757. * @type {number}
  40758. */
  40759. base: number;
  40760. /**
  40761. * Support test.
  40762. * @type {boolean}
  40763. */
  40764. static readonly IsSupported: boolean;
  40765. private _scene;
  40766. private _depthTexture;
  40767. private _normalTexture;
  40768. private _randomTexture;
  40769. private _originalColorPostProcess;
  40770. private _ssaoPostProcess;
  40771. private _blurHPostProcess;
  40772. private _blurVPostProcess;
  40773. private _ssaoCombinePostProcess;
  40774. private _firstUpdate;
  40775. /**
  40776. * @constructor
  40777. * @param {string} name - The rendering pipeline name
  40778. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40779. * @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 }
  40780. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40781. */
  40782. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  40783. /**
  40784. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  40785. */
  40786. dispose(disableGeometryBufferRenderer?: boolean): void;
  40787. private _createBlurPostProcess(ssaoRatio, blurRatio);
  40788. _rebuild(): void;
  40789. private _generateHemisphere();
  40790. private _createSSAOPostProcess(ratio);
  40791. private _createSSAOCombinePostProcess(ratio);
  40792. private _createRandomTexture();
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  40797. /**
  40798. * The PassPostProcess id in the pipeline that contains the original scene color
  40799. * @type {string}
  40800. */
  40801. SSAOOriginalSceneColorEffect: string;
  40802. /**
  40803. * The SSAO PostProcess id in the pipeline
  40804. * @type {string}
  40805. */
  40806. SSAORenderEffect: string;
  40807. /**
  40808. * The horizontal blur PostProcess id in the pipeline
  40809. * @type {string}
  40810. */
  40811. SSAOBlurHRenderEffect: string;
  40812. /**
  40813. * The vertical blur PostProcess id in the pipeline
  40814. * @type {string}
  40815. */
  40816. SSAOBlurVRenderEffect: string;
  40817. /**
  40818. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  40819. * @type {string}
  40820. */
  40821. SSAOCombineRenderEffect: string;
  40822. /**
  40823. * The output strength of the SSAO post-process. Default value is 1.0.
  40824. * @type {number}
  40825. */
  40826. totalStrength: number;
  40827. /**
  40828. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  40829. * @type {number}
  40830. */
  40831. radius: number;
  40832. /**
  40833. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  40834. * Must not be equal to fallOff and superior to fallOff.
  40835. * Default value is 0.975
  40836. * @type {number}
  40837. */
  40838. area: number;
  40839. /**
  40840. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  40841. * Must not be equal to area and inferior to area.
  40842. * Default value is 0.0
  40843. * @type {number}
  40844. */
  40845. fallOff: number;
  40846. /**
  40847. * The base color of the SSAO post-process
  40848. * The final result is "base + ssao" between [0, 1]
  40849. * @type {number}
  40850. */
  40851. base: number;
  40852. private _scene;
  40853. private _depthTexture;
  40854. private _randomTexture;
  40855. private _originalColorPostProcess;
  40856. private _ssaoPostProcess;
  40857. private _blurHPostProcess;
  40858. private _blurVPostProcess;
  40859. private _ssaoCombinePostProcess;
  40860. private _firstUpdate;
  40861. /**
  40862. * @constructor
  40863. * @param {string} name - The rendering pipeline name
  40864. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40865. * @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 }
  40866. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40867. */
  40868. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  40869. /**
  40870. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  40871. */
  40872. dispose(disableDepthRender?: boolean): void;
  40873. private _createBlurPostProcess(ratio);
  40874. _rebuild(): void;
  40875. private _createSSAOPostProcess(ratio);
  40876. private _createSSAOCombinePostProcess(ratio);
  40877. private _createRandomTexture();
  40878. }
  40879. }
  40880. declare module BABYLON {
  40881. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  40882. /**
  40883. * Public members
  40884. */
  40885. originalPostProcess: Nullable<PostProcess>;
  40886. downSampleX4PostProcess: Nullable<PostProcess>;
  40887. brightPassPostProcess: Nullable<PostProcess>;
  40888. blurHPostProcesses: PostProcess[];
  40889. blurVPostProcesses: PostProcess[];
  40890. textureAdderPostProcess: Nullable<PostProcess>;
  40891. volumetricLightPostProcess: Nullable<PostProcess>;
  40892. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  40893. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  40894. volumetricLightMergePostProces: Nullable<PostProcess>;
  40895. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  40896. luminancePostProcess: Nullable<PostProcess>;
  40897. luminanceDownSamplePostProcesses: PostProcess[];
  40898. hdrPostProcess: Nullable<PostProcess>;
  40899. textureAdderFinalPostProcess: Nullable<PostProcess>;
  40900. lensFlareFinalPostProcess: Nullable<PostProcess>;
  40901. hdrFinalPostProcess: Nullable<PostProcess>;
  40902. lensFlarePostProcess: Nullable<PostProcess>;
  40903. lensFlareComposePostProcess: Nullable<PostProcess>;
  40904. motionBlurPostProcess: Nullable<PostProcess>;
  40905. depthOfFieldPostProcess: Nullable<PostProcess>;
  40906. brightThreshold: number;
  40907. blurWidth: number;
  40908. horizontalBlur: boolean;
  40909. exposure: number;
  40910. lensTexture: Nullable<Texture>;
  40911. volumetricLightCoefficient: number;
  40912. volumetricLightPower: number;
  40913. volumetricLightBlurScale: number;
  40914. sourceLight: Nullable<SpotLight | DirectionalLight>;
  40915. hdrMinimumLuminance: number;
  40916. hdrDecreaseRate: number;
  40917. hdrIncreaseRate: number;
  40918. lensColorTexture: Nullable<Texture>;
  40919. lensFlareStrength: number;
  40920. lensFlareGhostDispersal: number;
  40921. lensFlareHaloWidth: number;
  40922. lensFlareDistortionStrength: number;
  40923. lensStarTexture: Nullable<Texture>;
  40924. lensFlareDirtTexture: Nullable<Texture>;
  40925. depthOfFieldDistance: number;
  40926. depthOfFieldBlurWidth: number;
  40927. motionStrength: number;
  40928. animations: Animation[];
  40929. /**
  40930. * Private members
  40931. */
  40932. private _scene;
  40933. private _currentDepthOfFieldSource;
  40934. private _basePostProcess;
  40935. private _hdrCurrentLuminance;
  40936. private _floatTextureType;
  40937. private _ratio;
  40938. private _bloomEnabled;
  40939. private _depthOfFieldEnabled;
  40940. private _vlsEnabled;
  40941. private _lensFlareEnabled;
  40942. private _hdrEnabled;
  40943. private _motionBlurEnabled;
  40944. private _motionBlurSamples;
  40945. private _volumetricLightStepsCount;
  40946. BloomEnabled: boolean;
  40947. DepthOfFieldEnabled: boolean;
  40948. LensFlareEnabled: boolean;
  40949. HDREnabled: boolean;
  40950. VLSEnabled: boolean;
  40951. MotionBlurEnabled: boolean;
  40952. volumetricLightStepsCount: number;
  40953. motionBlurSamples: number;
  40954. /**
  40955. * @constructor
  40956. * @param {string} name - The rendering pipeline name
  40957. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40958. * @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)
  40959. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  40960. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40961. */
  40962. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  40963. private _buildPipeline();
  40964. private _createDownSampleX4PostProcess(scene, ratio);
  40965. private _createBrightPassPostProcess(scene, ratio);
  40966. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  40967. private _createTextureAdderPostProcess(scene, ratio);
  40968. private _createVolumetricLightPostProcess(scene, ratio);
  40969. private _createLuminancePostProcesses(scene, textureType);
  40970. private _createHdrPostProcess(scene, ratio);
  40971. private _createLensFlarePostProcess(scene, ratio);
  40972. private _createDepthOfFieldPostProcess(scene, ratio);
  40973. private _createMotionBlurPostProcess(scene, ratio);
  40974. private _getDepthTexture();
  40975. private _disposePostProcesses();
  40976. dispose(): void;
  40977. serialize(): any;
  40978. /**
  40979. * Static members
  40980. */
  40981. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  40982. static LuminanceSteps: number;
  40983. }
  40984. }