babylon.inspector.js 244 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562
  1. var INSPECTOR;
  2. (function (INSPECTOR) {
  3. var Inspector = /** @class */ (function () {
  4. /** The inspector is created with the given engine.
  5. * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
  6. * If the parameter 'popup' is true, the inspector is created in another popup.
  7. */
  8. function Inspector(scene, popup, initialTab, parentElement, newColors) {
  9. if (initialTab === void 0) { initialTab = 0; }
  10. if (parentElement === void 0) { parentElement = null; }
  11. var _this = this;
  12. /** True if the inspector is built as a popup tab */
  13. this._popupMode = false;
  14. // Load GUI library if not already done
  15. if (!BABYLON.GUI) {
  16. BABYLON.Tools.LoadScript("https://preview.babylonjs.com/gui/babylon.gui.js", function () {
  17. //Load properties of GUI objects now as BABYLON.GUI has to be declared before
  18. INSPECTOR.loadGUIProperties();
  19. }, function () {
  20. console.warn('Error : loading "babylon.gui.js". Please add script https://preview.babylonjs.com/gui/babylon.gui.js to the HTML file.');
  21. });
  22. }
  23. else {
  24. //Load properties of GUI objects now as BABYLON.GUI has to be declared before
  25. INSPECTOR.loadGUIProperties();
  26. }
  27. //get Tabbar initialTab
  28. this._initialTab = initialTab;
  29. //get parentElement of our Inspector
  30. this._parentElement = parentElement;
  31. // get canvas parent only if needed.
  32. this._scene = scene;
  33. // Save HTML document and window
  34. Inspector.DOCUMENT = window.document;
  35. Inspector.WINDOW = window;
  36. // POPUP MODE
  37. if (popup) {
  38. // Build the inspector in the given parent
  39. this.openPopup(true); // set to true in order to NOT dispose the inspector (done in openPopup), as it's not existing yet
  40. }
  41. else {
  42. // Get canvas and its DOM parent
  43. var canvas = this._scene.getEngine().getRenderingCanvas();
  44. var canvasParent = canvas.parentElement;
  45. // get canvas style
  46. var canvasComputedStyle = Inspector.WINDOW.getComputedStyle(canvas);
  47. this._canvasStyle = {
  48. width: INSPECTOR.Helpers.Css(canvas, 'width'),
  49. height: INSPECTOR.Helpers.Css(canvas, 'height'),
  50. position: canvasComputedStyle.position,
  51. top: canvasComputedStyle.top,
  52. bottom: canvasComputedStyle.bottom,
  53. left: canvasComputedStyle.left,
  54. right: canvasComputedStyle.right,
  55. padding: canvasComputedStyle.padding,
  56. paddingBottom: canvasComputedStyle.paddingBottom,
  57. paddingLeft: canvasComputedStyle.paddingLeft,
  58. paddingTop: canvasComputedStyle.paddingTop,
  59. paddingRight: canvasComputedStyle.paddingRight,
  60. margin: canvasComputedStyle.margin,
  61. marginBottom: canvasComputedStyle.marginBottom,
  62. marginLeft: canvasComputedStyle.marginLeft,
  63. marginTop: canvasComputedStyle.marginTop,
  64. marginRight: canvasComputedStyle.marginRight
  65. };
  66. if (this._parentElement) {
  67. // Build the inspector wrapper
  68. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper', this._parentElement);
  69. this._c2diwrapper.style.width = '100%';
  70. this._c2diwrapper.style.height = '100%';
  71. this._c2diwrapper.style.paddingLeft = '5px';
  72. // add inspector
  73. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  74. inspector.style.width = '100%';
  75. inspector.style.height = '100%';
  76. // and build it in the popup
  77. this._buildInspector(inspector);
  78. }
  79. else {
  80. // Create c2di wrapper
  81. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper');
  82. // copy style from canvas to wrapper
  83. for (var prop in this._canvasStyle) {
  84. this._c2diwrapper.style[prop] = this._canvasStyle[prop];
  85. }
  86. if (!canvasComputedStyle.width || !canvasComputedStyle.height || !canvasComputedStyle.left) {
  87. return;
  88. }
  89. // Convert wrapper size in % (because getComputedStyle returns px only)
  90. var widthPx = parseFloat(canvasComputedStyle.width.substr(0, canvasComputedStyle.width.length - 2)) || 0;
  91. var heightPx = parseFloat(canvasComputedStyle.height.substr(0, canvasComputedStyle.height.length - 2)) || 0;
  92. // If the canvas position is absolute, restrain the wrapper width to the window width + left positionning
  93. if (canvasComputedStyle.position === "absolute" || canvasComputedStyle.position === "relative") {
  94. // compute only left as it takes predominance if right is also specified (and it will be for the wrapper)
  95. var leftPx = parseFloat(canvasComputedStyle.left.substr(0, canvasComputedStyle.left.length - 2)) || 0;
  96. if (widthPx + leftPx >= Inspector.WINDOW.innerWidth) {
  97. this._c2diwrapper.style.maxWidth = widthPx - leftPx + "px";
  98. }
  99. }
  100. // Check if the parent of the canvas is the body page. If yes, the size ratio is computed
  101. var parent_1 = this._getRelativeParent(canvas);
  102. var parentWidthPx = parent_1.clientWidth;
  103. var parentHeightPx = parent_1.clientHeight;
  104. var pWidth = widthPx / parentWidthPx * 100;
  105. var pheight = heightPx / parentHeightPx * 100;
  106. this._c2diwrapper.style.width = pWidth + "%";
  107. this._c2diwrapper.style.height = pheight + "%";
  108. // reset canvas style
  109. canvas.style.position = "static";
  110. canvas.style.width = "100%";
  111. canvas.style.height = "100%";
  112. canvas.style.paddingBottom = "0";
  113. canvas.style.paddingLeft = "0";
  114. canvas.style.paddingTop = "0";
  115. canvas.style.paddingRight = "0";
  116. canvas.style.margin = "0";
  117. canvas.style.marginBottom = "0";
  118. canvas.style.marginLeft = "0";
  119. canvas.style.marginTop = "0";
  120. canvas.style.marginRight = "0";
  121. // Replace canvas with the wrapper...
  122. if (canvasParent) {
  123. canvasParent.replaceChild(this._c2diwrapper, canvas);
  124. }
  125. // ... and add canvas to the wrapper
  126. this._c2diwrapper.appendChild(canvas);
  127. // add inspector
  128. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  129. // Add split bar
  130. if (!this._parentElement) {
  131. Split([canvas, inspector], {
  132. direction: 'horizontal',
  133. sizes: [75, 25],
  134. onDrag: function () {
  135. INSPECTOR.Helpers.SEND_EVENT('resize');
  136. if (_this._tabbar) {
  137. _this._tabbar.updateWidth();
  138. }
  139. }
  140. });
  141. }
  142. // Build the inspector
  143. this._buildInspector(inspector);
  144. }
  145. // Send resize event to the window
  146. INSPECTOR.Helpers.SEND_EVENT('resize');
  147. this._tabbar.updateWidth();
  148. }
  149. /*
  150. * Refresh the inspector if the browser is not edge
  151. * Why not ?! Condition commented on 180525
  152. * To be tested
  153. */
  154. // if (!Helpers.IsBrowserEdge()) {
  155. this.refresh();
  156. // }
  157. // Check custom css colors
  158. if (newColors) {
  159. var bColor = newColors.backgroundColor || '#242424';
  160. var bColorl1 = newColors.backgroundColorLighter || '#2c2c2c';
  161. var bColorl2 = newColors.backgroundColorLighter2 || '#383838';
  162. var bColorl3 = newColors.backgroundColorLighter3 || '#454545';
  163. var color = newColors.color || '#ccc';
  164. var colorTop = newColors.colorTop || '#f29766';
  165. var colorBot = newColors.colorBot || '#5db0d7';
  166. var styles = Inspector.DOCUMENT.querySelectorAll('style');
  167. for (var s = 0; s < styles.length; s++) {
  168. var style = styles[s];
  169. if (style.innerHTML.indexOf('insp-wrapper') != -1) {
  170. styles[s].innerHTML = styles[s].innerHTML
  171. .replace(/#242424/g, bColor) // background color
  172. .replace(/#2c2c2c/g, bColorl1) // background-lighter
  173. .replace(/#383838/g, bColorl2) // background-lighter2
  174. .replace(/#454545/g, bColorl3) // background-lighter3
  175. .replace(/#ccc/g, color) // color
  176. .replace(/#f29766/g, colorTop) // color-top
  177. .replace(/#5db0d7/g, colorBot); // color-bot
  178. }
  179. }
  180. }
  181. }
  182. /**
  183. * If the given element has a position 'asbolute' or 'relative',
  184. * returns the first parent of the given element that has a position 'relative' or 'absolute'.
  185. * If the given element has no position, returns the first parent
  186. *
  187. */
  188. Inspector.prototype._getRelativeParent = function (elem, lookForAbsoluteOrRelative) {
  189. // If the elem has no parent, returns himself
  190. if (!elem.parentElement) {
  191. return elem;
  192. }
  193. var computedStyle = Inspector.WINDOW.getComputedStyle(elem);
  194. // looking for the first element absolute or relative
  195. if (lookForAbsoluteOrRelative) {
  196. // if found, return this one
  197. if (computedStyle.position === "relative" || computedStyle.position === "absolute") {
  198. return elem;
  199. }
  200. else {
  201. // otherwise keep looking
  202. return this._getRelativeParent(elem.parentElement, true);
  203. }
  204. }
  205. // looking for the relative parent of the element
  206. else {
  207. if (computedStyle.position == "static") {
  208. return elem.parentElement;
  209. }
  210. else {
  211. // the elem has a position relative or absolute, look for the closest relative/absolute parent
  212. return this._getRelativeParent(elem.parentElement, true);
  213. }
  214. }
  215. };
  216. /** Build the inspector panel in the given HTML element */
  217. Inspector.prototype._buildInspector = function (parent) {
  218. // tabbar
  219. this._tabbar = new INSPECTOR.TabBar(this, this._initialTab);
  220. // Top panel
  221. this._topPanel = INSPECTOR.Helpers.CreateDiv('top-panel', parent);
  222. // Add tabbar
  223. this._topPanel.appendChild(this._tabbar.toHtml());
  224. this._tabbar.updateWidth();
  225. // Tab panel
  226. this._tabPanel = INSPECTOR.Helpers.CreateDiv('tab-panel-content', this._topPanel);
  227. };
  228. Object.defineProperty(Inspector.prototype, "scene", {
  229. get: function () {
  230. return this._scene;
  231. },
  232. enumerable: true,
  233. configurable: true
  234. });
  235. Object.defineProperty(Inspector.prototype, "popupMode", {
  236. get: function () {
  237. return this._popupMode;
  238. },
  239. enumerable: true,
  240. configurable: true
  241. });
  242. /**
  243. * Filter the list of item present in the tree.
  244. * All item returned should have the given filter contained in the item id.
  245. */
  246. Inspector.prototype.filterItem = function (filter) {
  247. var tab = this._tabbar.getActiveTab();
  248. if (tab) {
  249. tab.filter(filter);
  250. }
  251. };
  252. /** Display the mesh tab on the given object */
  253. Inspector.prototype.displayObjectDetails = function (mesh) {
  254. this._tabbar.switchMeshTab(mesh);
  255. };
  256. /** Clean the whole tree of item and rebuilds it */
  257. Inspector.prototype.refresh = function () {
  258. // Clean top panel
  259. INSPECTOR.Helpers.CleanDiv(this._tabPanel);
  260. // Get the active tab and its items
  261. var activeTab = this._tabbar.getActiveTab();
  262. if (!activeTab) {
  263. return;
  264. }
  265. activeTab.update();
  266. this._tabPanel.appendChild(activeTab.getPanel());
  267. INSPECTOR.Helpers.SEND_EVENT('resize');
  268. };
  269. /** Remove the inspector panel when it's built as a right panel:
  270. * remove the right panel and remove the wrapper
  271. */
  272. Inspector.prototype.dispose = function () {
  273. if (!this._popupMode) {
  274. var activeTab = this._tabbar.getActiveTab();
  275. if (activeTab) {
  276. activeTab.dispose();
  277. }
  278. // Get canvas
  279. var canvas = this._scene.getEngine().getRenderingCanvas();
  280. // restore canvas style
  281. for (var prop in this._canvasStyle) {
  282. canvas.style[prop] = this._canvasStyle[prop];
  283. }
  284. // Get parent of the wrapper
  285. if (canvas.parentElement) {
  286. var canvasParent = canvas.parentElement.parentElement;
  287. if (canvasParent) {
  288. canvasParent.insertBefore(canvas, this._c2diwrapper);
  289. // Remove wrapper
  290. INSPECTOR.Helpers.CleanDiv(this._c2diwrapper);
  291. this._c2diwrapper.remove();
  292. // Send resize event to the window
  293. INSPECTOR.Helpers.SEND_EVENT('resize');
  294. }
  295. }
  296. }
  297. INSPECTOR.Scheduler.getInstance().dispose();
  298. };
  299. /** Open the inspector in a new popup
  300. * Set 'firstTime' to true if there is no inspector created beforehands
  301. */
  302. Inspector.prototype.openPopup = function (firstTime) {
  303. var _this = this;
  304. // Create popup
  305. var popup = window.open('', 'Babylon.js INSPECTOR', 'toolbar=no,resizable=yes,menubar=no,width=750,height=1000');
  306. if (!popup) {
  307. alert("Please update your browser to open the Babylon.js inspector in an external view.");
  308. return;
  309. }
  310. popup.document.title = "Babylon.js INSPECTOR";
  311. // Get the inspector style
  312. var styles = Inspector.DOCUMENT.querySelectorAll('style');
  313. for (var s = 0; s < styles.length; s++) {
  314. popup.document.body.appendChild(styles[s].cloneNode(true));
  315. }
  316. var links = document.querySelectorAll('link');
  317. for (var l = 0; l < links.length; l++) {
  318. var link = popup.document.createElement("link");
  319. link.rel = "stylesheet";
  320. link.href = links[l].href;
  321. popup.document.head.appendChild(link);
  322. }
  323. // Dispose the right panel if existing
  324. if (!firstTime) {
  325. this.dispose();
  326. }
  327. // set the mode as popup
  328. this._popupMode = true;
  329. // Save the HTML document
  330. Inspector.DOCUMENT = popup.document;
  331. Inspector.WINDOW = popup;
  332. // Build the inspector wrapper
  333. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper', popup.document.body);
  334. // add inspector
  335. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  336. inspector.classList.add('popupmode');
  337. // and build it in the popup
  338. this._buildInspector(inspector);
  339. // Rebuild it
  340. this.refresh();
  341. popup.addEventListener('resize', function () {
  342. if (_this._tabbar) {
  343. _this._tabbar.updateWidth();
  344. }
  345. });
  346. };
  347. Inspector.prototype.getActiveTabIndex = function () {
  348. return this._tabbar.getActiveTabIndex();
  349. };
  350. return Inspector;
  351. }());
  352. INSPECTOR.Inspector = Inspector;
  353. })(INSPECTOR || (INSPECTOR = {}));
  354. //# sourceMappingURL=Inspector.js.map
  355. /// <reference path="../../dist/preview release/babylon.d.ts"/>
  356. var INSPECTOR;
  357. (function (INSPECTOR) {
  358. INSPECTOR.PROPERTIES = {
  359. /** Format the given object :
  360. * If a format function exists, returns the result of this function.
  361. * If this function doesn't exists, return the object type instead */
  362. format: function (obj) {
  363. var type = INSPECTOR.Helpers.GET_TYPE(obj) || 'type_not_defined';
  364. if (INSPECTOR.PROPERTIES[type] && INSPECTOR.PROPERTIES[type].format) {
  365. return INSPECTOR.PROPERTIES[type].format(obj);
  366. }
  367. else {
  368. return INSPECTOR.Helpers.GET_TYPE(obj);
  369. }
  370. },
  371. 'type_not_defined': {
  372. properties: new Array(),
  373. format: function () { return ''; }
  374. },
  375. 'Vector2': {
  376. type: BABYLON.Vector2,
  377. format: function (vec) { return "x:" + INSPECTOR.Helpers.Trunc(vec.x) + ", y:" + INSPECTOR.Helpers.Trunc(vec.y); }
  378. },
  379. 'Vector3': {
  380. type: BABYLON.Vector3,
  381. format: function (vec) { return "x:" + INSPECTOR.Helpers.Trunc(vec.x) + ", y:" + INSPECTOR.Helpers.Trunc(vec.y) + ", z:" + INSPECTOR.Helpers.Trunc(vec.z); }
  382. },
  383. 'Color3': {
  384. type: BABYLON.Color3,
  385. format: function (color) { return "R:" + color.r.toPrecision(2) + ", G:" + color.g.toPrecision(2) + ", B:" + color.b.toPrecision(2); },
  386. slider: {
  387. r: { min: 0, max: 1, step: 0.01 },
  388. g: { min: 0, max: 1, step: 0.01 },
  389. b: { min: 0, max: 1, step: 0.01 }
  390. }
  391. },
  392. 'Color4': {
  393. type: BABYLON.Color4,
  394. format: function (color) { return "R:" + color.r + ", G:" + color.g + ", B:" + color.b; },
  395. slider: {
  396. r: { min: 0, max: 1, step: 0.01 },
  397. g: { min: 0, max: 1, step: 0.01 },
  398. b: { min: 0, max: 1, step: 0.01 }
  399. }
  400. },
  401. 'Quaternion': {
  402. type: BABYLON.Quaternion
  403. },
  404. 'Size': {
  405. type: BABYLON.Size,
  406. format: function (size) { return "Size - w:" + INSPECTOR.Helpers.Trunc(size.width) + ", h:" + INSPECTOR.Helpers.Trunc(size.height); }
  407. },
  408. 'Texture': {
  409. type: BABYLON.Texture,
  410. format: function (tex) { return tex.name; }
  411. },
  412. 'RenderTargetTexture': {
  413. type: BABYLON.RenderTargetTexture
  414. },
  415. 'DynamicTexture': {
  416. type: BABYLON.DynamicTexture
  417. },
  418. 'BaseTexture': {
  419. type: BABYLON.BaseTexture
  420. },
  421. 'CubeTexture': {
  422. type: BABYLON.CubeTexture
  423. },
  424. 'HDRCubeTexture': {
  425. type: BABYLON.HDRCubeTexture
  426. },
  427. 'Sound': {
  428. type: BABYLON.Sound
  429. },
  430. 'ArcRotateCamera': {
  431. type: BABYLON.ArcRotateCamera,
  432. slider: {
  433. alpha: { min: 0, max: 2 * Math.PI, step: 0.01 },
  434. beta: { min: -Math.PI, max: Math.PI, step: 0.01 },
  435. fov: { min: 0, max: 180, step: 1 }
  436. }
  437. },
  438. 'FreeCamera': {
  439. type: BABYLON.FreeCamera,
  440. slider: {
  441. fov: { min: 0, max: 180, step: 1 }
  442. }
  443. },
  444. 'Scene': {
  445. type: BABYLON.Scene,
  446. },
  447. 'TransformNode': {
  448. type: BABYLON.TransformNode,
  449. format: function (m) { return m.name; }
  450. },
  451. 'AbstractMesh': {
  452. type: BABYLON.AbstractMesh,
  453. format: function (m) { return m.name; }
  454. },
  455. 'Mesh': {
  456. type: BABYLON.Mesh,
  457. format: function (m) { return m.name; },
  458. slider: {
  459. visibility: { min: 0, max: 1, step: 0.1 }
  460. }
  461. },
  462. 'StandardMaterial': {
  463. type: BABYLON.StandardMaterial,
  464. format: function (mat) { return mat.name; },
  465. slider: {
  466. alpha: { min: 0, max: 1, step: 0.01 }
  467. }
  468. },
  469. 'PBRMaterial': {
  470. type: BABYLON.PBRMaterial,
  471. slider: {
  472. alpha: { min: 0, max: 1, step: 0.01 }
  473. }
  474. },
  475. 'PhysicsImpostor': {
  476. type: BABYLON.PhysicsImpostor
  477. },
  478. 'ImageProcessingConfiguration': {
  479. type: BABYLON.ImageProcessingConfiguration
  480. },
  481. 'ColorCurves': {
  482. type: BABYLON.ColorCurves
  483. }
  484. };
  485. })(INSPECTOR || (INSPECTOR = {}));
  486. //# sourceMappingURL=properties.js.map
  487. /// <reference path="../../dist/preview release/gui/babylon.gui.d.ts"/>
  488. var INSPECTOR;
  489. (function (INSPECTOR) {
  490. /**
  491. * Function that add gui objects properties to the variable PROPERTIES
  492. */
  493. function loadGUIProperties() {
  494. var PROPERTIES_GUI = {
  495. 'ValueAndUnit': {
  496. type: BABYLON.GUI.ValueAndUnit,
  497. properties: ['_value', 'unit'],
  498. format: function (valueAndUnit) { return valueAndUnit; }
  499. },
  500. 'Control': {
  501. type: BABYLON.GUI.Control,
  502. properties: [
  503. '_alpha',
  504. '_fontFamily',
  505. '_color',
  506. '_scaleX',
  507. '_scaleY',
  508. '_rotation',
  509. '_currentMeasure',
  510. '_width',
  511. '_height',
  512. '_left',
  513. '_top',
  514. '_linkedMesh',
  515. 'isHitTestVisible',
  516. 'isPointerBlocker',
  517. ],
  518. format: function (control) { return control.name; }
  519. },
  520. 'Button': {
  521. type: BABYLON.GUI.Button,
  522. properties: new Array(),
  523. format: function (button) { return button.name; }
  524. },
  525. 'ColorPicker': {
  526. type: BABYLON.GUI.ColorPicker,
  527. properties: ['_value'],
  528. format: function (colorPicker) { return colorPicker.name; }
  529. },
  530. 'Checkbox': {
  531. type: BABYLON.GUI.Checkbox,
  532. properties: ['_isChecked', '_background'],
  533. format: function (checkbox) { return checkbox.name; }
  534. },
  535. 'Ellipse': {
  536. type: BABYLON.GUI.Ellipse,
  537. properties: ['_thickness'],
  538. format: function (ellipse) { return ellipse.name; }
  539. },
  540. 'Image': {
  541. type: BABYLON.GUI.Image,
  542. properties: [
  543. '_imageWidth',
  544. '_imageHeight',
  545. '_loaded',
  546. '_source',
  547. ],
  548. format: function (image) { return image.name; }
  549. },
  550. 'Line': {
  551. type: BABYLON.GUI.Line,
  552. properties: ['_lineWidth',
  553. '_background',
  554. '_x1',
  555. '_y1',
  556. '_x2',
  557. '_y2',
  558. ],
  559. format: function (line) { return line.name; }
  560. },
  561. 'RadioButton': {
  562. type: BABYLON.GUI.RadioButton,
  563. properties: ['_isChecked', '_background'],
  564. format: function (radioButton) { return radioButton.name; }
  565. },
  566. 'Rectangle': {
  567. type: BABYLON.GUI.Rectangle,
  568. properties: ['_thickness', '_cornerRadius'],
  569. format: function (rectangle) { return rectangle.name; }
  570. },
  571. 'Slider': {
  572. type: BABYLON.GUI.Slider,
  573. properties: [
  574. '_minimum',
  575. '_maximum',
  576. '_value',
  577. '_background',
  578. '_borderColor',
  579. ],
  580. format: function (slider) { return slider.name; }
  581. },
  582. 'StackPanel': {
  583. type: BABYLON.GUI.StackPanel,
  584. properties: ['_isVertical'],
  585. format: function (stackPanel) { return stackPanel.name; }
  586. },
  587. 'TextBlock': {
  588. type: BABYLON.GUI.TextBlock,
  589. properties: ['_text', '_textWrapping'],
  590. format: function (textBlock) { return textBlock.name; }
  591. },
  592. 'Container': {
  593. type: BABYLON.GUI.Container,
  594. properties: ['_background'],
  595. format: function (container) { return container.name; }
  596. },
  597. };
  598. for (var prop in PROPERTIES_GUI) {
  599. INSPECTOR.PROPERTIES[prop] = PROPERTIES_GUI[prop];
  600. }
  601. }
  602. INSPECTOR.loadGUIProperties = loadGUIProperties;
  603. })(INSPECTOR || (INSPECTOR = {}));
  604. //# sourceMappingURL=properties_gui.js.map
  605. var INSPECTOR;
  606. (function (INSPECTOR) {
  607. /**
  608. * Represents a html div element.
  609. * The div is built when an instance of BasicElement is created.
  610. */
  611. var BasicElement = /** @class */ (function () {
  612. function BasicElement() {
  613. this._div = INSPECTOR.Helpers.CreateDiv();
  614. }
  615. /**
  616. * Returns the div element
  617. */
  618. BasicElement.prototype.toHtml = function () {
  619. return this._div;
  620. };
  621. /**
  622. * Build the html element
  623. */
  624. BasicElement.prototype._build = function () { };
  625. ;
  626. /** Default dispose method if needed */
  627. BasicElement.prototype.dispose = function () { };
  628. ;
  629. return BasicElement;
  630. }());
  631. INSPECTOR.BasicElement = BasicElement;
  632. })(INSPECTOR || (INSPECTOR = {}));
  633. //# sourceMappingURL=BasicElement.js.map
  634. var INSPECTOR;
  635. (function (INSPECTOR) {
  636. var Adapter = /** @class */ (function () {
  637. function Adapter(obj) {
  638. this._obj = obj;
  639. }
  640. /** Returns true if the given object correspond to this */
  641. Adapter.prototype.correspondsTo = function (obj) {
  642. return obj === this._obj;
  643. };
  644. Object.defineProperty(Adapter.prototype, "name", {
  645. /** Returns the adapter unique name */
  646. get: function () {
  647. return Adapter._name;
  648. },
  649. enumerable: true,
  650. configurable: true
  651. });
  652. Object.defineProperty(Adapter.prototype, "object", {
  653. /**
  654. * Returns the actual object used for this adapter
  655. */
  656. get: function () {
  657. return this._obj;
  658. },
  659. enumerable: true,
  660. configurable: true
  661. });
  662. // a unique name for this adapter, to retrieve its own key in the local storage
  663. Adapter._name = BABYLON.Geometry.RandomId();
  664. return Adapter;
  665. }());
  666. INSPECTOR.Adapter = Adapter;
  667. })(INSPECTOR || (INSPECTOR = {}));
  668. //# sourceMappingURL=Adapter.js.map
  669. var __extends = (this && this.__extends) || (function () {
  670. var extendStatics = Object.setPrototypeOf ||
  671. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  672. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  673. return function (d, b) {
  674. extendStatics(d, b);
  675. function __() { this.constructor = d; }
  676. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  677. };
  678. })();
  679. var INSPECTOR;
  680. (function (INSPECTOR) {
  681. var CameraAdapter = /** @class */ (function (_super) {
  682. __extends(CameraAdapter, _super);
  683. function CameraAdapter(obj) {
  684. return _super.call(this, obj) || this;
  685. }
  686. /** Returns the name displayed in the tree */
  687. CameraAdapter.prototype.id = function () {
  688. var str = '';
  689. if (this._obj.name) {
  690. str = this._obj.name;
  691. } // otherwise nothing displayed
  692. return str;
  693. };
  694. /** Returns the type of this object - displayed in the tree */
  695. CameraAdapter.prototype.type = function () {
  696. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  697. };
  698. /** Returns the list of properties to be displayed for this adapter */
  699. CameraAdapter.prototype.getProperties = function () {
  700. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  701. };
  702. CameraAdapter.prototype.getTools = function () {
  703. var tools = [];
  704. tools.push(new INSPECTOR.CameraPOV(this));
  705. return tools;
  706. };
  707. // Set the point of view of the chosen camera
  708. CameraAdapter.prototype.setPOV = function () {
  709. this._obj.getScene().switchActiveCamera(this._obj);
  710. };
  711. // Return the name of the current active camera
  712. CameraAdapter.prototype.getCurrentActiveCamera = function () {
  713. var activeCamera = this._obj.getScene().activeCamera;
  714. if (activeCamera != null) {
  715. return activeCamera.name;
  716. }
  717. else {
  718. return "0";
  719. }
  720. };
  721. return CameraAdapter;
  722. }(INSPECTOR.Adapter));
  723. INSPECTOR.CameraAdapter = CameraAdapter;
  724. })(INSPECTOR || (INSPECTOR = {}));
  725. //# sourceMappingURL=CameraAdapter.js.map
  726. var __extends = (this && this.__extends) || (function () {
  727. var extendStatics = Object.setPrototypeOf ||
  728. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  729. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  730. return function (d, b) {
  731. extendStatics(d, b);
  732. function __() { this.constructor = d; }
  733. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  734. };
  735. })();
  736. var INSPECTOR;
  737. (function (INSPECTOR) {
  738. var PhysicsImpostorAdapter = /** @class */ (function (_super) {
  739. __extends(PhysicsImpostorAdapter, _super);
  740. function PhysicsImpostorAdapter(obj, viewer) {
  741. var _this = _super.call(this, obj) || this;
  742. _this._isVisible = false;
  743. _this._viewer = viewer;
  744. return _this;
  745. }
  746. /** Returns the name displayed in the tree */
  747. PhysicsImpostorAdapter.prototype.id = function () {
  748. var str = '';
  749. var physicsImposter = this._obj;
  750. if (physicsImposter && physicsImposter.object) {
  751. str = physicsImposter.object.name || "";
  752. } // otherwise nothing displayed
  753. return str;
  754. };
  755. /** Returns the type of this object - displayed in the tree */
  756. PhysicsImpostorAdapter.prototype.type = function () {
  757. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  758. };
  759. /** Returns the list of properties to be displayed for this adapter */
  760. PhysicsImpostorAdapter.prototype.getProperties = function () {
  761. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  762. };
  763. PhysicsImpostorAdapter.prototype.getTools = function () {
  764. var tools = [];
  765. tools.push(new INSPECTOR.Checkbox(this));
  766. return tools;
  767. };
  768. PhysicsImpostorAdapter.prototype.setVisible = function (b) {
  769. this._isVisible = b;
  770. if (b) {
  771. this._viewer.showImpostor(this._obj);
  772. }
  773. else {
  774. this._viewer.hideImpostor(this._obj);
  775. }
  776. };
  777. PhysicsImpostorAdapter.prototype.isVisible = function () {
  778. return this._isVisible;
  779. };
  780. return PhysicsImpostorAdapter;
  781. }(INSPECTOR.Adapter));
  782. INSPECTOR.PhysicsImpostorAdapter = PhysicsImpostorAdapter;
  783. })(INSPECTOR || (INSPECTOR = {}));
  784. //# sourceMappingURL=PhysicsImpostorAdapter.js.map
  785. var __extends = (this && this.__extends) || (function () {
  786. var extendStatics = Object.setPrototypeOf ||
  787. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  788. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  789. return function (d, b) {
  790. extendStatics(d, b);
  791. function __() { this.constructor = d; }
  792. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  793. };
  794. })();
  795. var INSPECTOR;
  796. (function (INSPECTOR) {
  797. var GUIAdapter = /** @class */ (function (_super) {
  798. __extends(GUIAdapter, _super);
  799. function GUIAdapter(obj) {
  800. return _super.call(this, obj) || this;
  801. }
  802. /** Returns the name displayed in the tree */
  803. GUIAdapter.prototype.id = function () {
  804. var str = '';
  805. if (this._obj.name) {
  806. str = this._obj.name;
  807. } // otherwise nothing displayed
  808. return str;
  809. };
  810. /** Returns the type of this object - displayed in the tree */
  811. GUIAdapter.prototype.type = function () {
  812. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  813. };
  814. /** Returns the list of properties to be displayed for this adapter */
  815. GUIAdapter.prototype.getProperties = function () {
  816. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  817. };
  818. GUIAdapter.prototype.getTools = function () {
  819. var tools = [];
  820. tools.push(new INSPECTOR.Checkbox(this));
  821. return tools;
  822. };
  823. GUIAdapter.prototype.setVisible = function (b) {
  824. this._obj.isVisible = b;
  825. };
  826. GUIAdapter.prototype.isVisible = function () {
  827. return this._obj.isVisible;
  828. };
  829. return GUIAdapter;
  830. }(INSPECTOR.Adapter));
  831. INSPECTOR.GUIAdapter = GUIAdapter;
  832. })(INSPECTOR || (INSPECTOR = {}));
  833. //# sourceMappingURL=GUIAdapter.js.map
  834. var __extends = (this && this.__extends) || (function () {
  835. var extendStatics = Object.setPrototypeOf ||
  836. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  837. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  838. return function (d, b) {
  839. extendStatics(d, b);
  840. function __() { this.constructor = d; }
  841. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  842. };
  843. })();
  844. var INSPECTOR;
  845. (function (INSPECTOR) {
  846. var SoundAdapter = /** @class */ (function (_super) {
  847. __extends(SoundAdapter, _super);
  848. function SoundAdapter(obj) {
  849. return _super.call(this, obj) || this;
  850. }
  851. /** Returns the name displayed in the tree */
  852. SoundAdapter.prototype.id = function () {
  853. var str = '';
  854. if (this._obj.name) {
  855. str = this._obj.name;
  856. } // otherwise nothing displayed
  857. return str;
  858. };
  859. /** Returns the type of this object - displayed in the tree */
  860. SoundAdapter.prototype.type = function () {
  861. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  862. };
  863. /** Returns the list of properties to be displayed for this adapter */
  864. SoundAdapter.prototype.getProperties = function () {
  865. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  866. };
  867. SoundAdapter.prototype.getTools = function () {
  868. var tools = [];
  869. tools.push(new INSPECTOR.SoundInteractions(this));
  870. return tools;
  871. };
  872. SoundAdapter.prototype.setPlaying = function (callback) {
  873. if (this._obj.isPlaying) {
  874. this._obj.pause();
  875. }
  876. else {
  877. this._obj.play();
  878. }
  879. this._obj.onended = function () {
  880. callback();
  881. };
  882. };
  883. return SoundAdapter;
  884. }(INSPECTOR.Adapter));
  885. INSPECTOR.SoundAdapter = SoundAdapter;
  886. })(INSPECTOR || (INSPECTOR = {}));
  887. //# sourceMappingURL=SoundAdapter.js.map
  888. var __extends = (this && this.__extends) || (function () {
  889. var extendStatics = Object.setPrototypeOf ||
  890. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  891. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  892. return function (d, b) {
  893. extendStatics(d, b);
  894. function __() { this.constructor = d; }
  895. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  896. };
  897. })();
  898. var INSPECTOR;
  899. (function (INSPECTOR) {
  900. var TextureAdapter = /** @class */ (function (_super) {
  901. __extends(TextureAdapter, _super);
  902. function TextureAdapter(obj) {
  903. return _super.call(this, obj) || this;
  904. }
  905. /** Returns the name displayed in the tree */
  906. TextureAdapter.prototype.id = function () {
  907. var str = '';
  908. if (this._obj.name) {
  909. str = this._obj.name;
  910. } // otherwise nothing displayed
  911. return str;
  912. };
  913. /** Returns the type of this object - displayed in the tree */
  914. TextureAdapter.prototype.type = function () {
  915. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  916. };
  917. /** Returns the list of properties to be displayed for this adapter */
  918. TextureAdapter.prototype.getProperties = function () {
  919. // Not used in this tab
  920. return [];
  921. };
  922. TextureAdapter.prototype.getTools = function () {
  923. var tools = new Array();
  924. // tools.push(new CameraPOV(this));
  925. return tools;
  926. };
  927. return TextureAdapter;
  928. }(INSPECTOR.Adapter));
  929. INSPECTOR.TextureAdapter = TextureAdapter;
  930. })(INSPECTOR || (INSPECTOR = {}));
  931. //# sourceMappingURL=TextureAdapter.js.map
  932. var __extends = (this && this.__extends) || (function () {
  933. var extendStatics = Object.setPrototypeOf ||
  934. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  935. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  936. return function (d, b) {
  937. extendStatics(d, b);
  938. function __() { this.constructor = d; }
  939. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  940. };
  941. })();
  942. var INSPECTOR;
  943. (function (INSPECTOR) {
  944. var LightAdapter = /** @class */ (function (_super) {
  945. __extends(LightAdapter, _super);
  946. function LightAdapter(obj) {
  947. return _super.call(this, obj) || this;
  948. }
  949. /** Returns the name displayed in the tree */
  950. LightAdapter.prototype.id = function () {
  951. var str = '';
  952. if (this._obj.name) {
  953. str = this._obj.name;
  954. } // otherwise nothing displayed
  955. return str;
  956. };
  957. /** Returns the type of this object - displayed in the tree */
  958. LightAdapter.prototype.type = function () {
  959. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  960. };
  961. /** Returns the list of properties to be displayed for this adapter */
  962. LightAdapter.prototype.getProperties = function () {
  963. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  964. };
  965. LightAdapter.prototype.getTools = function () {
  966. var tools = [];
  967. tools.push(new INSPECTOR.Checkbox(this));
  968. return tools;
  969. };
  970. LightAdapter.prototype.setVisible = function (b) {
  971. this._obj.setEnabled(b);
  972. };
  973. LightAdapter.prototype.isVisible = function () {
  974. return this._obj.isEnabled();
  975. };
  976. return LightAdapter;
  977. }(INSPECTOR.Adapter));
  978. INSPECTOR.LightAdapter = LightAdapter;
  979. })(INSPECTOR || (INSPECTOR = {}));
  980. //# sourceMappingURL=LightAdapter.js.map
  981. var __extends = (this && this.__extends) || (function () {
  982. var extendStatics = Object.setPrototypeOf ||
  983. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  984. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  985. return function (d, b) {
  986. extendStatics(d, b);
  987. function __() { this.constructor = d; }
  988. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  989. };
  990. })();
  991. var INSPECTOR;
  992. (function (INSPECTOR) {
  993. var MaterialAdapter = /** @class */ (function (_super) {
  994. __extends(MaterialAdapter, _super);
  995. function MaterialAdapter(obj) {
  996. return _super.call(this, obj) || this;
  997. }
  998. /** Returns the name displayed in the tree */
  999. MaterialAdapter.prototype.id = function () {
  1000. var str = '';
  1001. if (this._obj.name) {
  1002. str = this._obj.name;
  1003. } // otherwise nothing displayed
  1004. return str;
  1005. };
  1006. /** Returns the type of this object - displayed in the tree */
  1007. MaterialAdapter.prototype.type = function () {
  1008. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1009. };
  1010. /** Returns the list of properties to be displayed for this adapter */
  1011. MaterialAdapter.prototype.getProperties = function () {
  1012. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  1013. };
  1014. /** No tools for a material adapter */
  1015. MaterialAdapter.prototype.getTools = function () {
  1016. return [];
  1017. };
  1018. return MaterialAdapter;
  1019. }(INSPECTOR.Adapter));
  1020. INSPECTOR.MaterialAdapter = MaterialAdapter;
  1021. })(INSPECTOR || (INSPECTOR = {}));
  1022. //# sourceMappingURL=MaterialAdapter.js.map
  1023. var __extends = (this && this.__extends) || (function () {
  1024. var extendStatics = Object.setPrototypeOf ||
  1025. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1026. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1027. return function (d, b) {
  1028. extendStatics(d, b);
  1029. function __() { this.constructor = d; }
  1030. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1031. };
  1032. })();
  1033. var INSPECTOR;
  1034. (function (INSPECTOR) {
  1035. var MeshAdapter = /** @class */ (function (_super) {
  1036. __extends(MeshAdapter, _super);
  1037. function MeshAdapter(mesh) {
  1038. return _super.call(this, mesh) || this;
  1039. }
  1040. /** Returns the name displayed in the tree */
  1041. MeshAdapter.prototype.id = function () {
  1042. var str = '';
  1043. if (this._obj.name) {
  1044. str = this._obj.name;
  1045. } // otherwise nothing displayed
  1046. return str;
  1047. };
  1048. /** Returns the type of this object - displayed in the tree */
  1049. MeshAdapter.prototype.type = function () {
  1050. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1051. };
  1052. /** Returns the list of properties to be displayed for this adapter */
  1053. MeshAdapter.prototype.getProperties = function () {
  1054. return INSPECTOR.Helpers.GetAllLinesProperties(this._obj);
  1055. };
  1056. MeshAdapter.prototype.getTools = function () {
  1057. var tools = [];
  1058. tools.push(new INSPECTOR.Checkbox(this));
  1059. tools.push(new INSPECTOR.DebugArea(this));
  1060. if (this._obj instanceof BABYLON.AbstractMesh) {
  1061. if (this._obj.getTotalVertices() > 0) {
  1062. tools.push(new INSPECTOR.BoundingBox(this));
  1063. }
  1064. }
  1065. tools.push(new INSPECTOR.Info(this));
  1066. return tools;
  1067. };
  1068. MeshAdapter.prototype.setVisible = function (b) {
  1069. this._obj.setEnabled(b);
  1070. this._obj.isVisible = b;
  1071. };
  1072. MeshAdapter.prototype.isVisible = function () {
  1073. return this._obj.isEnabled() && (this._obj.isVisible === undefined || this._obj.isVisible);
  1074. };
  1075. MeshAdapter.prototype.isBoxVisible = function () {
  1076. return this._obj.showBoundingBox;
  1077. };
  1078. MeshAdapter.prototype.setBoxVisible = function (b) {
  1079. return this._obj.showBoundingBox = b;
  1080. };
  1081. MeshAdapter.prototype.debug = function (enable) {
  1082. // Draw axis the first time
  1083. if (!this._axesViewer) {
  1084. this._drawAxis();
  1085. }
  1086. // Display or hide axis
  1087. if (!enable && this._axesViewer) {
  1088. var mesh = this._obj;
  1089. mesh.getScene().onBeforeRenderObservable.remove(this.onBeforeRenderObserver);
  1090. this._axesViewer.dispose();
  1091. this._axesViewer = null;
  1092. }
  1093. };
  1094. /** Returns some information about this mesh */
  1095. MeshAdapter.prototype.getInfo = function () {
  1096. if (this._obj instanceof BABYLON.AbstractMesh) {
  1097. return this._obj.getTotalVertices() + " vertices";
  1098. }
  1099. return '0 vertices';
  1100. };
  1101. /** Draw X, Y and Z axis for the actual object if this adapter.
  1102. * Should be called only one time as it will fill this._axis
  1103. */
  1104. MeshAdapter.prototype._drawAxis = function () {
  1105. var _this = this;
  1106. this._obj.computeWorldMatrix();
  1107. // Axis
  1108. var x = new BABYLON.Vector3(1, 0, 0);
  1109. var y = new BABYLON.Vector3(0, 1, 0);
  1110. var z = new BABYLON.Vector3(0, 0, 1);
  1111. this._axesViewer = new BABYLON.Debug.AxesViewer(this._obj.getScene());
  1112. var mesh = this._obj;
  1113. this.onBeforeRenderObserver = mesh.getScene().onBeforeRenderObservable.add(function () {
  1114. var matrix = mesh.getWorldMatrix();
  1115. var extend = new BABYLON.Vector3(1, 1, 1);
  1116. if (mesh instanceof BABYLON.AbstractMesh) {
  1117. extend = mesh.getBoundingInfo().boundingBox.extendSizeWorld;
  1118. }
  1119. _this._axesViewer.scaleLines = Math.max(extend.x, extend.y, extend.z) * 2;
  1120. _this._axesViewer.update(_this._obj.position, BABYLON.Vector3.TransformNormal(x, matrix), BABYLON.Vector3.TransformNormal(y, matrix), BABYLON.Vector3.TransformNormal(z, matrix));
  1121. });
  1122. };
  1123. return MeshAdapter;
  1124. }(INSPECTOR.Adapter));
  1125. INSPECTOR.MeshAdapter = MeshAdapter;
  1126. })(INSPECTOR || (INSPECTOR = {}));
  1127. //# sourceMappingURL=MeshAdapter.js.map
  1128. var __extends = (this && this.__extends) || (function () {
  1129. var extendStatics = Object.setPrototypeOf ||
  1130. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1131. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1132. return function (d, b) {
  1133. extendStatics(d, b);
  1134. function __() { this.constructor = d; }
  1135. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1136. };
  1137. })();
  1138. var INSPECTOR;
  1139. (function (INSPECTOR) {
  1140. var DetailPanel = /** @class */ (function (_super) {
  1141. __extends(DetailPanel, _super);
  1142. function DetailPanel(dr) {
  1143. var _this = _super.call(this) || this;
  1144. // Contains all details rows that belongs to the item above
  1145. _this._detailRows = [];
  1146. // Store the sort direction of each header column
  1147. _this._sortDirection = {};
  1148. _this._build();
  1149. if (dr) {
  1150. _this._detailRows = dr;
  1151. _this.update();
  1152. }
  1153. return _this;
  1154. }
  1155. Object.defineProperty(DetailPanel.prototype, "details", {
  1156. set: function (detailsRow) {
  1157. this.clean();
  1158. //add the searchBar
  1159. this._addSearchBarDetails();
  1160. this._details = INSPECTOR.Helpers.CreateDiv('details', this._div);
  1161. this._detailRows = detailsRow;
  1162. // Refresh HTML
  1163. this.update();
  1164. },
  1165. enumerable: true,
  1166. configurable: true
  1167. });
  1168. DetailPanel.prototype._build = function () {
  1169. this._div.className = 'insp-details';
  1170. this._div.id = 'insp-details';
  1171. // Create header row
  1172. this._createHeaderRow();
  1173. this._div.appendChild(this._headerRow);
  1174. };
  1175. /** Updates the HTML of the detail panel */
  1176. DetailPanel.prototype.update = function (_items) {
  1177. this._sortDetails('name', 1);
  1178. // Check the searchbar
  1179. if (_items) {
  1180. this.cleanRow();
  1181. this._addSearchDetails(_items);
  1182. //console.log(_items);
  1183. }
  1184. else {
  1185. this._addDetails();
  1186. //console.log("np");
  1187. }
  1188. };
  1189. /** Add the search bar for the details */
  1190. DetailPanel.prototype._addSearchBarDetails = function () {
  1191. var searchDetails = INSPECTOR.Helpers.CreateDiv('searchbar-details', this._div);
  1192. // Create search bar
  1193. this._searchDetails = new INSPECTOR.SearchBarDetails(this);
  1194. searchDetails.appendChild(this._searchDetails.toHtml());
  1195. this._div.appendChild(searchDetails);
  1196. };
  1197. /** Search an element by name */
  1198. DetailPanel.prototype.searchByName = function (searchName) {
  1199. var rows = [];
  1200. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1201. var row = _a[_i];
  1202. if (row.name.indexOf(searchName) >= 0) {
  1203. rows.push(row);
  1204. }
  1205. }
  1206. this.update(rows);
  1207. };
  1208. /** Add all lines in the html div. Does not sort them! */
  1209. DetailPanel.prototype._addDetails = function () {
  1210. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1211. var row = _a[_i];
  1212. this._details.appendChild(row.toHtml());
  1213. }
  1214. };
  1215. DetailPanel.prototype._addSearchDetails = function (_items) {
  1216. for (var _i = 0, _items_1 = _items; _i < _items_1.length; _i++) {
  1217. var row = _items_1[_i];
  1218. this._details.appendChild(row.toHtml());
  1219. }
  1220. };
  1221. /**
  1222. * Sort the details row by comparing the given property of each row
  1223. */
  1224. DetailPanel.prototype._sortDetails = function (property, _direction) {
  1225. // Clean header
  1226. var elems = INSPECTOR.Inspector.DOCUMENT.querySelectorAll('.sort-direction');
  1227. for (var e = 0; e < elems.length; e++) {
  1228. elems[e].classList.remove('fa-chevron-up');
  1229. elems[e].classList.remove('fa-chevron-down');
  1230. }
  1231. if (_direction || !this._sortDirection[property]) {
  1232. this._sortDirection[property] = _direction || 1;
  1233. }
  1234. else {
  1235. this._sortDirection[property] *= -1;
  1236. }
  1237. var direction = this._sortDirection[property];
  1238. var query = this._headerRow.querySelector("#sort-direction-" + property);
  1239. if (query) {
  1240. if (direction == 1) {
  1241. query.classList.remove('fa-chevron-down');
  1242. query.classList.add('fa-chevron-up');
  1243. }
  1244. else {
  1245. query.classList.remove('fa-chevron-up');
  1246. query.classList.add('fa-chevron-down');
  1247. }
  1248. }
  1249. var isString = function (s) {
  1250. return typeof (s) === 'string' || s instanceof String;
  1251. };
  1252. this._detailRows.forEach(function (property) {
  1253. property.closeDetails();
  1254. });
  1255. this._detailRows.sort(function (detail1, detail2) {
  1256. var str1 = String(detail1[property]);
  1257. var str2 = String(detail2[property]);
  1258. if (!isString(str1)) {
  1259. str1 = detail1[property].toString();
  1260. }
  1261. if (!isString(str2)) {
  1262. str2 = detail2[property].toString();
  1263. }
  1264. // Compare numbers as numbers and string as string with 'numeric=true'
  1265. return str1.localeCompare(str2, [], { numeric: true }) * direction;
  1266. });
  1267. };
  1268. /**
  1269. * Removes all data in the detail panel but keep the header row
  1270. */
  1271. DetailPanel.prototype.clean = function () {
  1272. // Delete all details row
  1273. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1274. var pline = _a[_i];
  1275. pline.dispose();
  1276. }
  1277. INSPECTOR.Helpers.CleanDiv(this._div);
  1278. // Header row
  1279. this._div.appendChild(this._headerRow);
  1280. };
  1281. /**
  1282. * Clean the rows only
  1283. */
  1284. DetailPanel.prototype.cleanRow = function () {
  1285. // Delete all details row
  1286. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1287. var pline = _a[_i];
  1288. pline.dispose();
  1289. }
  1290. INSPECTOR.Helpers.CleanDiv(this._details);
  1291. };
  1292. /** Overrides basicelement.dispose */
  1293. DetailPanel.prototype.dispose = function () {
  1294. // Delete all details row
  1295. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1296. var pline = _a[_i];
  1297. pline.dispose();
  1298. }
  1299. };
  1300. /**
  1301. * Creates the header row : name, value, id
  1302. */
  1303. DetailPanel.prototype._createHeaderRow = function () {
  1304. var _this = this;
  1305. this._headerRow = INSPECTOR.Helpers.CreateDiv('header-row');
  1306. var createDiv = function (name, cssClass) {
  1307. var div = INSPECTOR.Helpers.CreateDiv(cssClass + ' header-col');
  1308. // Column title - first letter in uppercase
  1309. var spanName = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  1310. spanName.textContent = name.charAt(0).toUpperCase() + name.slice(1);
  1311. // sort direction
  1312. var spanDirection = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  1313. spanDirection.className = 'sort-direction fa';
  1314. spanDirection.id = 'sort-direction-' + name;
  1315. div.appendChild(spanName);
  1316. div.appendChild(spanDirection);
  1317. div.addEventListener('click', function (e) {
  1318. _this._sortDetails(name);
  1319. _this._addDetails();
  1320. });
  1321. return div;
  1322. };
  1323. this._headerRow.appendChild(createDiv('name', 'prop-name'));
  1324. this._headerRow.appendChild(createDiv('value', 'prop-value'));
  1325. };
  1326. return DetailPanel;
  1327. }(INSPECTOR.BasicElement));
  1328. INSPECTOR.DetailPanel = DetailPanel;
  1329. })(INSPECTOR || (INSPECTOR = {}));
  1330. //# sourceMappingURL=DetailPanel.js.map
  1331. var INSPECTOR;
  1332. (function (INSPECTOR) {
  1333. /**
  1334. * A property is a link between a data (string) and an object.
  1335. */
  1336. var Property = /** @class */ (function () {
  1337. function Property(prop, obj, parentObj) {
  1338. this._property = prop;
  1339. this._obj = obj;
  1340. this._parentObj = parentObj || null;
  1341. }
  1342. Object.defineProperty(Property.prototype, "name", {
  1343. get: function () {
  1344. return this._property;
  1345. },
  1346. enumerable: true,
  1347. configurable: true
  1348. });
  1349. Object.defineProperty(Property.prototype, "value", {
  1350. get: function () {
  1351. return this._obj[this._property];
  1352. },
  1353. set: function (newValue) {
  1354. if (newValue != undefined && this._obj[this._property] != undefined) {
  1355. if (this._obj instanceof BABYLON.Scene) {
  1356. this._obj.debugLayer.onPropertyChangedObservable.notifyObservers({
  1357. object: this._obj,
  1358. property: this._property,
  1359. value: newValue,
  1360. initialValue: this._obj[this._property]
  1361. });
  1362. }
  1363. else {
  1364. if (this._parentObj != null) {
  1365. // Object that have "children" properties : Color, Vector, imageProcessingConfiguration
  1366. if (this._parentObj instanceof BABYLON.Scene) {
  1367. this._parentObj.debugLayer.onPropertyChangedObservable.notifyObservers({
  1368. object: this._parentObj,
  1369. property: this._property,
  1370. value: newValue,
  1371. initialValue: this._obj[this._property]
  1372. });
  1373. }
  1374. else {
  1375. this._parentObj.getScene().debugLayer.onPropertyChangedObservable.notifyObservers({
  1376. object: this._parentObj,
  1377. property: this._property,
  1378. value: newValue,
  1379. initialValue: this._obj[this._property]
  1380. });
  1381. }
  1382. }
  1383. else {
  1384. this._obj.getScene().debugLayer.onPropertyChangedObservable.notifyObservers({
  1385. object: this._obj,
  1386. property: this._property,
  1387. value: newValue,
  1388. initialValue: this._obj[this._property]
  1389. });
  1390. }
  1391. }
  1392. }
  1393. this._obj[this._property] = newValue;
  1394. },
  1395. enumerable: true,
  1396. configurable: true
  1397. });
  1398. Object.defineProperty(Property.prototype, "type", {
  1399. get: function () {
  1400. return INSPECTOR.Helpers.GET_TYPE(this.value);
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. Object.defineProperty(Property.prototype, "obj", {
  1406. get: function () {
  1407. return this._obj;
  1408. },
  1409. set: function (newObj) {
  1410. this._obj = newObj;
  1411. },
  1412. enumerable: true,
  1413. configurable: true
  1414. });
  1415. return Property;
  1416. }());
  1417. INSPECTOR.Property = Property;
  1418. })(INSPECTOR || (INSPECTOR = {}));
  1419. //# sourceMappingURL=Property.js.map
  1420. var INSPECTOR;
  1421. (function (INSPECTOR) {
  1422. var PropertyFormatter = /** @class */ (function () {
  1423. function PropertyFormatter() {
  1424. }
  1425. /**
  1426. * Format the value of the given property of the given object.
  1427. */
  1428. PropertyFormatter.format = function (obj, prop) {
  1429. // Get original value;
  1430. var value = obj[prop];
  1431. // test if type PrimitiveAlignment is available (only included in canvas2d)
  1432. return value;
  1433. };
  1434. return PropertyFormatter;
  1435. }());
  1436. INSPECTOR.PropertyFormatter = PropertyFormatter;
  1437. /**
  1438. * A property line represents a line in the detail panel. This line is composed of :
  1439. * - a name (the property name)
  1440. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  1441. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  1442. * - a ID if defined (otherwise an empty string is displayed)
  1443. * The original object is sent to the value object who will update it at will.
  1444. *
  1445. * A property line can contain OTHER property line objects in the case of a complex type.
  1446. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  1447. *
  1448. */
  1449. var PropertyLine = /** @class */ (function () {
  1450. function PropertyLine(prop, parent, level) {
  1451. if (parent === void 0) { parent = null; }
  1452. if (level === void 0) { level = 0; }
  1453. // If the type is complex, this property will have child to update
  1454. this._children = [];
  1455. /** The list of viewer element displayed at the end of the line (color, texture...) */
  1456. this._elements = [];
  1457. this._property = prop;
  1458. this._level = level;
  1459. this._parent = parent;
  1460. this._div = INSPECTOR.Helpers.CreateDiv('row');
  1461. this._div.style.marginLeft = this._level + "px";
  1462. // Property name
  1463. var propName = INSPECTOR.Helpers.CreateDiv('prop-name', this._div);
  1464. propName.textContent = "" + this.name;
  1465. // Value
  1466. this._valueDiv = INSPECTOR.Helpers.CreateDiv('prop-value', this._div);
  1467. if (typeof this.value !== 'boolean' && !this._isSliderType()) {
  1468. this._valueDiv.textContent = this._displayValueContent() || '-'; // Init value text node
  1469. }
  1470. this._createElements();
  1471. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1472. var elem = _a[_i];
  1473. this._valueDiv.appendChild(elem.toHtml());
  1474. }
  1475. this._updateValue();
  1476. // If the property type is not simple, add click event to unfold its children
  1477. if (typeof this.value === 'boolean') {
  1478. this._checkboxInput();
  1479. }
  1480. else if (this._isSliderType()) {
  1481. this._rangeInput();
  1482. }
  1483. else if (!this._isSimple()) {
  1484. this._valueDiv.classList.add('clickable');
  1485. this._valueDiv.addEventListener('click', this._addDetails.bind(this));
  1486. }
  1487. else {
  1488. this._initInput();
  1489. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1490. this._input.addEventListener('focusout', this._focusOutInputHandler);
  1491. this._input.addEventListener('keydown', this._validateInputHandler);
  1492. this._input.addEventListener('keydown', this._escapeInputHandler);
  1493. }
  1494. // Add this property to the scheduler
  1495. INSPECTOR.Scheduler.getInstance().add(this);
  1496. }
  1497. /**
  1498. * Init the input element and al its handler :
  1499. * - a click in the window remove the input and restore the old property value
  1500. * - enters updates the property
  1501. */
  1502. PropertyLine.prototype._initInput = function () {
  1503. // Create the input element
  1504. this._input = document.createElement('input');
  1505. this._input.setAttribute('type', 'text');
  1506. // if the property is 'simple', add an event listener to create an input
  1507. this._displayInputHandler = this._displayInput.bind(this);
  1508. this._validateInputHandler = this._validateInput.bind(this);
  1509. this._escapeInputHandler = this._escapeInput.bind(this);
  1510. this._focusOutInputHandler = this.update.bind(this);
  1511. this._onMouseDownHandler = this._onMouseDown.bind(this);
  1512. this._onMouseDragHandler = this._onMouseDrag.bind(this);
  1513. this._onMouseUpHandler = this._onMouseUp.bind(this);
  1514. };
  1515. /**
  1516. * On enter : validates the new value and removes the input
  1517. * On escape : removes the input
  1518. */
  1519. PropertyLine.prototype._validateInput = function (e) {
  1520. this._input.removeEventListener('focusout', this._focusOutInputHandler);
  1521. if (e.keyCode == 13) { // Enter
  1522. this.validateInput(this._input.value);
  1523. }
  1524. else if (e.keyCode == 9) { // Tab
  1525. e.preventDefault();
  1526. this.validateInput(this._input.value);
  1527. }
  1528. else if (e.keyCode == 27) { // Esc : remove input
  1529. this.update();
  1530. }
  1531. };
  1532. PropertyLine.prototype.validateInput = function (value, forceupdate) {
  1533. if (forceupdate === void 0) { forceupdate = true; }
  1534. this.updateObject();
  1535. if (typeof this._property.value === 'number') {
  1536. this._property.value = parseFloat(value);
  1537. }
  1538. else {
  1539. this._property.value = value;
  1540. }
  1541. // Remove input
  1542. if (forceupdate) {
  1543. this.update();
  1544. // resume scheduler
  1545. INSPECTOR.Scheduler.getInstance().pause = false;
  1546. }
  1547. };
  1548. /**
  1549. * On escape : removes the input
  1550. */
  1551. PropertyLine.prototype._escapeInput = function (e) {
  1552. // Remove focus out handler
  1553. this._input.removeEventListener('focusout', this._focusOutInputHandler);
  1554. if (e.keyCode == 27) {
  1555. // Esc : remove input
  1556. this.update();
  1557. }
  1558. };
  1559. /** Removes the input without validating the new value */
  1560. PropertyLine.prototype._removeInputWithoutValidating = function () {
  1561. INSPECTOR.Helpers.CleanDiv(this._valueDiv);
  1562. if (typeof this.value !== 'boolean' && !this._isSliderType()) {
  1563. this._valueDiv.textContent = "-";
  1564. }
  1565. // restore elements
  1566. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1567. var elem = _a[_i];
  1568. this._valueDiv.appendChild(elem.toHtml());
  1569. }
  1570. if (typeof this.value !== 'boolean' && !this._isSliderType()) {
  1571. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1572. }
  1573. };
  1574. /** Replaces the default display with an input */
  1575. PropertyLine.prototype._displayInput = function (e) {
  1576. // Remove the displayInput event listener
  1577. this._valueDiv.removeEventListener('click', this._displayInputHandler);
  1578. // Set input value
  1579. var valueTxt = this._valueDiv.textContent;
  1580. this._valueDiv.textContent = "";
  1581. this._input.value = valueTxt || "";
  1582. this._valueDiv.appendChild(this._input);
  1583. this._input.focus();
  1584. if (typeof this.value !== 'boolean' && !this._isSliderType()) {
  1585. this._input.addEventListener('focusout', this._focusOutInputHandler);
  1586. }
  1587. else if (typeof this.value === 'number') {
  1588. this._input.addEventListener('mousedown', this._onMouseDownHandler);
  1589. }
  1590. // Pause the scheduler
  1591. INSPECTOR.Scheduler.getInstance().pause = true;
  1592. };
  1593. /** Retrieve the correct object from its parent.
  1594. * If no parent exists, returns the property value.
  1595. * This method is used at each update in case the property object is removed from the original object
  1596. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  1597. */
  1598. PropertyLine.prototype.updateObject = function () {
  1599. if (this._parent) {
  1600. this._property.obj = this._parent.updateObject();
  1601. }
  1602. return this._property.value;
  1603. };
  1604. Object.defineProperty(PropertyLine.prototype, "name", {
  1605. // Returns the property name
  1606. get: function () {
  1607. // let arrayName = Helpers.Capitalize(this._property.name).match(/[A-Z][a-z]+|[0-9]+/g)
  1608. // if (arrayName) {
  1609. // return arrayName.join(" ");
  1610. // }
  1611. return this._property.name;
  1612. },
  1613. enumerable: true,
  1614. configurable: true
  1615. });
  1616. Object.defineProperty(PropertyLine.prototype, "value", {
  1617. // Returns the value of the property
  1618. get: function () {
  1619. return PropertyFormatter.format(this._property.obj, this._property.name);
  1620. },
  1621. enumerable: true,
  1622. configurable: true
  1623. });
  1624. Object.defineProperty(PropertyLine.prototype, "type", {
  1625. // Returns the type of the property
  1626. get: function () {
  1627. return this._property.type;
  1628. },
  1629. enumerable: true,
  1630. configurable: true
  1631. });
  1632. /**
  1633. * Creates elements that wil be displayed on a property line, depending on the
  1634. * type of the property.
  1635. */
  1636. PropertyLine.prototype._createElements = function () {
  1637. // Colors
  1638. if (this.type == 'Color3' || this.type == 'Color4') {
  1639. if (!INSPECTOR.Helpers.IsBrowserIE()) {
  1640. this._elements.push(new INSPECTOR.ColorPickerElement(this.value, this));
  1641. }
  1642. }
  1643. // Texture
  1644. if (this.type == 'Texture') {
  1645. this._elements.push(new INSPECTOR.TextureElement(this.value));
  1646. }
  1647. // HDR Texture
  1648. if (this.type == 'HDRCubeTexture') {
  1649. this._elements.push(new INSPECTOR.HDRCubeTextureElement(this.value));
  1650. }
  1651. if (this.type == 'CubeTexture') {
  1652. this._elements.push(new INSPECTOR.CubeTextureElement(this.value));
  1653. }
  1654. };
  1655. // Returns the text displayed on the left of the property name :
  1656. // - If the type is simple, display its value
  1657. // - If the type is complex, but instance of Vector2, Size, display the type and its tostring
  1658. // - If the type is another one, display the Type
  1659. PropertyLine.prototype._displayValueContent = function () {
  1660. var value = this.value;
  1661. // If the value is a number, truncate it if needed
  1662. if (typeof value === 'number') {
  1663. return INSPECTOR.Helpers.Trunc(value);
  1664. }
  1665. // If it's a string or a boolean, display its value
  1666. if (typeof value === 'string' || typeof value === 'boolean') {
  1667. return value;
  1668. }
  1669. return INSPECTOR.PROPERTIES.format(value);
  1670. };
  1671. /** Delete properly this property line.
  1672. * Removes itself from the scheduler.
  1673. * Dispose all viewer element (color, texture...)
  1674. */
  1675. PropertyLine.prototype.dispose = function () {
  1676. INSPECTOR.Scheduler.getInstance().remove(this);
  1677. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1678. var child = _a[_i];
  1679. INSPECTOR.Scheduler.getInstance().remove(child);
  1680. }
  1681. for (var _b = 0, _c = this._elements; _b < _c.length; _b++) {
  1682. var elem = _c[_b];
  1683. elem.dispose();
  1684. }
  1685. this._elements = [];
  1686. };
  1687. /** Updates the content of _valueDiv with the value of the property,
  1688. * and all HTML element correpsonding to this type.
  1689. * Elements are updated as well
  1690. */
  1691. PropertyLine.prototype._updateValue = function () {
  1692. // Update the property object first
  1693. this.updateObject();
  1694. // Then update its value
  1695. // this._valueDiv.textContent = " "; // TOFIX this removes the elements after
  1696. if (typeof this.value === 'boolean') {
  1697. this._checkboxInput();
  1698. }
  1699. else if (this._isSliderType()) { // Add slider when parent have slider property
  1700. this._rangeInput();
  1701. }
  1702. else {
  1703. this._valueDiv.childNodes[0].nodeValue = this._displayValueContent();
  1704. //Doing the Hexa convertion
  1705. if ((this._property.type == "Color3" && this._children.length == 5 && this._children[1].value == true) || (this._property.type == "Color4" && this._children.length == 6 && this._children[1].value == true)) {
  1706. if (this._children[0] != undefined && this._children[0].name == "hex") {
  1707. var hexLineString = this._children[0].value;
  1708. var rValue = (parseInt((hexLineString.slice(1, 3)), 16)) * (1 / 255);
  1709. var rValueRound = Math.round(100 * rValue) / 100;
  1710. this.value.r = rValueRound;
  1711. var gValue = (parseInt((hexLineString.slice(3, 5)), 16)) * (1 / 255);
  1712. var gValueRound = Math.round(100 * gValue) / 100;
  1713. this.value.g = gValueRound;
  1714. var bValue = (parseInt((hexLineString.slice(5, 7)), 16)) * (1 / 255);
  1715. var bValueRound = Math.round(100 * bValue) / 100;
  1716. this.value.b = bValueRound;
  1717. if (this._children[2].name == "a") {
  1718. var aValue = (parseInt((hexLineString.slice(7, 9)), 16)) * (1 / 255);
  1719. var aValueRound = Math.round(100 * aValue) / 100;
  1720. this.value.a = aValueRound;
  1721. }
  1722. }
  1723. }
  1724. else if (this._property.type == "Color3" || this._property.type == "Color4") {
  1725. if (this._property.value.hex != undefined && this._property.value.hex != null) {
  1726. var hexLineInfos = [];
  1727. var valHexR = ((this._property.value.r * 255) | 0).toString(16);
  1728. hexLineInfos.push(valHexR);
  1729. if (valHexR == "0") {
  1730. hexLineInfos.push("0");
  1731. }
  1732. var valHexG = ((this._property.value.g * 255) | 0).toString(16);
  1733. hexLineInfos.push(valHexG);
  1734. if (valHexG == "0") {
  1735. hexLineInfos.push("0");
  1736. }
  1737. var valHexB = ((this._property.value.b * 255) | 0).toString(16);
  1738. hexLineInfos.push(valHexB);
  1739. if (valHexB == "0") {
  1740. hexLineInfos.push("0");
  1741. }
  1742. if (this._property.value.a != undefined) {
  1743. var valHexA = ((this._property.value.a * 255) | 0).toString(16);
  1744. hexLineInfos.push(valHexA);
  1745. if (valHexA == "0") {
  1746. hexLineInfos.push("0");
  1747. }
  1748. }
  1749. hexLineInfos.unshift("#");
  1750. var hexLineString = hexLineInfos.join("");
  1751. this._property.value.hex = hexLineString;
  1752. hexLineInfos.length = 0;
  1753. }
  1754. }
  1755. }
  1756. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1757. var elem = _a[_i];
  1758. elem.update(this.value);
  1759. }
  1760. };
  1761. /**
  1762. * Update the property division with the new property value.
  1763. * If this property is complex, update its child, otherwise update its text content
  1764. */
  1765. PropertyLine.prototype.update = function () {
  1766. this._removeInputWithoutValidating();
  1767. this._updateValue();
  1768. };
  1769. /**
  1770. * Returns true if the type of this property is simple, false otherwise.
  1771. * Returns true if the value is null
  1772. */
  1773. PropertyLine.prototype._isSimple = function () {
  1774. if (this.value != null && this.type !== 'type_not_defined') {
  1775. if (PropertyLine._SIMPLE_TYPE.indexOf(this.type) == -1) {
  1776. // complex type : return the type name
  1777. return false;
  1778. }
  1779. else {
  1780. // simple type : return value
  1781. return true;
  1782. }
  1783. }
  1784. else {
  1785. return true;
  1786. }
  1787. };
  1788. PropertyLine.prototype.toHtml = function () {
  1789. return this._div;
  1790. };
  1791. PropertyLine.prototype.closeDetails = function () {
  1792. if (this._div.classList.contains('unfolded')) {
  1793. // Remove class unfolded
  1794. this._div.classList.remove('unfolded');
  1795. // remove html children
  1796. if (this._div.parentNode) {
  1797. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1798. var child = _a[_i];
  1799. this._div.parentNode.removeChild(child.toHtml());
  1800. }
  1801. }
  1802. }
  1803. };
  1804. /**
  1805. * Add sub properties in case of a complex type
  1806. */
  1807. PropertyLine.prototype._addDetails = function () {
  1808. if (this._div.classList.contains('unfolded')) {
  1809. // Remove class unfolded
  1810. this._div.classList.remove('unfolded');
  1811. // remove html children
  1812. if (this._div.parentNode) {
  1813. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1814. var child = _a[_i];
  1815. this._div.parentNode.removeChild(child.toHtml());
  1816. }
  1817. }
  1818. }
  1819. else {
  1820. // if children does not exists, generate it
  1821. this._div.classList.toggle('unfolded');
  1822. if (this._children.length == 0) {
  1823. var objToDetail = this.value;
  1824. // Display all properties that are not functions
  1825. var propToDisplay = INSPECTOR.Helpers.GetAllLinesPropertiesAsString(objToDetail);
  1826. // special case for color3
  1827. if ((propToDisplay.indexOf('r') && propToDisplay.indexOf('g') && propToDisplay.indexOf('b')) == 0) {
  1828. propToDisplay.sort();
  1829. }
  1830. else {
  1831. propToDisplay.sort().reverse();
  1832. }
  1833. for (var _b = 0, propToDisplay_1 = propToDisplay; _b < propToDisplay_1.length; _b++) {
  1834. var prop = propToDisplay_1[_b];
  1835. var infos = new INSPECTOR.Property(prop, this._property.value, this._property.obj);
  1836. var child = new PropertyLine(infos, this, this._level + PropertyLine._MARGIN_LEFT);
  1837. this._children.push(child);
  1838. }
  1839. //Add the Hexa converter
  1840. if ((propToDisplay.indexOf('r') && propToDisplay.indexOf('g') && propToDisplay.indexOf('b') && propToDisplay.indexOf('a')) == 0) {
  1841. var hexLineInfos = [];
  1842. var hexLinePropCheck = new INSPECTOR.Property("hexEnable", this._property.value, this._property.obj);
  1843. hexLinePropCheck.value = false;
  1844. var hexLineCheck = new PropertyLine(hexLinePropCheck, this, this._level + PropertyLine._MARGIN_LEFT);
  1845. this._children.unshift(hexLineCheck);
  1846. for (var _c = 0, propToDisplay_2 = propToDisplay; _c < propToDisplay_2.length; _c++) {
  1847. var prop = propToDisplay_2[_c];
  1848. var infos = new INSPECTOR.Property(prop, this._property.value, this._property.obj);
  1849. var valHex = ((infos.value * 255) | 0).toString(16);
  1850. hexLineInfos.push(valHex);
  1851. if (valHex == "0") {
  1852. hexLineInfos.push("0");
  1853. }
  1854. }
  1855. hexLineInfos.push("#");
  1856. hexLineInfos.reverse();
  1857. var hexLineString = hexLineInfos.join("");
  1858. var hexLineProp = new INSPECTOR.Property("hex", this._property.value, this._property.obj);
  1859. hexLineProp.value = hexLineString;
  1860. var hexLine = new PropertyLine(hexLineProp, this, this._level + PropertyLine._MARGIN_LEFT);
  1861. this._children.unshift(hexLine);
  1862. }
  1863. }
  1864. // otherwise display it
  1865. if (this._div.parentNode) {
  1866. for (var _d = 0, _e = this._children; _d < _e.length; _d++) {
  1867. var child = _e[_d];
  1868. this._div.parentNode.insertBefore(child.toHtml(), this._div.nextSibling);
  1869. }
  1870. }
  1871. }
  1872. };
  1873. /**
  1874. * Refresh mouse position on y axis
  1875. * @param e
  1876. */
  1877. PropertyLine.prototype._onMouseDrag = function (e) {
  1878. var diff = this._prevY - e.clientY;
  1879. this._input.value = (this._preValue + diff).toString();
  1880. };
  1881. /**
  1882. * Save new value from slider
  1883. * @param e
  1884. */
  1885. PropertyLine.prototype._onMouseUp = function (e) {
  1886. window.removeEventListener('mousemove', this._onMouseDragHandler);
  1887. window.removeEventListener('mouseup', this._onMouseUpHandler);
  1888. this._prevY = e.clientY;
  1889. };
  1890. /**
  1891. * Start record mouse position
  1892. * @param e
  1893. */
  1894. PropertyLine.prototype._onMouseDown = function (e) {
  1895. this._prevY = e.clientY;
  1896. this._preValue = this.value;
  1897. window.addEventListener('mousemove', this._onMouseDragHandler);
  1898. window.addEventListener('mouseup', this._onMouseUpHandler);
  1899. };
  1900. /**
  1901. * Create input entry
  1902. */
  1903. PropertyLine.prototype._checkboxInput = function () {
  1904. var _this = this;
  1905. if (this._valueDiv.childElementCount < 1) { // Prevent display two checkbox
  1906. this._input = INSPECTOR.Helpers.CreateInput('checkbox-element', this._valueDiv);
  1907. this._input.type = 'checkbox';
  1908. this._input.checked = this.value;
  1909. this._input.addEventListener('change', function () {
  1910. INSPECTOR.Scheduler.getInstance().pause = true;
  1911. _this.validateInput(!_this.value);
  1912. });
  1913. }
  1914. };
  1915. PropertyLine.prototype._rangeInput = function () {
  1916. if (this._valueDiv.childElementCount < 1) { // Prevent display two input range
  1917. this._input = INSPECTOR.Helpers.CreateInput('slider-element', this._valueDiv);
  1918. this._input.type = 'range';
  1919. this._input.style.display = 'inline-block';
  1920. this._input.min = this._getSliderProperty().min;
  1921. this._input.max = this._getSliderProperty().max;
  1922. this._input.step = this._getSliderProperty().step;
  1923. this._input.value = this.value;
  1924. this._validateInputHandler = this._rangeHandler.bind(this);
  1925. this._input.addEventListener('input', this._validateInputHandler);
  1926. this._input.addEventListener('change', function () {
  1927. INSPECTOR.Scheduler.getInstance().pause = false;
  1928. });
  1929. this._textValue = INSPECTOR.Helpers.CreateDiv('value-text', this._valueDiv);
  1930. this._textValue.innerText = INSPECTOR.Helpers.Trunc(this.value).toString();
  1931. this._textValue.style.paddingLeft = '10px';
  1932. this._textValue.style.display = 'inline-block';
  1933. }
  1934. };
  1935. PropertyLine.prototype._rangeHandler = function () {
  1936. INSPECTOR.Scheduler.getInstance().pause = true;
  1937. //this._input.style.backgroundSize = ((parseFloat(this._input.value) - parseFloat(this._input.min)) * 100 / ( parseFloat(this._input.max) - parseFloat(this._input.min))) + '% 100%'
  1938. this._textValue.innerText = this._input.value;
  1939. this.validateInput(this._input.value, false);
  1940. };
  1941. PropertyLine.prototype._isSliderType = function () {
  1942. return this._property &&
  1943. INSPECTOR.PROPERTIES.hasOwnProperty(this._property.obj.constructor.name) &&
  1944. INSPECTOR.PROPERTIES[this._property.obj.constructor.name].hasOwnProperty('slider') &&
  1945. INSPECTOR.PROPERTIES[this._property.obj.constructor.name].slider.hasOwnProperty(this.name);
  1946. };
  1947. PropertyLine.prototype._getSliderProperty = function () {
  1948. return INSPECTOR.PROPERTIES[this._property.obj.constructor.name].slider[this.name];
  1949. };
  1950. // Array representing the simple type. All others are considered 'complex'
  1951. PropertyLine._SIMPLE_TYPE = ['number', 'string', 'boolean'];
  1952. // The number of pixel at each children step
  1953. PropertyLine._MARGIN_LEFT = 15;
  1954. return PropertyLine;
  1955. }());
  1956. INSPECTOR.PropertyLine = PropertyLine;
  1957. })(INSPECTOR || (INSPECTOR = {}));
  1958. //# sourceMappingURL=PropertyLine.js.map
  1959. var __extends = (this && this.__extends) || (function () {
  1960. var extendStatics = Object.setPrototypeOf ||
  1961. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1962. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1963. return function (d, b) {
  1964. extendStatics(d, b);
  1965. function __() { this.constructor = d; }
  1966. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1967. };
  1968. })();
  1969. var INSPECTOR;
  1970. (function (INSPECTOR) {
  1971. /**
  1972. * Display a very small div corresponding to the given color
  1973. */
  1974. var ColorElement = /** @class */ (function (_super) {
  1975. __extends(ColorElement, _super);
  1976. // The color as hexadecimal string
  1977. function ColorElement(color) {
  1978. var _this = _super.call(this) || this;
  1979. _this._div.className = 'color-element';
  1980. _this._div.style.backgroundColor = _this._toRgba(color);
  1981. return _this;
  1982. }
  1983. ColorElement.prototype.update = function (color) {
  1984. if (color) {
  1985. this._div.style.backgroundColor = this._toRgba(color);
  1986. }
  1987. };
  1988. ColorElement.prototype._toRgba = function (color) {
  1989. if (color) {
  1990. var r = (color.r * 255) | 0;
  1991. var g = (color.g * 255) | 0;
  1992. var b = (color.b * 255) | 0;
  1993. var a = 1;
  1994. if (color instanceof BABYLON.Color4) {
  1995. a = color.a;
  1996. }
  1997. return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
  1998. }
  1999. else {
  2000. return '';
  2001. }
  2002. };
  2003. return ColorElement;
  2004. }(INSPECTOR.BasicElement));
  2005. INSPECTOR.ColorElement = ColorElement;
  2006. })(INSPECTOR || (INSPECTOR = {}));
  2007. var __extends = (this && this.__extends) || (function () {
  2008. var extendStatics = Object.setPrototypeOf ||
  2009. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2010. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2011. return function (d, b) {
  2012. extendStatics(d, b);
  2013. function __() { this.constructor = d; }
  2014. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2015. };
  2016. })();
  2017. var INSPECTOR;
  2018. (function (INSPECTOR) {
  2019. /**
  2020. * Represents a html div element.
  2021. * The div is built when an instance of BasicElement is created.
  2022. */
  2023. var ColorPickerElement = /** @class */ (function (_super) {
  2024. __extends(ColorPickerElement, _super);
  2025. function ColorPickerElement(color, propertyLine) {
  2026. var _this = _super.call(this) || this;
  2027. var scheduler = INSPECTOR.Scheduler.getInstance();
  2028. _this._div.className = 'color-element';
  2029. _this._div.style.backgroundColor = _this._toRgba(color);
  2030. _this.pline = propertyLine;
  2031. _this._input = INSPECTOR.Helpers.CreateInput();
  2032. _this._input.type = 'color';
  2033. _this._input.style.opacity = "0";
  2034. _this._input.style.width = '10px';
  2035. _this._input.style.height = '15px';
  2036. _this._input.value = color.toHexString();
  2037. _this._input.addEventListener('input', function (e) {
  2038. var color = BABYLON.Color3.FromHexString(_this._input.value);
  2039. color.r = parseFloat(color.r.toPrecision(2));
  2040. color.g = parseFloat(color.g.toPrecision(2));
  2041. color.b = parseFloat(color.b.toPrecision(2));
  2042. _this.pline.validateInput(color);
  2043. scheduler.pause = false;
  2044. });
  2045. _this._div.appendChild(_this._input);
  2046. _this._input.addEventListener('click', function (e) {
  2047. scheduler.pause = true;
  2048. });
  2049. return _this;
  2050. }
  2051. ColorPickerElement.prototype.update = function (color) {
  2052. if (color) {
  2053. this._div.style.backgroundColor = this._toRgba(color);
  2054. this._input.value = color.toHexString();
  2055. }
  2056. };
  2057. ColorPickerElement.prototype._toRgba = function (color) {
  2058. if (color) {
  2059. var r = (color.r * 255) | 0;
  2060. var g = (color.g * 255) | 0;
  2061. var b = (color.b * 255) | 0;
  2062. var a = 1;
  2063. if (color instanceof BABYLON.Color4) {
  2064. a = color.a;
  2065. }
  2066. return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
  2067. }
  2068. else {
  2069. return '';
  2070. }
  2071. };
  2072. return ColorPickerElement;
  2073. }(INSPECTOR.BasicElement));
  2074. INSPECTOR.ColorPickerElement = ColorPickerElement;
  2075. })(INSPECTOR || (INSPECTOR = {}));
  2076. var __extends = (this && this.__extends) || (function () {
  2077. var extendStatics = Object.setPrototypeOf ||
  2078. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2079. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2080. return function (d, b) {
  2081. extendStatics(d, b);
  2082. function __() { this.constructor = d; }
  2083. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2084. };
  2085. })();
  2086. var INSPECTOR;
  2087. (function (INSPECTOR) {
  2088. /**
  2089. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  2090. * cube texture in a cube
  2091. */
  2092. var CubeTextureElement = /** @class */ (function (_super) {
  2093. __extends(CubeTextureElement, _super);
  2094. /** The texture given as a parameter should be cube. */
  2095. function CubeTextureElement(tex) {
  2096. var _this = _super.call(this) || this;
  2097. // On pause the engine will not render anything
  2098. _this._pause = false;
  2099. _this._div.className = 'fa fa-search texture-element';
  2100. // Create the texture viewer
  2101. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  2102. // canvas
  2103. _this._canvas = INSPECTOR.Helpers.CreateElement('canvas', 'texture-viewer-img', _this._textureDiv);
  2104. if (tex) {
  2105. _this._textureUrl = tex.name;
  2106. }
  2107. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  2108. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  2109. return _this;
  2110. }
  2111. CubeTextureElement.prototype.update = function (tex) {
  2112. if (tex && tex.url === this._textureUrl) {
  2113. // Nothing to do, as the old texture is the same as the old one
  2114. }
  2115. else {
  2116. if (tex) {
  2117. this._textureUrl = tex.name;
  2118. }
  2119. if (this._engine) {
  2120. // Dispose old material and cube
  2121. if (this._cube.material) {
  2122. this._cube.material.dispose(true, true);
  2123. }
  2124. this._cube.dispose();
  2125. }
  2126. else {
  2127. this._initEngine();
  2128. }
  2129. // and create it again
  2130. this._populateScene();
  2131. }
  2132. };
  2133. /** Creates the box */
  2134. CubeTextureElement.prototype._populateScene = function () {
  2135. var _this = this;
  2136. // Create the hdr texture
  2137. var hdrTexture = new BABYLON.CubeTexture(this._textureUrl, this._scene);
  2138. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2139. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  2140. var hdrSkyboxMaterial = new BABYLON.StandardMaterial("skyBox", this._scene);
  2141. hdrSkyboxMaterial.backFaceCulling = false;
  2142. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  2143. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2144. hdrSkyboxMaterial.disableLighting = true;
  2145. this._cube.material = hdrSkyboxMaterial;
  2146. this._cube.registerBeforeRender(function () {
  2147. _this._cube.rotation.y += 0.01;
  2148. });
  2149. };
  2150. /** Init the babylon engine */
  2151. CubeTextureElement.prototype._initEngine = function () {
  2152. var _this = this;
  2153. this._engine = new BABYLON.Engine(this._canvas);
  2154. this._scene = new BABYLON.Scene(this._engine);
  2155. this._scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
  2156. this._engine.runRenderLoop(function () {
  2157. if (!_this._pause) {
  2158. _this._scene.render();
  2159. }
  2160. });
  2161. this._canvas.setAttribute('width', '110');
  2162. this._canvas.setAttribute('height', '110');
  2163. };
  2164. CubeTextureElement.prototype._showViewer = function (mode) {
  2165. // If displaying...
  2166. if (mode != 'none') {
  2167. // ... and the canvas is not initialized
  2168. if (!this._engine) {
  2169. this._initEngine();
  2170. this._populateScene();
  2171. }
  2172. // In every cases, unpause the engine
  2173. this._pause = false;
  2174. }
  2175. else {
  2176. // hide : pause the engine
  2177. this._pause = true;
  2178. }
  2179. this._textureDiv.style.display = mode;
  2180. };
  2181. /** Removes properly the babylon engine */
  2182. CubeTextureElement.prototype.dispose = function () {
  2183. if (this._engine) {
  2184. this._engine.dispose();
  2185. this._engine = null;
  2186. }
  2187. };
  2188. return CubeTextureElement;
  2189. }(INSPECTOR.BasicElement));
  2190. INSPECTOR.CubeTextureElement = CubeTextureElement;
  2191. })(INSPECTOR || (INSPECTOR = {}));
  2192. var __extends = (this && this.__extends) || (function () {
  2193. var extendStatics = Object.setPrototypeOf ||
  2194. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2195. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2196. return function (d, b) {
  2197. extendStatics(d, b);
  2198. function __() { this.constructor = d; }
  2199. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2200. };
  2201. })();
  2202. var INSPECTOR;
  2203. (function (INSPECTOR) {
  2204. /**
  2205. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  2206. * cube texture in a cube
  2207. */
  2208. var HDRCubeTextureElement = /** @class */ (function (_super) {
  2209. __extends(HDRCubeTextureElement, _super);
  2210. /** The texture given as a parameter should be cube. */
  2211. function HDRCubeTextureElement(tex) {
  2212. return _super.call(this, tex) || this;
  2213. }
  2214. /** Creates the box */
  2215. HDRCubeTextureElement.prototype._populateScene = function () {
  2216. var _this = this;
  2217. // Create the hdr texture
  2218. var hdrTexture = new BABYLON.HDRCubeTexture(this._textureUrl, this._scene, 512);
  2219. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2220. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  2221. var hdrSkyboxMaterial = new BABYLON.PBRMaterial("skyBox", this._scene);
  2222. hdrSkyboxMaterial.backFaceCulling = false;
  2223. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  2224. hdrSkyboxMaterial.microSurface = 1.0;
  2225. hdrSkyboxMaterial.disableLighting = true;
  2226. this._cube.material = hdrSkyboxMaterial;
  2227. this._cube.registerBeforeRender(function () {
  2228. _this._cube.rotation.y += 0.01;
  2229. });
  2230. };
  2231. return HDRCubeTextureElement;
  2232. }(INSPECTOR.CubeTextureElement));
  2233. INSPECTOR.HDRCubeTextureElement = HDRCubeTextureElement;
  2234. })(INSPECTOR || (INSPECTOR = {}));
  2235. var __extends = (this && this.__extends) || (function () {
  2236. var extendStatics = Object.setPrototypeOf ||
  2237. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2238. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2239. return function (d, b) {
  2240. extendStatics(d, b);
  2241. function __() { this.constructor = d; }
  2242. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2243. };
  2244. })();
  2245. var INSPECTOR;
  2246. (function (INSPECTOR) {
  2247. /**
  2248. * A search bar can be used to filter elements in the tree panel.
  2249. * At each keypress on the input, the treepanel will be filtered.
  2250. */
  2251. var SearchBar = /** @class */ (function (_super) {
  2252. __extends(SearchBar, _super);
  2253. function SearchBar(tab) {
  2254. var _this = _super.call(this) || this;
  2255. _this._propTab = tab;
  2256. _this._div.classList.add('searchbar');
  2257. var filter = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  2258. filter.className = 'fa fa-search';
  2259. _this._div.appendChild(filter);
  2260. // Create input
  2261. _this._inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  2262. _this._inputElement.placeholder = 'Filter by name...';
  2263. _this._div.appendChild(_this._inputElement);
  2264. _this._inputElement.addEventListener('keyup', function (evt) {
  2265. var filter = _this._inputElement.value;
  2266. _this._propTab.filter(filter);
  2267. });
  2268. return _this;
  2269. }
  2270. /** Delete all characters typped in the input element */
  2271. SearchBar.prototype.reset = function () {
  2272. this._inputElement.value = '';
  2273. };
  2274. SearchBar.prototype.update = function () {
  2275. // Nothing to update
  2276. };
  2277. return SearchBar;
  2278. }(INSPECTOR.BasicElement));
  2279. INSPECTOR.SearchBar = SearchBar;
  2280. var SearchBarDetails = /** @class */ (function (_super) {
  2281. __extends(SearchBarDetails, _super);
  2282. function SearchBarDetails(tab) {
  2283. var _this = _super.call(this) || this;
  2284. _this._detailTab = tab;
  2285. _this._div.classList.add('searchbar');
  2286. var filter = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  2287. filter.className = 'fa fa-search';
  2288. _this._div.appendChild(filter);
  2289. // Create input
  2290. _this._inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  2291. _this._inputElement.placeholder = 'Filter by name...';
  2292. _this._div.appendChild(_this._inputElement);
  2293. _this._inputElement.addEventListener('keyup', function (evt) {
  2294. var filter = _this._inputElement.value;
  2295. _this._detailTab.searchByName(filter);
  2296. });
  2297. return _this;
  2298. }
  2299. /** Delete all characters typped in the input element */
  2300. SearchBarDetails.prototype.reset = function () {
  2301. this._inputElement.value = '';
  2302. };
  2303. SearchBarDetails.prototype.update = function () {
  2304. // Nothing to update
  2305. };
  2306. return SearchBarDetails;
  2307. }(INSPECTOR.BasicElement));
  2308. INSPECTOR.SearchBarDetails = SearchBarDetails;
  2309. })(INSPECTOR || (INSPECTOR = {}));
  2310. var __extends = (this && this.__extends) || (function () {
  2311. var extendStatics = Object.setPrototypeOf ||
  2312. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2313. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2314. return function (d, b) {
  2315. extendStatics(d, b);
  2316. function __() { this.constructor = d; }
  2317. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2318. };
  2319. })();
  2320. var INSPECTOR;
  2321. (function (INSPECTOR) {
  2322. /**
  2323. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  2324. */
  2325. var TextureElement = /** @class */ (function (_super) {
  2326. __extends(TextureElement, _super);
  2327. function TextureElement(tex) {
  2328. var _this = _super.call(this) || this;
  2329. _this._div.className = 'fa fa-search texture-element';
  2330. // Create the texture viewer
  2331. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  2332. // Img
  2333. var imgDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer-img', _this._textureDiv);
  2334. // Texture size
  2335. var sizeDiv = INSPECTOR.Helpers.CreateDiv(null, _this._textureDiv);
  2336. if (tex) {
  2337. sizeDiv.textContent = tex.getBaseSize().width + "px x " + tex.getBaseSize().height + "px";
  2338. imgDiv.style.backgroundImage = "url('" + tex.url + "')";
  2339. imgDiv.style.width = tex.getBaseSize().width + "px";
  2340. imgDiv.style.height = tex.getBaseSize().height + "px";
  2341. }
  2342. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  2343. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  2344. return _this;
  2345. }
  2346. TextureElement.prototype.update = function (tex) {
  2347. };
  2348. TextureElement.prototype._showViewer = function (mode) {
  2349. this._textureDiv.style.display = mode;
  2350. };
  2351. return TextureElement;
  2352. }(INSPECTOR.BasicElement));
  2353. INSPECTOR.TextureElement = TextureElement;
  2354. })(INSPECTOR || (INSPECTOR = {}));
  2355. var INSPECTOR;
  2356. (function (INSPECTOR) {
  2357. /**
  2358. * Creates a tooltip for the parent of the given html element
  2359. */
  2360. var Tooltip = /** @class */ (function () {
  2361. function Tooltip(elem, tip, attachTo) {
  2362. if (attachTo === void 0) { attachTo = null; }
  2363. var _this = this;
  2364. this._elem = elem;
  2365. if (!attachTo) {
  2366. attachTo = this._elem.parentElement;
  2367. }
  2368. this._infoDiv = INSPECTOR.Helpers.CreateDiv('tooltip', attachTo);
  2369. this._elem.addEventListener('mouseover', function () {
  2370. _this._infoDiv.textContent = tip;
  2371. _this._infoDiv.style.display = 'block';
  2372. });
  2373. this._elem.addEventListener('mouseout', function () { _this._infoDiv.style.display = 'none'; });
  2374. }
  2375. return Tooltip;
  2376. }());
  2377. INSPECTOR.Tooltip = Tooltip;
  2378. })(INSPECTOR || (INSPECTOR = {}));
  2379. var INSPECTOR;
  2380. (function (INSPECTOR) {
  2381. var Helpers = /** @class */ (function () {
  2382. function Helpers() {
  2383. }
  2384. /**
  2385. * Returns the type of the given object. First
  2386. * uses getClassName. If nothing is returned, used the type of the constructor
  2387. */
  2388. Helpers.GET_TYPE = function (obj) {
  2389. if (typeof obj === 'boolean') {
  2390. return 'boolean';
  2391. }
  2392. if (obj != null && obj != undefined) {
  2393. var classname = BABYLON.Tools.GetClassName(obj);
  2394. if (!classname || classname === 'object') {
  2395. classname = obj.constructor.name;
  2396. // classname is undefined in IE11
  2397. if (!classname) {
  2398. classname = this._GetFnName(obj.constructor);
  2399. }
  2400. }
  2401. // If the class name has no matching properties, check every type
  2402. if (!this._CheckIfTypeExists(classname)) {
  2403. return this._GetTypeFor(obj);
  2404. }
  2405. return classname;
  2406. }
  2407. else {
  2408. return 'type_not_defined';
  2409. }
  2410. };
  2411. /**
  2412. * Check if some properties are defined for the given type.
  2413. */
  2414. Helpers._CheckIfTypeExists = function (type) {
  2415. var properties = INSPECTOR.PROPERTIES[type];
  2416. if (properties) {
  2417. return true;
  2418. }
  2419. return false;
  2420. };
  2421. /**
  2422. * Returns true if the user browser is edge.
  2423. */
  2424. Helpers.IsBrowserEdge = function () {
  2425. var regexp = /Edge/;
  2426. return regexp.test(navigator.userAgent);
  2427. };
  2428. /**
  2429. * Returns true if the user browser is IE.
  2430. */
  2431. Helpers.IsBrowserIE = function () {
  2432. var regexp = /Trident.*rv\:11\./;
  2433. return regexp.test(navigator.userAgent);
  2434. };
  2435. /**
  2436. * Returns the name of the type of the given object, where the name
  2437. * is in PROPERTIES constant.
  2438. * Returns 'Undefined' if no type exists for this object
  2439. */
  2440. Helpers._GetTypeFor = function (obj) {
  2441. for (var type in INSPECTOR.PROPERTIES) {
  2442. var typeBlock = INSPECTOR.PROPERTIES[type];
  2443. if (typeBlock.type) {
  2444. if (obj instanceof typeBlock.type) {
  2445. return type;
  2446. }
  2447. }
  2448. }
  2449. return 'type_not_defined';
  2450. };
  2451. /**
  2452. * Returns the name of a function (workaround to get object type for IE11)
  2453. */
  2454. Helpers._GetFnName = function (fn) {
  2455. var f = typeof fn == 'function';
  2456. var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
  2457. return (!f && 'not a function') || (s && s[1] || 'anonymous');
  2458. };
  2459. /** Send the event which name is given in parameter to the window */
  2460. Helpers.SEND_EVENT = function (eventName) {
  2461. var event;
  2462. if (INSPECTOR.Inspector.DOCUMENT.createEvent) {
  2463. event = INSPECTOR.Inspector.DOCUMENT.createEvent('HTMLEvents');
  2464. event.initEvent(eventName, true, true);
  2465. }
  2466. else {
  2467. event = new Event(eventName);
  2468. }
  2469. window.dispatchEvent(event);
  2470. };
  2471. /** Returns the given number with 2 decimal number max if a decimal part exists */
  2472. Helpers.Trunc = function (nb) {
  2473. if (typeof nb !== 'number') {
  2474. return 0;
  2475. }
  2476. if (Math.round(nb) !== nb) {
  2477. return nb.toFixed(2);
  2478. }
  2479. return nb;
  2480. };
  2481. ;
  2482. /**
  2483. * Useful function used to create a div
  2484. */
  2485. Helpers.CreateDiv = function (className, parent) {
  2486. if (className === void 0) { className = null; }
  2487. return Helpers.CreateElement('div', className, parent);
  2488. };
  2489. /**
  2490. * Useful function used to create a input
  2491. */
  2492. Helpers.CreateInput = function (className, parent) {
  2493. return Helpers.CreateElement('input', className, parent);
  2494. };
  2495. Helpers.CreateElement = function (element, className, parent) {
  2496. if (className === void 0) { className = null; }
  2497. var elem = INSPECTOR.Inspector.DOCUMENT.createElement(element);
  2498. if (className) {
  2499. elem.className = className;
  2500. }
  2501. if (parent) {
  2502. parent.appendChild(elem);
  2503. }
  2504. return elem;
  2505. };
  2506. /**
  2507. * Removes all children of the given div.
  2508. */
  2509. Helpers.CleanDiv = function (div) {
  2510. while (div.firstChild) {
  2511. div.removeChild(div.firstChild);
  2512. }
  2513. };
  2514. /**
  2515. * Returns the true value of the given CSS Attribute from the given element (in percentage or in pixel, as it was specified in the css)
  2516. */
  2517. Helpers.Css = function (elem, cssAttribute) {
  2518. var clone = elem.cloneNode(true);
  2519. var div = Helpers.CreateDiv('', INSPECTOR.Inspector.DOCUMENT.body);
  2520. div.style.display = 'none';
  2521. div.appendChild(clone);
  2522. var value = INSPECTOR.Inspector.WINDOW.getComputedStyle(clone)[cssAttribute];
  2523. if (div.parentNode) {
  2524. div.parentNode.removeChild(div);
  2525. }
  2526. return value;
  2527. };
  2528. Helpers.LoadScript = function () {
  2529. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js", function (elem) {
  2530. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2531. script.textContent = elem;
  2532. // Load glsl detection
  2533. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/languages/glsl.min.js", function (elem) {
  2534. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2535. script.textContent = elem;
  2536. // Load css style
  2537. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/zenburn.min.css", function (elem) {
  2538. var style = Helpers.CreateElement('style', '', INSPECTOR.Inspector.DOCUMENT.body);
  2539. style.textContent = elem;
  2540. });
  2541. }, undefined, undefined, undefined, function () {
  2542. console.log('Error : LoadFile "glsl.min.js"');
  2543. });
  2544. }, undefined, undefined, undefined, function () {
  2545. console.log('Error : LoadFile "highlight.min.js"');
  2546. });
  2547. };
  2548. Helpers.IsSystemName = function (name) {
  2549. if (name == null) {
  2550. return false;
  2551. }
  2552. return name.indexOf("###") === 0 && name.lastIndexOf("###") === (name.length - 3);
  2553. };
  2554. /**
  2555. * Return an array of PropertyLine for an obj
  2556. * @param obj
  2557. */
  2558. Helpers.GetAllLinesProperties = function (obj) {
  2559. var propertiesLines = [];
  2560. var props = Helpers.GetAllLinesPropertiesAsString(obj);
  2561. for (var _i = 0, props_1 = props; _i < props_1.length; _i++) {
  2562. var prop = props_1[_i];
  2563. var infos = new INSPECTOR.Property(prop, obj);
  2564. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  2565. }
  2566. return propertiesLines;
  2567. };
  2568. /**
  2569. * Returns an array of string corresponding to tjhe list of properties of the object to be displayed
  2570. * @param obj
  2571. */
  2572. Helpers.GetAllLinesPropertiesAsString = function (obj, dontTakeThis) {
  2573. if (dontTakeThis === void 0) { dontTakeThis = []; }
  2574. var props = [];
  2575. for (var prop in obj) {
  2576. //No private and no function
  2577. if (dontTakeThis.indexOf(prop) === -1 && prop.substring(0, 1) !== '_' && typeof obj[prop] !== 'function') {
  2578. props.push(prop);
  2579. }
  2580. }
  2581. return props;
  2582. };
  2583. Helpers.Capitalize = function (str) {
  2584. return str.charAt(0).toUpperCase() + str.slice(1);
  2585. };
  2586. return Helpers;
  2587. }());
  2588. INSPECTOR.Helpers = Helpers;
  2589. })(INSPECTOR || (INSPECTOR = {}));
  2590. var INSPECTOR;
  2591. (function (INSPECTOR) {
  2592. var Scheduler = /** @class */ (function () {
  2593. function Scheduler() {
  2594. /** Is this scheduler in pause ? */
  2595. this.pause = false;
  2596. /** The list of data to update */
  2597. this._updatableProperties = [];
  2598. this.interval = setInterval(this._update.bind(this), Scheduler.REFRESH_TIME);
  2599. }
  2600. Scheduler.getInstance = function () {
  2601. if (!Scheduler._instance) {
  2602. Scheduler._instance = new Scheduler();
  2603. }
  2604. return Scheduler._instance;
  2605. };
  2606. /** Add a property line to be updated every X ms */
  2607. Scheduler.prototype.add = function (prop) {
  2608. this._updatableProperties.push(prop);
  2609. };
  2610. /** Removes the given property from the list of properties to update */
  2611. Scheduler.prototype.remove = function (prop) {
  2612. var index = this._updatableProperties.indexOf(prop);
  2613. if (index != -1) {
  2614. this._updatableProperties.splice(index, 1);
  2615. }
  2616. };
  2617. Scheduler.prototype._update = function () {
  2618. // If not in pause, update
  2619. if (!this.pause) {
  2620. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  2621. var prop = _a[_i];
  2622. prop.update();
  2623. }
  2624. }
  2625. };
  2626. Scheduler.prototype.dispose = function () {
  2627. window.clearInterval(this.interval);
  2628. };
  2629. /** All properties are refreshed every 250ms */
  2630. Scheduler.REFRESH_TIME = 250;
  2631. return Scheduler;
  2632. }());
  2633. INSPECTOR.Scheduler = Scheduler;
  2634. })(INSPECTOR || (INSPECTOR = {}));
  2635. var __extends = (this && this.__extends) || (function () {
  2636. var extendStatics = Object.setPrototypeOf ||
  2637. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2638. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2639. return function (d, b) {
  2640. extendStatics(d, b);
  2641. function __() { this.constructor = d; }
  2642. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2643. };
  2644. })();
  2645. var INSPECTOR;
  2646. (function (INSPECTOR) {
  2647. var Tab = /** @class */ (function (_super) {
  2648. __extends(Tab, _super);
  2649. function Tab(tabbar, name) {
  2650. var _this = _super.call(this) || this;
  2651. _this._isActive = false;
  2652. _this._tabbar = tabbar;
  2653. _this.name = name;
  2654. _this._build();
  2655. return _this;
  2656. }
  2657. /** True if the tab is active, false otherwise */
  2658. Tab.prototype.isActive = function () {
  2659. return this._isActive;
  2660. };
  2661. Tab.prototype._build = function () {
  2662. var _this = this;
  2663. this._div.className = 'tab';
  2664. this._div.textContent = this.name;
  2665. this._div.addEventListener('click', function (evt) {
  2666. // Set this tab as active
  2667. _this._tabbar.switchTab(_this);
  2668. });
  2669. };
  2670. /** Set this tab as active or not, depending on the current state */
  2671. Tab.prototype.active = function (b) {
  2672. if (b) {
  2673. this._div.classList.add('active');
  2674. }
  2675. else {
  2676. this._div.classList.remove('active');
  2677. }
  2678. this._isActive = b;
  2679. };
  2680. Tab.prototype.update = function () {
  2681. // Nothing for the moment
  2682. };
  2683. /** Creates the tab panel for this tab. */
  2684. Tab.prototype.getPanel = function () {
  2685. return this._panel;
  2686. };
  2687. /** Add this in the propertytab with the searchbar */
  2688. Tab.prototype.filter = function (str) { };
  2689. ;
  2690. /** Select an item in the tree */
  2691. Tab.prototype.select = function (item) {
  2692. // To define in subclasses if needed
  2693. };
  2694. /**
  2695. * Returns the total width in pixel of this tab, 0 by default
  2696. */
  2697. Tab.prototype.getPixelWidth = function () {
  2698. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._div);
  2699. if (!style.marginLeft || !style.marginRight) {
  2700. return 0;
  2701. }
  2702. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  2703. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  2704. return (this._div.clientWidth || 0) + left + right;
  2705. };
  2706. return Tab;
  2707. }(INSPECTOR.BasicElement));
  2708. INSPECTOR.Tab = Tab;
  2709. })(INSPECTOR || (INSPECTOR = {}));
  2710. var __extends = (this && this.__extends) || (function () {
  2711. var extendStatics = Object.setPrototypeOf ||
  2712. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2713. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2714. return function (d, b) {
  2715. extendStatics(d, b);
  2716. function __() { this.constructor = d; }
  2717. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2718. };
  2719. })();
  2720. var INSPECTOR;
  2721. (function (INSPECTOR) {
  2722. /**
  2723. * A Property tab can creates two panels:
  2724. * a tree panel and a detail panel,
  2725. * in which properties will be displayed.
  2726. * Both panels are separated by a resize bar
  2727. */
  2728. var PropertyTab = /** @class */ (function (_super) {
  2729. __extends(PropertyTab, _super);
  2730. function PropertyTab(tabbar, name, insp) {
  2731. var _this = _super.call(this, tabbar, name) || this;
  2732. _this._treeItems = [];
  2733. _this._inspector = insp;
  2734. // Build the properties panel : a div that will contains the tree and the detail panel
  2735. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2736. _this._panel.classList.add('searchable');
  2737. // Search bar
  2738. _this._searchBar = new INSPECTOR.SearchBar(_this);
  2739. // Add searchbar
  2740. _this._panel.appendChild(_this._searchBar.toHtml());
  2741. // Build the treepanel
  2742. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  2743. // Build the detail panel
  2744. _this._detailsPanel = new INSPECTOR.DetailPanel();
  2745. _this._panel.appendChild(_this._detailsPanel.toHtml());
  2746. Split([_this._treePanel, _this._detailsPanel.toHtml()], {
  2747. blockDrag: _this._inspector.popupMode,
  2748. direction: 'vertical'
  2749. });
  2750. _this.update();
  2751. return _this;
  2752. }
  2753. /** Overrides dispose */
  2754. PropertyTab.prototype.dispose = function () {
  2755. this._detailsPanel.dispose();
  2756. };
  2757. PropertyTab.prototype.update = function (_items) {
  2758. var items;
  2759. if (_items) {
  2760. items = _items;
  2761. }
  2762. else {
  2763. // Rebuild the tree
  2764. this._treeItems = this._getTree();
  2765. items = this._treeItems;
  2766. }
  2767. // Clean the tree
  2768. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  2769. // Clean the detail properties
  2770. this._detailsPanel.clean();
  2771. // Sort items alphabetically
  2772. items.sort(function (item1, item2) {
  2773. return item1.compareTo(item2);
  2774. });
  2775. // Display items
  2776. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  2777. var item = items_1[_i];
  2778. this._treePanel.appendChild(item.toHtml());
  2779. }
  2780. };
  2781. /** Display the details of the given item */
  2782. PropertyTab.prototype.displayDetails = function (item) {
  2783. // Remove active state on all items
  2784. this.activateNode(item);
  2785. // Update the detail panel
  2786. this._detailsPanel.details = item.getDetails();
  2787. };
  2788. /** Select an item in the tree */
  2789. PropertyTab.prototype.select = function (item) {
  2790. // Active the node
  2791. this.activateNode(item);
  2792. // Display its details
  2793. this.displayDetails(item);
  2794. };
  2795. /** Set the given item as active in the tree */
  2796. PropertyTab.prototype.activateNode = function (item) {
  2797. if (this._treeItems) {
  2798. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2799. var node = _a[_i];
  2800. node.active(false);
  2801. }
  2802. }
  2803. // item.getDiv().scrollIntoView();
  2804. item.active(true);
  2805. };
  2806. /** Returns the treeitem corersponding to the given obj, null if not found */
  2807. PropertyTab.prototype.getItemFor = function (_obj) {
  2808. var obj = _obj;
  2809. // Search recursively
  2810. var searchObjectInTree = function (object, treeItem) {
  2811. if (treeItem.correspondsTo(object)) {
  2812. return treeItem;
  2813. }
  2814. else {
  2815. if (treeItem.children.length > 0) {
  2816. for (var _i = 0, _a = treeItem.children; _i < _a.length; _i++) {
  2817. var item = _a[_i];
  2818. var it = searchObjectInTree(obj, item);
  2819. if (it) {
  2820. return it;
  2821. }
  2822. }
  2823. }
  2824. else {
  2825. return null;
  2826. }
  2827. }
  2828. return null;
  2829. };
  2830. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2831. var item = _a[_i];
  2832. var it = searchObjectInTree(obj, item);
  2833. if (it) {
  2834. return it;
  2835. }
  2836. }
  2837. return null;
  2838. };
  2839. PropertyTab.prototype.filter = function (filter) {
  2840. var items = [];
  2841. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2842. var item = _a[_i];
  2843. if (item.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2844. items.push(item);
  2845. }
  2846. for (var _b = 0, _c = item.children; _b < _c.length; _b++) {
  2847. var child = _c[_b];
  2848. if (child.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2849. items.push(item);
  2850. }
  2851. }
  2852. }
  2853. this.update(items);
  2854. };
  2855. return PropertyTab;
  2856. }(INSPECTOR.Tab));
  2857. INSPECTOR.PropertyTab = PropertyTab;
  2858. })(INSPECTOR || (INSPECTOR = {}));
  2859. var __extends = (this && this.__extends) || (function () {
  2860. var extendStatics = Object.setPrototypeOf ||
  2861. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2862. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2863. return function (d, b) {
  2864. extendStatics(d, b);
  2865. function __() { this.constructor = d; }
  2866. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2867. };
  2868. })();
  2869. var INSPECTOR;
  2870. (function (INSPECTOR) {
  2871. var CameraTab = /** @class */ (function (_super) {
  2872. __extends(CameraTab, _super);
  2873. function CameraTab(tabbar, inspector) {
  2874. return _super.call(this, tabbar, 'Camera', inspector) || this;
  2875. }
  2876. /* Overrides super */
  2877. CameraTab.prototype._getTree = function () {
  2878. var arr = [];
  2879. // get all cameras from the first scene
  2880. var instances = this._inspector.scene;
  2881. for (var _i = 0, _a = instances.cameras; _i < _a.length; _i++) {
  2882. var camera = _a[_i];
  2883. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.CameraAdapter(camera)));
  2884. }
  2885. return arr;
  2886. };
  2887. return CameraTab;
  2888. }(INSPECTOR.PropertyTab));
  2889. INSPECTOR.CameraTab = CameraTab;
  2890. })(INSPECTOR || (INSPECTOR = {}));
  2891. var __extends = (this && this.__extends) || (function () {
  2892. var extendStatics = Object.setPrototypeOf ||
  2893. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2894. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2895. return function (d, b) {
  2896. extendStatics(d, b);
  2897. function __() { this.constructor = d; }
  2898. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2899. };
  2900. })();
  2901. var INSPECTOR;
  2902. (function (INSPECTOR) {
  2903. var GUITab = /** @class */ (function (_super) {
  2904. __extends(GUITab, _super);
  2905. function GUITab(tabbar, inspector) {
  2906. return _super.call(this, tabbar, 'GUI', inspector) || this;
  2907. }
  2908. /* Overrides super */
  2909. GUITab.prototype._getTree = function () {
  2910. var _this = this;
  2911. var arr = [];
  2912. // Recursive method building the tree panel
  2913. var createNode = function (obj) {
  2914. var descendants = obj.children;
  2915. if (descendants && descendants.length > 0) {
  2916. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.GUIAdapter(obj));
  2917. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  2918. var child = descendants_1[_i];
  2919. var n = createNode(child);
  2920. node.add(n);
  2921. }
  2922. node.update();
  2923. return node;
  2924. }
  2925. else {
  2926. return new INSPECTOR.TreeItem(_this, new INSPECTOR.GUIAdapter(obj));
  2927. }
  2928. };
  2929. // get all textures from the first scene
  2930. var instances = this._inspector.scene;
  2931. for (var _i = 0, _a = instances.textures; _i < _a.length; _i++) {
  2932. var tex = _a[_i];
  2933. //only get GUI's textures
  2934. if (tex instanceof BABYLON.GUI.AdvancedDynamicTexture) {
  2935. var node = createNode(tex._rootContainer);
  2936. arr.push(node);
  2937. }
  2938. }
  2939. return arr;
  2940. };
  2941. return GUITab;
  2942. }(INSPECTOR.PropertyTab));
  2943. INSPECTOR.GUITab = GUITab;
  2944. })(INSPECTOR || (INSPECTOR = {}));
  2945. var __extends = (this && this.__extends) || (function () {
  2946. var extendStatics = Object.setPrototypeOf ||
  2947. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2948. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2949. return function (d, b) {
  2950. extendStatics(d, b);
  2951. function __() { this.constructor = d; }
  2952. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2953. };
  2954. })();
  2955. var INSPECTOR;
  2956. (function (INSPECTOR) {
  2957. var PhysicsTab = /** @class */ (function (_super) {
  2958. __extends(PhysicsTab, _super);
  2959. function PhysicsTab(tabbar, inspector) {
  2960. return _super.call(this, tabbar, 'Physics', inspector) || this;
  2961. }
  2962. /* Overrides super */
  2963. PhysicsTab.prototype._getTree = function () {
  2964. var arr = new Array();
  2965. var scene = this._inspector.scene;
  2966. if (!scene.isPhysicsEnabled()) {
  2967. return arr;
  2968. }
  2969. if (!this.viewer) {
  2970. this.viewer = new BABYLON.Debug.PhysicsViewer(scene);
  2971. }
  2972. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  2973. var mesh = _a[_i];
  2974. if (mesh.physicsImpostor) {
  2975. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.PhysicsImpostorAdapter(mesh.physicsImpostor, this.viewer)));
  2976. }
  2977. }
  2978. return arr;
  2979. };
  2980. return PhysicsTab;
  2981. }(INSPECTOR.PropertyTab));
  2982. INSPECTOR.PhysicsTab = PhysicsTab;
  2983. })(INSPECTOR || (INSPECTOR = {}));
  2984. var __extends = (this && this.__extends) || (function () {
  2985. var extendStatics = Object.setPrototypeOf ||
  2986. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2987. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2988. return function (d, b) {
  2989. extendStatics(d, b);
  2990. function __() { this.constructor = d; }
  2991. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2992. };
  2993. })();
  2994. var INSPECTOR;
  2995. (function (INSPECTOR) {
  2996. var SoundTab = /** @class */ (function (_super) {
  2997. __extends(SoundTab, _super);
  2998. function SoundTab(tabbar, inspector) {
  2999. return _super.call(this, tabbar, 'Audio', inspector) || this;
  3000. }
  3001. /* Overrides super */
  3002. SoundTab.prototype._getTree = function () {
  3003. var _this = this;
  3004. var arr = new Array();
  3005. // get all cameras from the first scene
  3006. var instances = this._inspector.scene;
  3007. for (var _i = 0, _a = instances.soundTracks; _i < _a.length; _i++) {
  3008. var sounds = _a[_i];
  3009. var sound = sounds.soundCollection;
  3010. sound.forEach(function (element) {
  3011. arr.push(new INSPECTOR.TreeItem(_this, new INSPECTOR.SoundAdapter(element)));
  3012. });
  3013. }
  3014. return arr;
  3015. };
  3016. return SoundTab;
  3017. }(INSPECTOR.PropertyTab));
  3018. INSPECTOR.SoundTab = SoundTab;
  3019. })(INSPECTOR || (INSPECTOR = {}));
  3020. var __extends = (this && this.__extends) || (function () {
  3021. var extendStatics = Object.setPrototypeOf ||
  3022. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3023. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3024. return function (d, b) {
  3025. extendStatics(d, b);
  3026. function __() { this.constructor = d; }
  3027. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3028. };
  3029. })();
  3030. var INSPECTOR;
  3031. (function (INSPECTOR) {
  3032. var TextureTab = /** @class */ (function (_super) {
  3033. __extends(TextureTab, _super);
  3034. function TextureTab(tabbar, inspector) {
  3035. var _this = _super.call(this, tabbar, 'Textures') || this;
  3036. _this._treeItems = [];
  3037. _this._inspector = inspector;
  3038. // Build the properties panel : a div that will contains the tree and the detail panel
  3039. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3040. // Build the treepanel
  3041. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  3042. _this._imagePanel = INSPECTOR.Helpers.CreateDiv('insp-details', _this._panel);
  3043. Split([_this._treePanel, _this._imagePanel], {
  3044. blockDrag: _this._inspector.popupMode,
  3045. direction: 'vertical'
  3046. });
  3047. _this.update();
  3048. return _this;
  3049. }
  3050. TextureTab.prototype.dispose = function () {
  3051. // Nothing to dispose
  3052. };
  3053. TextureTab.prototype.update = function (_items) {
  3054. var items;
  3055. if (_items) {
  3056. items = _items;
  3057. }
  3058. else {
  3059. // Rebuild the tree
  3060. this._treeItems = this._getTree();
  3061. items = this._treeItems;
  3062. }
  3063. // Clean the tree
  3064. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  3065. INSPECTOR.Helpers.CleanDiv(this._imagePanel);
  3066. // Sort items alphabetically
  3067. items.sort(function (item1, item2) {
  3068. return item1.compareTo(item2);
  3069. });
  3070. // Display items
  3071. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  3072. var item = items_1[_i];
  3073. this._treePanel.appendChild(item.toHtml());
  3074. }
  3075. };
  3076. /* Overrides super */
  3077. TextureTab.prototype._getTree = function () {
  3078. var arr = [];
  3079. // get all cameras from the first scene
  3080. var instances = this._inspector.scene;
  3081. for (var _i = 0, _a = instances.textures; _i < _a.length; _i++) {
  3082. var tex = _a[_i];
  3083. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.TextureAdapter(tex)));
  3084. }
  3085. return arr;
  3086. };
  3087. /** Display the details of the given item */
  3088. TextureTab.prototype.displayDetails = function (item) {
  3089. // Remove active state on all items
  3090. this.activateNode(item);
  3091. INSPECTOR.Helpers.CleanDiv(this._imagePanel);
  3092. // Get the texture object
  3093. var texture = item.adapter.object;
  3094. var imgs = [];
  3095. var img = INSPECTOR.Helpers.CreateElement('img', 'texture-image', this._imagePanel);
  3096. imgs.push(img);
  3097. //Create five other images elements
  3098. for (var i = 0; i < 5; i++) {
  3099. imgs.push(INSPECTOR.Helpers.CreateElement('img', 'texture-image', this._imagePanel));
  3100. }
  3101. if (texture instanceof BABYLON.RenderTargetTexture) {
  3102. // RenderTarget textures
  3103. var scene = this._inspector.scene;
  3104. var engine_1 = scene.getEngine();
  3105. var size_1 = texture.getSize();
  3106. // Clone the texture
  3107. var screenShotTexture = texture.clone();
  3108. screenShotTexture.activeCamera = texture.activeCamera;
  3109. screenShotTexture.onBeforeRender = texture.onBeforeRender;
  3110. screenShotTexture.onAfterRender = texture.onAfterRender;
  3111. screenShotTexture.onBeforeRenderObservable = texture.onBeforeRenderObservable;
  3112. // To display the texture after rendering
  3113. screenShotTexture.onAfterRenderObservable.add(function (faceIndex) {
  3114. BABYLON.Tools.DumpFramebuffer(size_1.width, size_1.height, engine_1, function (data) { return imgs[faceIndex].src = data; });
  3115. });
  3116. // Render the texture
  3117. scene.incrementRenderId();
  3118. scene.resetCachedMaterial();
  3119. screenShotTexture.render();
  3120. screenShotTexture.dispose();
  3121. }
  3122. else if (texture instanceof BABYLON.CubeTexture) {
  3123. // Cannot open correctly DDS File
  3124. // Display all textures of the CubeTexture
  3125. var pixels = texture.readPixels();
  3126. var canvas = document.createElement('canvas');
  3127. canvas.id = "MyCanvas";
  3128. if (img.parentElement) {
  3129. img.parentElement.appendChild(canvas);
  3130. }
  3131. var ctx = canvas.getContext('2d');
  3132. var size = texture.getSize();
  3133. var tmp = pixels.buffer.slice(0, size.height * size.width * 4);
  3134. var u = new Uint8ClampedArray(tmp);
  3135. var colors = new ImageData(size.width * 6, size.height);
  3136. colors.data.set(u);
  3137. var imgData = ctx.createImageData(size.width * 6, size.height);
  3138. imgData.data.set(u);
  3139. // let data = imgData.data;
  3140. // for(let i = 0, len = size.height * size.width; i < len; i++) {
  3141. // data[i] = pixels[i];
  3142. // }
  3143. ctx.putImageData(imgData, 0, 0);
  3144. // let i: number = 0;
  3145. // for(let filename of (texture as BABYLON.CubeTexture)['_files']){
  3146. // imgs[i].src = filename;
  3147. // i++;
  3148. // }
  3149. }
  3150. else if (texture['_canvas']) {
  3151. // Dynamic texture
  3152. var base64Image = texture['_canvas'].toDataURL("image/png");
  3153. img.src = base64Image;
  3154. }
  3155. else if (texture.url) {
  3156. var pixels = texture.readPixels();
  3157. var canvas = document.createElement('canvas');
  3158. canvas.id = "MyCanvas";
  3159. if (img.parentElement) {
  3160. img.parentElement.appendChild(canvas);
  3161. }
  3162. var ctx = canvas.getContext('2d');
  3163. var size = texture.getSize();
  3164. var imgData = ctx.createImageData(size.width, size.height);
  3165. imgData.data.set(pixels);
  3166. ctx.putImageData(imgData, 0, 0);
  3167. // If an url is present, the texture is an image
  3168. // img.src = texture.url;
  3169. }
  3170. };
  3171. /** Select an item in the tree */
  3172. TextureTab.prototype.select = function (item) {
  3173. // Active the node
  3174. this.activateNode(item);
  3175. // Display its details
  3176. this.displayDetails(item);
  3177. };
  3178. /** Set the given item as active in the tree */
  3179. TextureTab.prototype.activateNode = function (item) {
  3180. if (this._treeItems) {
  3181. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  3182. var node = _a[_i];
  3183. node.active(false);
  3184. }
  3185. }
  3186. item.active(true);
  3187. };
  3188. return TextureTab;
  3189. }(INSPECTOR.Tab));
  3190. INSPECTOR.TextureTab = TextureTab;
  3191. })(INSPECTOR || (INSPECTOR = {}));
  3192. var __extends = (this && this.__extends) || (function () {
  3193. var extendStatics = Object.setPrototypeOf ||
  3194. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3195. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3196. return function (d, b) {
  3197. extendStatics(d, b);
  3198. function __() { this.constructor = d; }
  3199. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3200. };
  3201. })();
  3202. var INSPECTOR;
  3203. (function (INSPECTOR) {
  3204. var LightTab = /** @class */ (function (_super) {
  3205. __extends(LightTab, _super);
  3206. function LightTab(tabbar, inspector) {
  3207. return _super.call(this, tabbar, 'Light', inspector) || this;
  3208. }
  3209. /* Overrides super */
  3210. LightTab.prototype._getTree = function () {
  3211. var arr = [];
  3212. // get all lights from the first scene
  3213. var instances = this._inspector.scene;
  3214. for (var _i = 0, _a = instances.lights; _i < _a.length; _i++) {
  3215. var light = _a[_i];
  3216. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.LightAdapter(light)));
  3217. }
  3218. return arr;
  3219. };
  3220. return LightTab;
  3221. }(INSPECTOR.PropertyTab));
  3222. INSPECTOR.LightTab = LightTab;
  3223. })(INSPECTOR || (INSPECTOR = {}));
  3224. var __extends = (this && this.__extends) || (function () {
  3225. var extendStatics = Object.setPrototypeOf ||
  3226. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3227. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3228. return function (d, b) {
  3229. extendStatics(d, b);
  3230. function __() { this.constructor = d; }
  3231. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3232. };
  3233. })();
  3234. var INSPECTOR;
  3235. (function (INSPECTOR) {
  3236. var MaterialTab = /** @class */ (function (_super) {
  3237. __extends(MaterialTab, _super);
  3238. function MaterialTab(tabbar, inspector) {
  3239. return _super.call(this, tabbar, 'Material', inspector) || this;
  3240. }
  3241. /* Overrides super */
  3242. MaterialTab.prototype._getTree = function () {
  3243. var arr = [];
  3244. // get all meshes from the first scene
  3245. var instances = this._inspector.scene;
  3246. for (var _i = 0, _a = instances.materials; _i < _a.length; _i++) {
  3247. var mat = _a[_i];
  3248. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.MaterialAdapter(mat)));
  3249. }
  3250. return arr;
  3251. };
  3252. return MaterialTab;
  3253. }(INSPECTOR.PropertyTab));
  3254. INSPECTOR.MaterialTab = MaterialTab;
  3255. })(INSPECTOR || (INSPECTOR = {}));
  3256. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  3257. var __extends = (this && this.__extends) || (function () {
  3258. var extendStatics = Object.setPrototypeOf ||
  3259. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3260. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3261. return function (d, b) {
  3262. extendStatics(d, b);
  3263. function __() { this.constructor = d; }
  3264. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3265. };
  3266. })();
  3267. var INSPECTOR;
  3268. (function (INSPECTOR) {
  3269. var MeshTab = /** @class */ (function (_super) {
  3270. __extends(MeshTab, _super);
  3271. function MeshTab(tabbar, inspector) {
  3272. return _super.call(this, tabbar, 'Mesh', inspector) || this;
  3273. }
  3274. /* Overrides super */
  3275. MeshTab.prototype._getTree = function () {
  3276. var _this = this;
  3277. var arr = new Array();
  3278. // Tab containing mesh already in results
  3279. var alreadyIn = new Array();
  3280. // Recursive method building the tree panel
  3281. var createNode = function (obj) {
  3282. var descendants = obj.getDescendants(true);
  3283. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.MeshAdapter(obj));
  3284. if (descendants.length > 0) {
  3285. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  3286. var child = descendants_1[_i];
  3287. if (child instanceof BABYLON.TransformNode) {
  3288. if (!INSPECTOR.Helpers.IsSystemName(child.name)) {
  3289. var n = createNode(child);
  3290. node.add(n);
  3291. }
  3292. }
  3293. }
  3294. node.update();
  3295. }
  3296. // Retrieve the root node if the mesh is actually child of another mesh
  3297. // This can hapen if the child mesh has been created before the parent mesh
  3298. if (obj.parent != null && alreadyIn.indexOf(obj) != -1) {
  3299. var i = 0;
  3300. var notFound = true;
  3301. // Find and delete the root node standing for this mesh
  3302. while (i < arr.length && notFound) {
  3303. if (obj.name === arr[i].id) {
  3304. arr.splice(i, 1);
  3305. notFound = false;
  3306. }
  3307. i++;
  3308. }
  3309. }
  3310. alreadyIn.push(obj);
  3311. return node;
  3312. };
  3313. // get all meshes from the first scene
  3314. var instances = this._inspector.scene;
  3315. // Find top of hierarchy for meshes...
  3316. var meshWithoutAnyParent = [];
  3317. for (var _i = 0, _a = instances.meshes; _i < _a.length; _i++) {
  3318. var mesh = _a[_i];
  3319. // Not already in the array, not system name and no parent
  3320. if (meshWithoutAnyParent.indexOf(mesh) == -1 && !INSPECTOR.Helpers.IsSystemName(mesh.name) && !mesh.parent) {
  3321. meshWithoutAnyParent.push(mesh);
  3322. }
  3323. }
  3324. // ... and for transforms
  3325. for (var _b = 0, _c = instances.transformNodes; _b < _c.length; _b++) {
  3326. var tn = _c[_b];
  3327. // Not already in the array, not system name and no parent
  3328. if (meshWithoutAnyParent.indexOf(tn) == -1 && !INSPECTOR.Helpers.IsSystemName(tn.name) && !tn.parent) {
  3329. meshWithoutAnyParent.push(tn);
  3330. }
  3331. }
  3332. for (var _d = 0, meshWithoutAnyParent_1 = meshWithoutAnyParent; _d < meshWithoutAnyParent_1.length; _d++) {
  3333. var mesh = meshWithoutAnyParent_1[_d];
  3334. if (alreadyIn.indexOf(mesh) == -1 && !INSPECTOR.Helpers.IsSystemName(mesh.name)) {
  3335. var node = createNode(mesh);
  3336. arr.push(node);
  3337. }
  3338. }
  3339. return arr;
  3340. };
  3341. return MeshTab;
  3342. }(INSPECTOR.PropertyTab));
  3343. INSPECTOR.MeshTab = MeshTab;
  3344. })(INSPECTOR || (INSPECTOR = {}));
  3345. var __extends = (this && this.__extends) || (function () {
  3346. var extendStatics = Object.setPrototypeOf ||
  3347. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3348. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3349. return function (d, b) {
  3350. extendStatics(d, b);
  3351. function __() { this.constructor = d; }
  3352. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3353. };
  3354. })();
  3355. var INSPECTOR;
  3356. (function (INSPECTOR) {
  3357. var SceneTab = /** @class */ (function (_super) {
  3358. __extends(SceneTab, _super);
  3359. function SceneTab(tabbar, insp) {
  3360. var _this = _super.call(this, tabbar, 'Scene') || this;
  3361. /** The list of skeleton viewer */
  3362. _this._skeletonViewers = [];
  3363. _this._inspector = insp;
  3364. // Build the properties panel : a div that will contains the tree and the detail panel
  3365. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3366. _this._actions = INSPECTOR.Helpers.CreateDiv('scene-actions', _this._panel);
  3367. _this._detailsPanel = new INSPECTOR.DetailPanel();
  3368. _this._panel.appendChild(_this._detailsPanel.toHtml());
  3369. // build propertiesline
  3370. var details = [];
  3371. // Remove deprecated properties generating warning in console
  3372. var dontTakeThis = ['interFramePerfCounter', 'lastFramePerfCounter', 'evaluateActiveMeshesDurationPerfCounter', 'renderDurationPerfCounter', 'particlesDurationPerfCounter', 'spriteDuractionPerfCounter'];
  3373. var props = INSPECTOR.Helpers.GetAllLinesPropertiesAsString(_this._inspector.scene, dontTakeThis);
  3374. for (var _i = 0, props_1 = props; _i < props_1.length; _i++) {
  3375. var propString = props_1[_i];
  3376. var prop = new INSPECTOR.PropertyLine(new INSPECTOR.Property(propString, _this._inspector.scene));
  3377. details.push(prop);
  3378. }
  3379. _this._detailsPanel.details = details;
  3380. Split([_this._actions, _this._detailsPanel.toHtml()], {
  3381. blockDrag: _this._inspector.popupMode,
  3382. sizes: [50, 50],
  3383. direction: 'vertical'
  3384. });
  3385. // Build actions
  3386. {
  3387. // Rendering mode
  3388. var title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3389. title.textContent = 'Rendering mode';
  3390. var point = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3391. var wireframe = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3392. var solid = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3393. point.textContent = 'Point';
  3394. wireframe.textContent = 'Wireframe';
  3395. solid.textContent = 'Solid';
  3396. if (_this._inspector.scene.forcePointsCloud) {
  3397. point.classList.add('active');
  3398. }
  3399. else if (_this._inspector.scene.forceWireframe) {
  3400. wireframe.classList.add('active');
  3401. }
  3402. else {
  3403. solid.classList.add('active');
  3404. }
  3405. _this._generateRadioAction([point, wireframe, solid]);
  3406. point.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = true; _this._inspector.scene.forceWireframe = false; });
  3407. wireframe.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = true; });
  3408. solid.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = false; });
  3409. // Textures
  3410. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3411. title.textContent = 'Textures channels';
  3412. _this._generateActionLine('Diffuse Texture', BABYLON.StandardMaterial.DiffuseTextureEnabled, function (b) { BABYLON.StandardMaterial.DiffuseTextureEnabled = b; });
  3413. _this._generateActionLine('Ambient Texture', BABYLON.StandardMaterial.AmbientTextureEnabled, function (b) { BABYLON.StandardMaterial.AmbientTextureEnabled = b; });
  3414. _this._generateActionLine('Specular Texture', BABYLON.StandardMaterial.SpecularTextureEnabled, function (b) { BABYLON.StandardMaterial.SpecularTextureEnabled = b; });
  3415. _this._generateActionLine('Emissive Texture', BABYLON.StandardMaterial.EmissiveTextureEnabled, function (b) { BABYLON.StandardMaterial.EmissiveTextureEnabled = b; });
  3416. _this._generateActionLine('Bump Texture', BABYLON.StandardMaterial.BumpTextureEnabled, function (b) { BABYLON.StandardMaterial.BumpTextureEnabled = b; });
  3417. _this._generateActionLine('Opacity Texture', BABYLON.StandardMaterial.OpacityTextureEnabled, function (b) { BABYLON.StandardMaterial.OpacityTextureEnabled = b; });
  3418. _this._generateActionLine('Reflection Texture', BABYLON.StandardMaterial.ReflectionTextureEnabled, function (b) { BABYLON.StandardMaterial.ReflectionTextureEnabled = b; });
  3419. _this._generateActionLine('Refraction Texture', BABYLON.StandardMaterial.RefractionTextureEnabled, function (b) { BABYLON.StandardMaterial.RefractionTextureEnabled = b; });
  3420. _this._generateActionLine('ColorGrading', BABYLON.StandardMaterial.ColorGradingTextureEnabled, function (b) { BABYLON.StandardMaterial.ColorGradingTextureEnabled = b; });
  3421. _this._generateActionLine('Lightmap Texture', BABYLON.StandardMaterial.LightmapTextureEnabled, function (b) { BABYLON.StandardMaterial.LightmapTextureEnabled = b; });
  3422. _this._generateActionLine('Fresnel', BABYLON.StandardMaterial.FresnelEnabled, function (b) { BABYLON.StandardMaterial.FresnelEnabled = b; });
  3423. // Options
  3424. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3425. title.textContent = 'Options';
  3426. _this._generateActionLine('Animations', _this._inspector.scene.animationsEnabled, function (b) { _this._inspector.scene.animationsEnabled = b; });
  3427. _this._generateActionLine('Collisions', _this._inspector.scene.collisionsEnabled, function (b) { _this._inspector.scene.collisionsEnabled = b; });
  3428. _this._generateActionLine('Fog', _this._inspector.scene.fogEnabled, function (b) { _this._inspector.scene.fogEnabled = b; });
  3429. _this._generateActionLine('Lens flares', _this._inspector.scene.lensFlaresEnabled, function (b) { _this._inspector.scene.lensFlaresEnabled = b; });
  3430. _this._generateActionLine('Lights', _this._inspector.scene.lightsEnabled, function (b) { _this._inspector.scene.lightsEnabled = b; });
  3431. _this._generateActionLine('Particles', _this._inspector.scene.particlesEnabled, function (b) { _this._inspector.scene.particlesEnabled = b; });
  3432. _this._generateActionLine('Post-processes', _this._inspector.scene.postProcessesEnabled, function (b) { _this._inspector.scene.postProcessesEnabled = b; });
  3433. _this._generateActionLine('Probes', _this._inspector.scene.probesEnabled, function (b) { _this._inspector.scene.probesEnabled = b; });
  3434. _this._generateActionLine('Procedural textures', _this._inspector.scene.proceduralTexturesEnabled, function (b) { _this._inspector.scene.proceduralTexturesEnabled = b; });
  3435. _this._generateActionLine('Render targets', _this._inspector.scene.renderTargetsEnabled, function (b) { _this._inspector.scene.renderTargetsEnabled = b; });
  3436. _this._generateActionLine('Shadows', _this._inspector.scene.shadowsEnabled, function (b) { _this._inspector.scene.shadowsEnabled = b; });
  3437. _this._generateActionLine('Skeletons', _this._inspector.scene.skeletonsEnabled, function (b) { _this._inspector.scene.skeletonsEnabled = b; });
  3438. _this._generateActionLine('Sprites', _this._inspector.scene.spritesEnabled, function (b) { _this._inspector.scene.spritesEnabled = b; });
  3439. _this._generateActionLine('Textures', _this._inspector.scene.texturesEnabled, function (b) { _this._inspector.scene.texturesEnabled = b; });
  3440. // Audio
  3441. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3442. title.textContent = 'Audio';
  3443. var headphones = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3444. var normalSpeaker = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3445. _this._generateActionLine('Disable audio', !_this._inspector.scene.audioEnabled, function (b) { _this._inspector.scene.audioEnabled = !b; });
  3446. headphones.textContent = 'Headphones';
  3447. normalSpeaker.textContent = 'Normal speakers';
  3448. _this._generateRadioAction([headphones, normalSpeaker]);
  3449. if (_this._inspector.scene.headphone) {
  3450. headphones.classList.add('active');
  3451. }
  3452. else {
  3453. normalSpeaker.classList.add('active');
  3454. }
  3455. headphones.addEventListener('click', function () { _this._inspector.scene.headphone = true; });
  3456. normalSpeaker.addEventListener('click', function () { _this._inspector.scene.headphone = false; });
  3457. // Viewers
  3458. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3459. title.textContent = 'Viewer';
  3460. _this._generateActionLine('Skeletons', false, function (b) {
  3461. if (b) {
  3462. for (var index = 0; index < _this._inspector.scene.meshes.length; index++) {
  3463. var mesh = _this._inspector.scene.meshes[index];
  3464. if (mesh.skeleton) {
  3465. var found = false;
  3466. for (var sIndex = 0; sIndex < _this._skeletonViewers.length; sIndex++) {
  3467. if (_this._skeletonViewers[sIndex].skeleton === mesh.skeleton) {
  3468. found = true;
  3469. break;
  3470. }
  3471. }
  3472. if (found) {
  3473. continue;
  3474. }
  3475. var viewer = new BABYLON.Debug.SkeletonViewer(mesh.skeleton, mesh, _this._inspector.scene);
  3476. viewer.isEnabled = true;
  3477. _this._skeletonViewers.push(viewer);
  3478. }
  3479. }
  3480. }
  3481. else {
  3482. for (var index = 0; index < _this._skeletonViewers.length; index++) {
  3483. _this._skeletonViewers[index].dispose();
  3484. }
  3485. _this._skeletonViewers = [];
  3486. }
  3487. });
  3488. }
  3489. return _this;
  3490. }
  3491. /** Overrides super.dispose */
  3492. SceneTab.prototype.dispose = function () {
  3493. this._detailsPanel.dispose();
  3494. };
  3495. /** generates a div which correspond to an option that can be activated/deactivated */
  3496. SceneTab.prototype._generateActionLine = function (name, initValue, action) {
  3497. var div = INSPECTOR.Helpers.CreateDiv('scene-actions', this._actions);
  3498. div.textContent = name;
  3499. div.classList.add('action');
  3500. if (initValue) {
  3501. div.classList.add('active');
  3502. }
  3503. div.addEventListener('click', function (e) {
  3504. div.classList.toggle('active');
  3505. var isActivated = div.classList.contains('active');
  3506. action(isActivated);
  3507. });
  3508. };
  3509. /**
  3510. * Add a click action for all given elements :
  3511. * the clicked element is set as active, all others elements are deactivated
  3512. */
  3513. SceneTab.prototype._generateRadioAction = function (arr) {
  3514. var active = function (elem, evt) {
  3515. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  3516. var e = arr_1[_i];
  3517. e.classList.remove('active');
  3518. }
  3519. elem.classList.add('active');
  3520. };
  3521. for (var _i = 0, arr_2 = arr; _i < arr_2.length; _i++) {
  3522. var elem = arr_2[_i];
  3523. elem.addEventListener('click', active.bind(this, elem));
  3524. }
  3525. };
  3526. return SceneTab;
  3527. }(INSPECTOR.Tab));
  3528. INSPECTOR.SceneTab = SceneTab;
  3529. })(INSPECTOR || (INSPECTOR = {}));
  3530. var __extends = (this && this.__extends) || (function () {
  3531. var extendStatics = Object.setPrototypeOf ||
  3532. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3533. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3534. return function (d, b) {
  3535. extendStatics(d, b);
  3536. function __() { this.constructor = d; }
  3537. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3538. };
  3539. })();
  3540. var INSPECTOR;
  3541. (function (INSPECTOR) {
  3542. /**
  3543. * The console tab will have two features :
  3544. * - hook all console.log call and display them in this panel (and in the browser console as well)
  3545. * - display all Babylon logs (called with Tools.Log...)
  3546. */
  3547. var ConsoleTab = /** @class */ (function (_super) {
  3548. __extends(ConsoleTab, _super);
  3549. function ConsoleTab(tabbar, insp) {
  3550. var _this = _super.call(this, tabbar, 'Console') || this;
  3551. _this._inspector = insp;
  3552. // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
  3553. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3554. var consolePanel = INSPECTOR.Helpers.CreateDiv('console-panel');
  3555. var bjsPanel = INSPECTOR.Helpers.CreateDiv('console-panel');
  3556. _this._panel.appendChild(consolePanel);
  3557. _this._panel.appendChild(bjsPanel);
  3558. Split([consolePanel, bjsPanel], {
  3559. blockDrag: _this._inspector.popupMode,
  3560. sizes: [50, 50],
  3561. direction: 'vertical'
  3562. });
  3563. // Titles
  3564. var title = INSPECTOR.Helpers.CreateDiv('console-panel-title', consolePanel);
  3565. title.textContent = 'Console logs';
  3566. title = INSPECTOR.Helpers.CreateDiv('console-panel-title', bjsPanel);
  3567. title.textContent = 'Babylon.js logs';
  3568. // Contents
  3569. _this._consolePanelContent = INSPECTOR.Helpers.CreateDiv('console-panel-content', consolePanel);
  3570. _this._bjsPanelContent = INSPECTOR.Helpers.CreateDiv('console-panel-content', bjsPanel);
  3571. // Bjs logs
  3572. _this._bjsPanelContent.innerHTML = BABYLON.Tools.LogCache;
  3573. BABYLON.Tools.OnNewCacheEntry = function (entry) {
  3574. _this._bjsPanelContent.innerHTML += entry;
  3575. _this._bjsPanelContent.scrollTop = _this._bjsPanelContent.scrollHeight;
  3576. };
  3577. return _this;
  3578. // Testing
  3579. //console.log("This is a console.log message");
  3580. // console.log("That's right, console.log calls are hooked to be written in this window");
  3581. // console.log("Object are also stringify-ed", {width:10, height:30, shape:'rectangular'});
  3582. // console.warn("This is a console.warn message");
  3583. // console.error("This is a console.error message");
  3584. // BABYLON.Tools.Log("This is a message");
  3585. // BABYLON.Tools.Warn("This is a warning");
  3586. // BABYLON.Tools.Error("This is a error");
  3587. }
  3588. /** Overrides super.dispose */
  3589. ConsoleTab.prototype.dispose = function () {
  3590. console.log = this._oldConsoleLog;
  3591. console.warn = this._oldConsoleWarn;
  3592. console.error = this._oldConsoleError;
  3593. };
  3594. ConsoleTab.prototype.active = function (b) {
  3595. _super.prototype.active.call(this, b);
  3596. if (b) {
  3597. // save old console.log
  3598. this._oldConsoleLog = console.log;
  3599. this._oldConsoleWarn = console.warn;
  3600. this._oldConsoleError = console.error;
  3601. console.log = this._addConsoleLog.bind(this);
  3602. console.warn = this._addConsoleWarn.bind(this);
  3603. console.error = this._addConsoleError.bind(this);
  3604. }
  3605. };
  3606. ConsoleTab.prototype._message = function (type, message, caller) {
  3607. var callerLine = INSPECTOR.Helpers.CreateDiv('caller', this._consolePanelContent);
  3608. callerLine.textContent = caller.replace(' ', '\u00A0');
  3609. var line = INSPECTOR.Helpers.CreateDiv(type, this._consolePanelContent);
  3610. line.textContent = message.replace(' ', '\u00A0');
  3611. this._consolePanelContent.scrollTop = this._consolePanelContent.scrollHeight;
  3612. };
  3613. ConsoleTab.prototype._addConsoleLog = function () {
  3614. var params = [];
  3615. for (var _i = 0; _i < arguments.length; _i++) {
  3616. params[_i] = arguments[_i];
  3617. }
  3618. // Get caller name if not null
  3619. var callerFunc = this._addConsoleLog.caller;
  3620. var caller = callerFunc == null ? "Window" : "Function " + callerFunc['name'] + ": ";
  3621. for (var i = 0; i < params.length; i++) {
  3622. this._message('log', params[i], caller);
  3623. // Write again in console does not work on edge, as the console object
  3624. // is not instantiate if debugger tools is not open
  3625. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3626. this._oldConsoleLog(params[i]);
  3627. }
  3628. }
  3629. };
  3630. ConsoleTab.prototype._addConsoleWarn = function () {
  3631. var params = [];
  3632. for (var _i = 0; _i < arguments.length; _i++) {
  3633. params[_i] = arguments[_i];
  3634. }
  3635. // Get caller name if not null
  3636. var callerFunc = this._addConsoleLog.caller;
  3637. var caller = callerFunc == null ? "Window" : callerFunc['name'];
  3638. for (var i = 0; i < params.length; i++) {
  3639. this._message('warn', params[i], caller);
  3640. // Write again in console does not work on edge, as the console object
  3641. // is not instantiate if debugger tools is not open
  3642. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3643. this._oldConsoleWarn(params[i]);
  3644. }
  3645. }
  3646. };
  3647. ConsoleTab.prototype._addConsoleError = function () {
  3648. var params = [];
  3649. for (var _i = 0; _i < arguments.length; _i++) {
  3650. params[_i] = arguments[_i];
  3651. }
  3652. // Get caller name if not null
  3653. var callerFunc = this._addConsoleLog.caller;
  3654. var caller = callerFunc == null ? "Window" : callerFunc['name'];
  3655. for (var i = 0; i < params.length; i++) {
  3656. this._message('error', params[i], caller);
  3657. // Write again in console does not work on edge, as the console object
  3658. // is not instantiate if debugger tools is not open
  3659. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3660. this._oldConsoleError(params[i]);
  3661. }
  3662. }
  3663. };
  3664. return ConsoleTab;
  3665. }(INSPECTOR.Tab));
  3666. INSPECTOR.ConsoleTab = ConsoleTab;
  3667. })(INSPECTOR || (INSPECTOR = {}));
  3668. var __extends = (this && this.__extends) || (function () {
  3669. var extendStatics = Object.setPrototypeOf ||
  3670. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3671. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3672. return function (d, b) {
  3673. extendStatics(d, b);
  3674. function __() { this.constructor = d; }
  3675. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3676. };
  3677. })();
  3678. var INSPECTOR;
  3679. (function (INSPECTOR) {
  3680. var StatsTab = /** @class */ (function (_super) {
  3681. __extends(StatsTab, _super);
  3682. function StatsTab(tabbar, insp) {
  3683. var _this = _super.call(this, tabbar, 'Stats') || this;
  3684. /**
  3685. * Properties in this array will be updated
  3686. * in a render loop - Mostly stats properties
  3687. */
  3688. _this._updatableProperties = [];
  3689. _this._inspector = insp;
  3690. _this._scene = _this._inspector.scene;
  3691. _this._engine = _this._scene.getEngine();
  3692. _this._glInfo = _this._engine.getGlInfo();
  3693. _this._connectToInstrumentation();
  3694. // Build the stats panel: a div that will contains all stats
  3695. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3696. _this._panel.classList.add("stats-panel");
  3697. var title = INSPECTOR.Helpers.CreateDiv('stat-title1', _this._panel);
  3698. var fpsSpan = INSPECTOR.Helpers.CreateElement('span', 'stats-fps');
  3699. _this._updatableProperties.push({
  3700. elem: fpsSpan,
  3701. updateFct: function () { return BABYLON.Tools.Format(_this._inspector.scene.getEngine().getFps(), 0) + " fps"; }
  3702. });
  3703. var versionSpan = INSPECTOR.Helpers.CreateElement('span');
  3704. versionSpan.textContent = "Babylon.js v" + BABYLON.Engine.Version + " - ";
  3705. title.appendChild(versionSpan);
  3706. title.appendChild(fpsSpan);
  3707. _this._updateLoopHandler = _this._update.bind(_this);
  3708. _this._refreshRateCounter = 0;
  3709. _this.refreshRate = 4;
  3710. // Count block
  3711. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3712. title.textContent = "Count";
  3713. {
  3714. _this._createStatLabel("Total meshes", _this._panel);
  3715. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3716. _this._updatableProperties.push({
  3717. elem: elemValue,
  3718. updateFct: function () { return _this._scene.meshes.length.toString(); }
  3719. });
  3720. _this._createStatLabel("Draw calls", _this._panel);
  3721. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3722. _this._updatableProperties.push({
  3723. elem: elemValue,
  3724. updateFct: function () { return _this._sceneInstrumentation.drawCallsCounter.current.toString(); }
  3725. });
  3726. _this._createStatLabel("Texture collisions", _this._panel);
  3727. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3728. _this._updatableProperties.push({
  3729. elem: elemValue,
  3730. updateFct: function () { return _this._sceneInstrumentation.textureCollisionsCounter.current.toString(); }
  3731. });
  3732. _this._createStatLabel("Total lights", _this._panel);
  3733. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3734. _this._updatableProperties.push({
  3735. elem: elemValue,
  3736. updateFct: function () { return _this._scene.lights.length.toString(); }
  3737. });
  3738. _this._createStatLabel("Total vertices", _this._panel);
  3739. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3740. _this._updatableProperties.push({
  3741. elem: elemValue,
  3742. updateFct: function () { return _this._scene.getTotalVertices().toString(); }
  3743. });
  3744. _this._createStatLabel("Total materials", _this._panel);
  3745. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3746. _this._updatableProperties.push({
  3747. elem: elemValue,
  3748. updateFct: function () { return _this._scene.materials.length.toString(); }
  3749. });
  3750. _this._createStatLabel("Total textures", _this._panel);
  3751. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3752. _this._updatableProperties.push({
  3753. elem: elemValue,
  3754. updateFct: function () { return _this._scene.textures.length.toString(); }
  3755. });
  3756. _this._createStatLabel("Active meshes", _this._panel);
  3757. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3758. _this._updatableProperties.push({
  3759. elem: elemValue,
  3760. updateFct: function () { return _this._scene.getActiveMeshes().length.toString(); }
  3761. });
  3762. _this._createStatLabel("Active indices", _this._panel);
  3763. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3764. _this._updatableProperties.push({
  3765. elem: elemValue,
  3766. updateFct: function () { return _this._scene.getActiveIndices().toString(); }
  3767. });
  3768. _this._createStatLabel("Active bones", _this._panel);
  3769. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3770. _this._updatableProperties.push({
  3771. elem: elemValue,
  3772. updateFct: function () { return _this._scene.getActiveBones().toString(); }
  3773. });
  3774. _this._createStatLabel("Active particles", _this._panel);
  3775. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3776. _this._updatableProperties.push({
  3777. elem: elemValue,
  3778. updateFct: function () { return _this._scene.getActiveParticles().toString(); }
  3779. });
  3780. }
  3781. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3782. title.textContent = "Duration";
  3783. {
  3784. _this._createStatLabel("Properties refresh rate (per second)", _this._panel);
  3785. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3786. _this._inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  3787. _this._inputElement.value = _this.refreshRate;
  3788. elemValue.appendChild(_this._inputElement);
  3789. _this._inputElement.addEventListener('keyup', function (evt) {
  3790. _this.refreshRate = _this._inputElement.value;
  3791. });
  3792. _this._createStatLabel("Meshes selection", _this._panel);
  3793. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3794. _this._updatableProperties.push({
  3795. elem: elemValue,
  3796. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.activeMeshesEvaluationTimeCounter.current); }
  3797. });
  3798. _this._createStatLabel("Render targets", _this._panel);
  3799. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3800. _this._updatableProperties.push({
  3801. elem: elemValue,
  3802. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.renderTargetsRenderTimeCounter.current); }
  3803. });
  3804. _this._createStatLabel("Particles", _this._panel);
  3805. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3806. _this._updatableProperties.push({
  3807. elem: elemValue,
  3808. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.particlesRenderTimeCounter.current); }
  3809. });
  3810. _this._createStatLabel("Sprites", _this._panel);
  3811. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3812. _this._updatableProperties.push({
  3813. elem: elemValue,
  3814. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.spritesRenderTimeCounter.current); }
  3815. });
  3816. _this._createStatLabel("Animations", _this._panel);
  3817. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3818. _this._updatableProperties.push({
  3819. elem: elemValue,
  3820. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.animationsTimeCounter.current); }
  3821. });
  3822. _this._createStatLabel("Physics", _this._panel);
  3823. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3824. _this._updatableProperties.push({
  3825. elem: elemValue,
  3826. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.physicsTimeCounter.current); }
  3827. });
  3828. _this._createStatLabel("Render", _this._panel);
  3829. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3830. _this._updatableProperties.push({
  3831. elem: elemValue,
  3832. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.renderTimeCounter.current); }
  3833. });
  3834. _this._createStatLabel("Frame", _this._panel);
  3835. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3836. _this._updatableProperties.push({
  3837. elem: elemValue,
  3838. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.frameTimeCounter.current); }
  3839. });
  3840. _this._createStatLabel("Inter-frame", _this._panel);
  3841. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3842. _this._updatableProperties.push({
  3843. elem: elemValue,
  3844. updateFct: function () { return BABYLON.Tools.Format(_this._sceneInstrumentation.interFrameTimeCounter.current); }
  3845. });
  3846. _this._createStatLabel("GPU Frame time", _this._panel);
  3847. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3848. _this._updatableProperties.push({
  3849. elem: elemValue,
  3850. updateFct: function () { return BABYLON.Tools.Format(_this._engineInstrumentation.gpuFrameTimeCounter.current * 0.000001); }
  3851. });
  3852. _this._createStatLabel("GPU Frame time (average)", _this._panel);
  3853. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3854. _this._updatableProperties.push({
  3855. elem: elemValue,
  3856. updateFct: function () { return BABYLON.Tools.Format(_this._engineInstrumentation.gpuFrameTimeCounter.average * 0.000001); }
  3857. });
  3858. _this._createStatLabel("Potential FPS", _this._panel);
  3859. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3860. _this._updatableProperties.push({
  3861. elem: elemValue,
  3862. updateFct: function () { return BABYLON.Tools.Format(1000.0 / _this._sceneInstrumentation.frameTimeCounter.current, 0); }
  3863. });
  3864. _this._createStatLabel("Resolution", _this._panel);
  3865. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3866. _this._updatableProperties.push({
  3867. elem: elemValue,
  3868. updateFct: function () { return _this._engine.getRenderWidth() + "x" + _this._engine.getRenderHeight(); }
  3869. });
  3870. }
  3871. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3872. title.textContent = "Extensions";
  3873. {
  3874. _this._createStatLabel("Std derivatives", _this._panel);
  3875. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3876. _this._updatableProperties.push({
  3877. elem: elemValue,
  3878. updateFct: function () { return (_this._engine.getCaps().standardDerivatives ? "Yes" : "No"); }
  3879. });
  3880. _this._createStatLabel("Compressed textures", _this._panel);
  3881. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3882. _this._updatableProperties.push({
  3883. elem: elemValue,
  3884. updateFct: function () { return (_this._engine.getCaps().s3tc ? "Yes" : "No"); }
  3885. });
  3886. _this._createStatLabel("Hardware instances", _this._panel);
  3887. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3888. _this._updatableProperties.push({
  3889. elem: elemValue,
  3890. updateFct: function () { return (_this._engine.getCaps().instancedArrays ? "Yes" : "No"); }
  3891. });
  3892. _this._createStatLabel("Texture float", _this._panel);
  3893. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3894. _this._updatableProperties.push({
  3895. elem: elemValue,
  3896. updateFct: function () { return (_this._engine.getCaps().textureFloat ? "Yes" : "No"); }
  3897. });
  3898. _this._createStatLabel("32bits indices", _this._panel);
  3899. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3900. _this._updatableProperties.push({
  3901. elem: elemValue,
  3902. updateFct: function () { return (_this._engine.getCaps().uintIndices ? "Yes" : "No"); }
  3903. });
  3904. _this._createStatLabel("Fragment depth", _this._panel);
  3905. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3906. _this._updatableProperties.push({
  3907. elem: elemValue,
  3908. updateFct: function () { return (_this._engine.getCaps().fragmentDepthSupported ? "Yes" : "No"); }
  3909. });
  3910. _this._createStatLabel("High precision shaders", _this._panel);
  3911. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3912. _this._updatableProperties.push({
  3913. elem: elemValue,
  3914. updateFct: function () { return (_this._engine.getCaps().highPrecisionShaderSupported ? "Yes" : "No"); }
  3915. });
  3916. _this._createStatLabel("Draw buffers", _this._panel);
  3917. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3918. _this._updatableProperties.push({
  3919. elem: elemValue,
  3920. updateFct: function () { return (_this._engine.getCaps().drawBuffersExtension ? "Yes" : "No"); }
  3921. });
  3922. _this._createStatLabel("Vertex array object", _this._panel);
  3923. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3924. _this._updatableProperties.push({
  3925. elem: elemValue,
  3926. updateFct: function () { return (_this._engine.getCaps().vertexArrayObject ? "Yes" : "No"); }
  3927. });
  3928. _this._createStatLabel("Timer query", _this._panel);
  3929. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3930. _this._updatableProperties.push({
  3931. elem: elemValue,
  3932. updateFct: function () { return (_this._engine.getCaps().timerQuery ? "Yes" : "No"); }
  3933. });
  3934. }
  3935. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3936. title.textContent = "Caps.";
  3937. {
  3938. _this._createStatLabel("Stencil", _this._panel);
  3939. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3940. _this._updatableProperties.push({
  3941. elem: elemValue,
  3942. updateFct: function () { return (_this._engine.isStencilEnable ? "Enabled" : "Disabled"); }
  3943. });
  3944. _this._createStatLabel("Max textures units", _this._panel);
  3945. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3946. _this._updatableProperties.push({
  3947. elem: elemValue,
  3948. updateFct: function () { return _this._engine.getCaps().maxTexturesImageUnits.toString(); }
  3949. });
  3950. _this._createStatLabel("Max textures size", _this._panel);
  3951. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3952. _this._updatableProperties.push({
  3953. elem: elemValue,
  3954. updateFct: function () { return _this._engine.getCaps().maxTextureSize.toString(); }
  3955. });
  3956. _this._createStatLabel("Max anisotropy", _this._panel);
  3957. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3958. _this._updatableProperties.push({
  3959. elem: elemValue,
  3960. updateFct: function () { return _this._engine.getCaps().maxAnisotropy.toString(); }
  3961. });
  3962. }
  3963. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3964. title.textContent = "Info";
  3965. {
  3966. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-infos', _this._panel);
  3967. _this._updatableProperties.push({
  3968. elem: elemValue,
  3969. updateFct: function () { return "WebGL v" + _this._engine.webGLVersion + " - " + _this._glInfo.version + " - " + _this._glInfo.renderer; }
  3970. });
  3971. }
  3972. return _this;
  3973. }
  3974. StatsTab.prototype._connectToInstrumentation = function () {
  3975. if (this._sceneInstrumentation) {
  3976. return;
  3977. }
  3978. this._sceneInstrumentation = new BABYLON.SceneInstrumentation(this._scene);
  3979. this._sceneInstrumentation.captureActiveMeshesEvaluationTime = true;
  3980. this._sceneInstrumentation.captureRenderTargetsRenderTime = true;
  3981. this._sceneInstrumentation.captureFrameTime = true;
  3982. this._sceneInstrumentation.captureRenderTime = true;
  3983. this._sceneInstrumentation.captureInterFrameTime = true;
  3984. this._sceneInstrumentation.captureParticlesRenderTime = true;
  3985. this._sceneInstrumentation.captureSpritesRenderTime = true;
  3986. this._sceneInstrumentation.capturePhysicsTime = true;
  3987. this._sceneInstrumentation.captureAnimationsTime = true;
  3988. this._engineInstrumentation = new BABYLON.EngineInstrumentation(this._engine);
  3989. this._engineInstrumentation.captureGPUFrameTime = true;
  3990. };
  3991. StatsTab.prototype._createStatLabel = function (content, parent) {
  3992. var elem = INSPECTOR.Helpers.CreateDiv('stat-label', parent);
  3993. elem.textContent = content;
  3994. return elem;
  3995. };
  3996. /** Update each properties of the stats panel */
  3997. StatsTab.prototype._update = function () {
  3998. if (this._refreshRateCounter > 1) {
  3999. this._refreshRateCounter--;
  4000. }
  4001. else {
  4002. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  4003. var prop = _a[_i];
  4004. prop.elem.textContent = prop.updateFct();
  4005. }
  4006. if (this._inspector.scene.getEngine().getFps() / this.refreshRate == Infinity) {
  4007. this._refreshRateCounter = 1;
  4008. }
  4009. else {
  4010. this._refreshRateCounter = this._inspector.scene.getEngine().getFps() / this.refreshRate;
  4011. }
  4012. }
  4013. };
  4014. StatsTab.prototype.dispose = function () {
  4015. this._scene.unregisterAfterRender(this._updateLoopHandler);
  4016. this._sceneInstrumentation.dispose();
  4017. this._sceneInstrumentation = null;
  4018. this._engineInstrumentation.dispose();
  4019. this._engineInstrumentation = null;
  4020. };
  4021. StatsTab.prototype.active = function (b) {
  4022. _super.prototype.active.call(this, b);
  4023. if (b) {
  4024. this._connectToInstrumentation();
  4025. this._scene.registerAfterRender(this._updateLoopHandler);
  4026. }
  4027. };
  4028. return StatsTab;
  4029. }(INSPECTOR.Tab));
  4030. INSPECTOR.StatsTab = StatsTab;
  4031. })(INSPECTOR || (INSPECTOR = {}));
  4032. /// <reference path="../../../dist/preview release/gltf2Interface/babylon.glTF2Interface.d.ts"/>
  4033. /// <reference path="../../../dist/preview release/loaders/babylon.glTF2FileLoader.d.ts"/>
  4034. /// <reference path="../../../dist/preview release/serializers/babylon.glTF2Serializer.d.ts"/>
  4035. var __extends = (this && this.__extends) || (function () {
  4036. var extendStatics = Object.setPrototypeOf ||
  4037. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4038. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4039. return function (d, b) {
  4040. extendStatics(d, b);
  4041. function __() { this.constructor = d; }
  4042. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4043. };
  4044. })();
  4045. var INSPECTOR;
  4046. (function (INSPECTOR) {
  4047. ;
  4048. var GLTFTab = /** @class */ (function (_super) {
  4049. __extends(GLTFTab, _super);
  4050. function GLTFTab(tabbar, inspector) {
  4051. var _this = _super.call(this, tabbar, 'GLTF') || this;
  4052. _this._detailsPanel = null;
  4053. _this._inspector = inspector;
  4054. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  4055. _this._actions = INSPECTOR.Helpers.CreateDiv('gltf-actions', _this._panel);
  4056. _this._actions.addEventListener('click', function (event) {
  4057. _this._closeDetailsPanel();
  4058. });
  4059. if (BABYLON.SceneLoader && BABYLON.GLTFFileLoader && BABYLON.GLTF2.GLTFLoader) {
  4060. _this._addImport();
  4061. }
  4062. if (BABYLON.GLTF2Export) {
  4063. _this._addExport();
  4064. }
  4065. return _this;
  4066. }
  4067. Object.defineProperty(GLTFTab, "IsSupported", {
  4068. get: function () {
  4069. return !!(BABYLON.SceneLoader && BABYLON.GLTFFileLoader && BABYLON.GLTF2.GLTFLoader) || !!BABYLON.GLTF2Export;
  4070. },
  4071. enumerable: true,
  4072. configurable: true
  4073. });
  4074. /** @hidden */
  4075. GLTFTab._Initialize = function () {
  4076. // Must register with OnPluginActivatedObservable as early as possible to
  4077. // override the default settings for each extension.
  4078. BABYLON.SceneLoader.OnPluginActivatedObservable.add(function (loader) {
  4079. if (loader.name === "gltf" && GLTFTab._LoaderExtensionSettings) {
  4080. loader.onExtensionLoadedObservable.add(function (extension) {
  4081. var settings = GLTFTab._LoaderExtensionSettings[extension.name];
  4082. for (var settingName in settings) {
  4083. extension[settingName] = settings[settingName];
  4084. }
  4085. });
  4086. }
  4087. });
  4088. };
  4089. GLTFTab.prototype.dispose = function () {
  4090. if (this._detailsPanel) {
  4091. this._detailsPanel.dispose();
  4092. }
  4093. };
  4094. GLTFTab.prototype._addImport = function () {
  4095. var _this = this;
  4096. var importActions = INSPECTOR.Helpers.CreateDiv(null, this._actions);
  4097. this._getLoaderExtensionOverridesAsync().then(function (loaderExtensionSettings) {
  4098. var title = INSPECTOR.Helpers.CreateDiv('gltf-title', importActions);
  4099. title.textContent = 'Import';
  4100. var extensionActions = INSPECTOR.Helpers.CreateDiv('gltf-actions', importActions);
  4101. var extensionsTitle = INSPECTOR.Helpers.CreateDiv('gltf-title', extensionActions);
  4102. extensionsTitle.textContent = "Extensions";
  4103. var _loop_1 = function (extensionName) {
  4104. var settings = loaderExtensionSettings[extensionName];
  4105. var extensionAction = INSPECTOR.Helpers.CreateDiv('gltf-action', extensionActions);
  4106. extensionAction.addEventListener('click', function (event) {
  4107. if (_this._updateLoaderExtensionDetails(settings)) {
  4108. event.stopPropagation();
  4109. }
  4110. });
  4111. var checkbox = INSPECTOR.Helpers.CreateElement('span', 'gltf-checkbox', extensionAction);
  4112. if (settings.enabled) {
  4113. checkbox.classList.add('action', 'active');
  4114. }
  4115. checkbox.addEventListener('click', function () {
  4116. checkbox.classList.toggle('active');
  4117. settings.enabled = checkbox.classList.contains('active');
  4118. });
  4119. var label = INSPECTOR.Helpers.CreateElement('span', null, extensionAction);
  4120. label.textContent = extensionName;
  4121. };
  4122. for (var extensionName in loaderExtensionSettings) {
  4123. _loop_1(extensionName);
  4124. }
  4125. });
  4126. };
  4127. GLTFTab.prototype._getLoaderExtensionOverridesAsync = function () {
  4128. if (GLTFTab._LoaderExtensionSettings) {
  4129. return Promise.resolve(GLTFTab._LoaderExtensionSettings);
  4130. }
  4131. var loaderExtensionSettings = {};
  4132. var engine = new BABYLON.NullEngine();
  4133. var scene = new BABYLON.Scene(engine);
  4134. var loader = new BABYLON.GLTF2.GLTFLoader();
  4135. loader.onExtensionLoadedObservable.add(function (extension) {
  4136. loaderExtensionSettings[extension.name] = {};
  4137. var settings = loaderExtensionSettings[extension.name];
  4138. for (var _i = 0, _a = Object.keys(extension); _i < _a.length; _i++) {
  4139. var key = _a[_i];
  4140. if (key !== "name" && key[0] !== '_') {
  4141. var value = extension[key];
  4142. if (typeof value !== "object") {
  4143. settings[key] = value;
  4144. }
  4145. }
  4146. }
  4147. });
  4148. var data = { json: {}, bin: null };
  4149. return loader.importMeshAsync([], scene, data, "").then(function () {
  4150. scene.dispose();
  4151. engine.dispose();
  4152. return (GLTFTab._LoaderExtensionSettings = loaderExtensionSettings);
  4153. });
  4154. };
  4155. GLTFTab.prototype._updateLoaderExtensionDetails = function (settings) {
  4156. if (Object.keys(settings).length === 1) {
  4157. return false;
  4158. }
  4159. if (!this._detailsPanel) {
  4160. this._detailsPanel = new INSPECTOR.DetailPanel();
  4161. this._panel.appendChild(this._detailsPanel.toHtml());
  4162. this._split = Split([this._actions, this._detailsPanel.toHtml()], {
  4163. blockDrag: this._inspector.popupMode,
  4164. sizes: [50, 50],
  4165. direction: 'vertical'
  4166. });
  4167. }
  4168. this._detailsPanel.clean();
  4169. var details = new Array();
  4170. for (var key in settings) {
  4171. if (key !== "enabled") {
  4172. details.push(new INSPECTOR.PropertyLine(new INSPECTOR.Property(key, settings)));
  4173. }
  4174. }
  4175. this._detailsPanel.details = details;
  4176. return true;
  4177. };
  4178. GLTFTab.prototype._closeDetailsPanel = function () {
  4179. if (this._detailsPanel) {
  4180. this._detailsPanel.toHtml().remove();
  4181. this._detailsPanel.dispose();
  4182. this._detailsPanel = null;
  4183. }
  4184. if (this._split) {
  4185. this._split.destroy();
  4186. delete this._split;
  4187. }
  4188. };
  4189. GLTFTab.prototype._addExport = function () {
  4190. var _this = this;
  4191. var exportActions = INSPECTOR.Helpers.CreateDiv(null, this._actions);
  4192. var title = INSPECTOR.Helpers.CreateDiv('gltf-title', exportActions);
  4193. title.textContent = 'Export';
  4194. var name = INSPECTOR.Helpers.CreateInput('gltf-input', exportActions);
  4195. name.placeholder = "File name...";
  4196. var button = INSPECTOR.Helpers.CreateElement('button', 'gltf-button', exportActions);
  4197. button.innerText = 'Export GLB';
  4198. button.addEventListener('click', function () {
  4199. BABYLON.GLTF2Export.GLBAsync(_this._inspector.scene, name.value || "scene", {
  4200. shouldExportTransformNode: function (transformNode) { return !GLTFTab._IsSkyBox(transformNode); }
  4201. }).then(function (glb) {
  4202. glb.downloadFiles();
  4203. });
  4204. });
  4205. };
  4206. GLTFTab._IsSkyBox = function (transformNode) {
  4207. if (transformNode instanceof BABYLON.Mesh) {
  4208. if (transformNode.material) {
  4209. var material = transformNode.material;
  4210. var reflectionTexture = material.reflectionTexture;
  4211. if (reflectionTexture && reflectionTexture.coordinatesMode === BABYLON.Texture.SKYBOX_MODE) {
  4212. return true;
  4213. }
  4214. }
  4215. }
  4216. return false;
  4217. };
  4218. GLTFTab._LoaderExtensionSettings = null;
  4219. return GLTFTab;
  4220. }(INSPECTOR.Tab));
  4221. INSPECTOR.GLTFTab = GLTFTab;
  4222. GLTFTab._Initialize();
  4223. })(INSPECTOR || (INSPECTOR = {}));
  4224. var __extends = (this && this.__extends) || (function () {
  4225. var extendStatics = Object.setPrototypeOf ||
  4226. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4227. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4228. return function (d, b) {
  4229. extendStatics(d, b);
  4230. function __() { this.constructor = d; }
  4231. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4232. };
  4233. })();
  4234. var INSPECTOR;
  4235. (function (INSPECTOR) {
  4236. var ToolsTab = /** @class */ (function (_super) {
  4237. __extends(ToolsTab, _super);
  4238. function ToolsTab(tabbar, insp) {
  4239. var _this = _super.call(this, tabbar, 'Tools') || this;
  4240. _this._inspector = insp;
  4241. _this._scene = _this._inspector.scene;
  4242. // Build the tools panel: a div that will contains all tools
  4243. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  4244. _this._panel.classList.add("tools-panel");
  4245. var title = INSPECTOR.Helpers.CreateDiv('tool-title1', _this._panel);
  4246. var versionSpan = INSPECTOR.Helpers.CreateElement('span');
  4247. versionSpan.textContent = "Babylon.js v" + BABYLON.Engine.Version + " - Tools";
  4248. title.appendChild(versionSpan);
  4249. // Environment block
  4250. title = INSPECTOR.Helpers.CreateDiv('tool-title2', _this._panel);
  4251. title.textContent = "Environment Texture (.dds, .env)";
  4252. {
  4253. var errorElemm_1 = INSPECTOR.Inspector.DOCUMENT.createElement('div');
  4254. errorElemm_1.className = "tool-label-error";
  4255. errorElemm_1.style.display = "none";
  4256. var elemValue = INSPECTOR.Helpers.CreateDiv(null, _this._panel);
  4257. var inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  4258. inputElement.className = "tool-input";
  4259. inputElement.type = "file";
  4260. inputElement.accept = ".dds, .env";
  4261. inputElement.onchange = function (event) {
  4262. var files = event.target.files;
  4263. var file = null;
  4264. if (files && files.length) {
  4265. file = files[0];
  4266. }
  4267. if (!file) {
  4268. errorElemm_1.style.display = "block";
  4269. errorElemm_1.textContent = "Please, select a file first.";
  4270. return;
  4271. }
  4272. var isFileDDS = file.name.toLowerCase().indexOf(".dds") > 0;
  4273. var isFileEnv = file.name.toLowerCase().indexOf(".env") > 0;
  4274. if (!isFileDDS && !isFileEnv) {
  4275. errorElemm_1.style.display = "block";
  4276. errorElemm_1.textContent = "Please, select a dds or env file.";
  4277. return;
  4278. }
  4279. BABYLON.Tools.ReadFile(file, function (data) {
  4280. var blob = new Blob([data], { type: "octet/stream" });
  4281. var url = URL.createObjectURL(blob);
  4282. if (isFileDDS) {
  4283. _this._scene.environmentTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(url, _this._scene, ".dds");
  4284. errorElemm_1.style.display = "none";
  4285. }
  4286. else {
  4287. _this._scene.environmentTexture = new BABYLON.CubeTexture(url, _this._scene, undefined, undefined, undefined, function () {
  4288. errorElemm_1.style.display = "none";
  4289. }, function (message) {
  4290. if (message) {
  4291. errorElemm_1.style.display = "block";
  4292. errorElemm_1.textContent = message;
  4293. }
  4294. }, undefined, undefined, ".env");
  4295. }
  4296. }, undefined, true);
  4297. };
  4298. elemValue.appendChild(inputElement);
  4299. if (!_this._scene.getEngine().premultipliedAlpha) {
  4300. elemValue = INSPECTOR.Helpers.CreateDiv(null, _this._panel);
  4301. inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  4302. inputElement.value = "Compress current texture to .env";
  4303. inputElement.className = "tool-input";
  4304. inputElement.type = "button";
  4305. inputElement.onclick = function () {
  4306. if (!_this._scene.environmentTexture) {
  4307. errorElemm_1.style.display = "block";
  4308. errorElemm_1.textContent = "You must load an environment texture first.";
  4309. return;
  4310. }
  4311. if (_this._scene.activeCamera) {
  4312. BABYLON.EnvironmentTextureTools.CreateEnvTextureAsync(_this._scene.environmentTexture)
  4313. .then(function (buffer) {
  4314. var blob = new Blob([buffer], { type: "octet/stream" });
  4315. BABYLON.Tools.Download(blob, "environment.env");
  4316. errorElemm_1.style.display = "none";
  4317. })
  4318. .catch(function (error) {
  4319. errorElemm_1.style.display = "block";
  4320. errorElemm_1.textContent = error;
  4321. });
  4322. }
  4323. else {
  4324. errorElemm_1.style.display = "block";
  4325. errorElemm_1.textContent = "An active camera is required.";
  4326. }
  4327. };
  4328. elemValue.appendChild(inputElement);
  4329. }
  4330. _this._panel.appendChild(errorElemm_1);
  4331. }
  4332. title = INSPECTOR.Helpers.CreateDiv('tool-title2', _this._panel);
  4333. title.textContent = "Capture";
  4334. {
  4335. var elemValue = INSPECTOR.Helpers.CreateDiv(null, _this._panel);
  4336. var inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  4337. inputElement.value = "Take Screenshot";
  4338. inputElement.type = "button";
  4339. inputElement.className = "tool-input";
  4340. inputElement.onclick = function () {
  4341. if (_this._scene.activeCamera) {
  4342. BABYLON.Tools.CreateScreenshot(_this._scene.getEngine(), _this._scene.activeCamera, { precision: 0.5 });
  4343. }
  4344. };
  4345. elemValue.appendChild(inputElement);
  4346. }
  4347. return _this;
  4348. }
  4349. ToolsTab.prototype.dispose = function () {
  4350. // Nothing to dispose
  4351. };
  4352. return ToolsTab;
  4353. }(INSPECTOR.Tab));
  4354. INSPECTOR.ToolsTab = ToolsTab;
  4355. })(INSPECTOR || (INSPECTOR = {}));
  4356. var __extends = (this && this.__extends) || (function () {
  4357. var extendStatics = Object.setPrototypeOf ||
  4358. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4359. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4360. return function (d, b) {
  4361. extendStatics(d, b);
  4362. function __() { this.constructor = d; }
  4363. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4364. };
  4365. })();
  4366. var INSPECTOR;
  4367. (function (INSPECTOR) {
  4368. /**
  4369. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  4370. * The default active tab is the first one of the list.
  4371. */
  4372. var TabBar = /** @class */ (function (_super) {
  4373. __extends(TabBar, _super);
  4374. function TabBar(inspector, initialTab) {
  4375. var _this = _super.call(this) || this;
  4376. // The list of available tabs
  4377. _this._tabs = [];
  4378. /** The list of tab displayed by clicking on the remainingIcon */
  4379. _this._invisibleTabs = [];
  4380. /** The list of tabs visible, displayed in the tab bar */
  4381. _this._visibleTabs = [];
  4382. _this._inspector = inspector;
  4383. _this._tabs.push(new INSPECTOR.SceneTab(_this, _this._inspector));
  4384. _this._tabs.push(new INSPECTOR.ConsoleTab(_this, _this._inspector));
  4385. _this._tabs.push(new INSPECTOR.StatsTab(_this, _this._inspector));
  4386. _this._meshTab = new INSPECTOR.MeshTab(_this, _this._inspector);
  4387. _this._tabs.push(new INSPECTOR.TextureTab(_this, _this._inspector));
  4388. _this._tabs.push(_this._meshTab);
  4389. _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
  4390. _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
  4391. if (INSPECTOR.GLTFTab.IsSupported) {
  4392. _this._tabs.push(new INSPECTOR.GLTFTab(_this, _this._inspector));
  4393. }
  4394. if (BABYLON.GUI) {
  4395. _this._tabs.push(new INSPECTOR.GUITab(_this, _this._inspector));
  4396. }
  4397. _this._tabs.push(new INSPECTOR.PhysicsTab(_this, _this._inspector));
  4398. _this._tabs.push(new INSPECTOR.CameraTab(_this, _this._inspector));
  4399. _this._tabs.push(new INSPECTOR.SoundTab(_this, _this._inspector));
  4400. _this._tabs.push(new INSPECTOR.ToolsTab(_this, _this._inspector));
  4401. _this._toolBar = new INSPECTOR.Toolbar(_this._inspector);
  4402. _this._build();
  4403. //Check initialTab is defined and between tabs bounds
  4404. if (!initialTab || initialTab < 0 || initialTab >= _this._tabs.length) {
  4405. initialTab = 0;
  4406. }
  4407. _this._tabs[initialTab].active(true);
  4408. // set all tab as visible
  4409. for (var _i = 0, _a = _this._tabs; _i < _a.length; _i++) {
  4410. var tab = _a[_i];
  4411. _this._visibleTabs.push(tab);
  4412. }
  4413. return _this;
  4414. }
  4415. // No update
  4416. TabBar.prototype.update = function () { };
  4417. TabBar.prototype._build = function () {
  4418. var _this = this;
  4419. this._div.className = 'tabbar';
  4420. this._div.appendChild(this._toolBar.toHtml());
  4421. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  4422. var tab = _a[_i];
  4423. this._div.appendChild(tab.toHtml());
  4424. }
  4425. this._moreTabsIcon = INSPECTOR.Helpers.CreateElement('i', 'fa fa-angle-double-right more-tabs');
  4426. this._moreTabsPanel = INSPECTOR.Helpers.CreateDiv('more-tabs-panel');
  4427. this._moreTabsIcon.addEventListener('click', function () {
  4428. // Hide the 'more-tabs-panel' if already displayed
  4429. if (_this._moreTabsPanel.style.display == 'flex') {
  4430. _this._moreTabsPanel.style.display = 'none';
  4431. }
  4432. else {
  4433. // Attach more-tabs-panel if not attached yet
  4434. var topPanel = _this._div.parentNode;
  4435. if (!topPanel.contains(_this._moreTabsPanel)) {
  4436. topPanel.appendChild(_this._moreTabsPanel);
  4437. }
  4438. // Clean the 'more-tabs-panel'
  4439. INSPECTOR.Helpers.CleanDiv(_this._moreTabsPanel);
  4440. // Add each invisible tabs to this panel
  4441. for (var _i = 0, _a = _this._invisibleTabs; _i < _a.length; _i++) {
  4442. var tab = _a[_i];
  4443. _this._addInvisibleTabToPanel(tab);
  4444. }
  4445. // And display it
  4446. _this._moreTabsPanel.style.display = 'flex';
  4447. }
  4448. });
  4449. };
  4450. /**
  4451. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  4452. * 'more-tabs' icon
  4453. */
  4454. TabBar.prototype._addInvisibleTabToPanel = function (tab) {
  4455. var _this = this;
  4456. var div = INSPECTOR.Helpers.CreateDiv('invisible-tab', this._moreTabsPanel);
  4457. div.textContent = tab.name;
  4458. div.addEventListener('click', function () {
  4459. _this._moreTabsPanel.style.display = 'none';
  4460. _this.switchTab(tab);
  4461. });
  4462. };
  4463. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  4464. TabBar.prototype.switchTab = function (tab) {
  4465. // Dispose the active tab
  4466. var activeTab = this.getActiveTab();
  4467. if (activeTab) {
  4468. activeTab.dispose();
  4469. }
  4470. // Deactivate all tabs
  4471. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  4472. var t = _a[_i];
  4473. t.active(false);
  4474. }
  4475. // activate the given tab
  4476. tab.active(true);
  4477. // Refresh the inspector
  4478. this._inspector.refresh();
  4479. };
  4480. /** Display the mesh tab.
  4481. * If a parameter is given, the given mesh details are displayed
  4482. */
  4483. TabBar.prototype.switchMeshTab = function (mesh) {
  4484. this.switchTab(this._meshTab);
  4485. if (mesh) {
  4486. var item = this._meshTab.getItemFor(mesh);
  4487. if (item) {
  4488. this._meshTab.select(item);
  4489. }
  4490. }
  4491. };
  4492. /** Returns the active tab */
  4493. TabBar.prototype.getActiveTab = function () {
  4494. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  4495. var tab = _a[_i];
  4496. if (tab.isActive()) {
  4497. return tab;
  4498. }
  4499. }
  4500. return null;
  4501. };
  4502. TabBar.prototype.getActiveTabIndex = function () {
  4503. for (var i = 0; i < this._tabs.length; i++) {
  4504. if (this._tabs[i].isActive()) {
  4505. return i;
  4506. }
  4507. }
  4508. return 0;
  4509. };
  4510. Object.defineProperty(TabBar.prototype, "inspector", {
  4511. get: function () {
  4512. return this._inspector;
  4513. },
  4514. enumerable: true,
  4515. configurable: true
  4516. });
  4517. /**
  4518. * Returns the total width in pixel of the tabbar,
  4519. * that corresponds to the sum of the width of each visible tab + toolbar width
  4520. */
  4521. TabBar.prototype.getPixelWidth = function () {
  4522. var sum = 0;
  4523. for (var _i = 0, _a = this._visibleTabs; _i < _a.length; _i++) {
  4524. var tab = _a[_i];
  4525. sum += tab.getPixelWidth();
  4526. }
  4527. sum += this._toolBar.getPixelWidth();
  4528. if (this._div.contains(this._moreTabsIcon)) {
  4529. sum += 30; // $tabbarheight
  4530. }
  4531. return sum;
  4532. };
  4533. /** Display the remaining icon or not depending on the tabbar width.
  4534. * This function should be called each time the inspector width is updated
  4535. */
  4536. TabBar.prototype.updateWidth = function () {
  4537. if (!this._div.parentElement) {
  4538. return;
  4539. }
  4540. var parentSize = this._div.parentElement.clientWidth;
  4541. var lastTabWidth = 75;
  4542. var currentSize = this.getPixelWidth();
  4543. // Check if a tab should be removed : if the tab bar width is greater than
  4544. // its parent width
  4545. while (this._visibleTabs.length > 0 && currentSize > parentSize) {
  4546. // Start by the last element
  4547. var tab = this._visibleTabs.pop();
  4548. if (!tab) {
  4549. break;
  4550. }
  4551. // set it invisible
  4552. this._invisibleTabs.push(tab);
  4553. // and removes it from the DOM
  4554. this._div.removeChild(tab.toHtml());
  4555. currentSize = this.getPixelWidth() + lastTabWidth;
  4556. }
  4557. // Check if a tab can be added to the tab bar : if the tab bar width
  4558. // + 100 (at least 100px is needed to add a tab) is less than its parent width
  4559. if (this._invisibleTabs.length > 0) {
  4560. if (currentSize + lastTabWidth < parentSize) {
  4561. var lastTab = this._invisibleTabs.pop();
  4562. if (lastTab) {
  4563. this._div.appendChild(lastTab.toHtml());
  4564. this._visibleTabs.push(lastTab);
  4565. }
  4566. // Update more-tab icon in last position if needed
  4567. if (this._div.contains(this._moreTabsIcon)) {
  4568. this._div.removeChild(this._moreTabsIcon);
  4569. }
  4570. }
  4571. }
  4572. if (this._invisibleTabs.length > 0 && !this._div.contains(this._moreTabsIcon)) {
  4573. this._div.appendChild(this._moreTabsIcon);
  4574. }
  4575. };
  4576. return TabBar;
  4577. }(INSPECTOR.BasicElement));
  4578. INSPECTOR.TabBar = TabBar;
  4579. })(INSPECTOR || (INSPECTOR = {}));
  4580. var INSPECTOR;
  4581. (function (INSPECTOR) {
  4582. var AbstractTool = /** @class */ (function () {
  4583. function AbstractTool(iconSet, icon, parent, inspector, tooltip) {
  4584. var _this = this;
  4585. this._inspector = inspector;
  4586. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  4587. this._elem.className = "tool " + iconSet + " " + icon;
  4588. parent.appendChild(this._elem);
  4589. this._elem.addEventListener('click', function (e) {
  4590. _this.action();
  4591. });
  4592. new INSPECTOR.Tooltip(this._elem, tooltip);
  4593. }
  4594. AbstractTool.prototype.toHtml = function () {
  4595. return this._elem;
  4596. };
  4597. /**
  4598. * Returns the total width in pixel of this tool, 0 by default
  4599. */
  4600. AbstractTool.prototype.getPixelWidth = function () {
  4601. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._elem);
  4602. if (!style.marginLeft || !style.marginRight) {
  4603. return 0;
  4604. }
  4605. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  4606. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  4607. return (this._elem.clientWidth || 0) + left + right;
  4608. };
  4609. /**
  4610. * Updates the icon of this tool with the given string
  4611. */
  4612. AbstractTool.prototype._updateIcon = function (icon) {
  4613. this._elem.className = "tool fa " + icon;
  4614. };
  4615. return AbstractTool;
  4616. }());
  4617. INSPECTOR.AbstractTool = AbstractTool;
  4618. })(INSPECTOR || (INSPECTOR = {}));
  4619. var __extends = (this && this.__extends) || (function () {
  4620. var extendStatics = Object.setPrototypeOf ||
  4621. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4622. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4623. return function (d, b) {
  4624. extendStatics(d, b);
  4625. function __() { this.constructor = d; }
  4626. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4627. };
  4628. })();
  4629. var INSPECTOR;
  4630. (function (INSPECTOR) {
  4631. var PauseScheduleTool = /** @class */ (function (_super) {
  4632. __extends(PauseScheduleTool, _super);
  4633. function PauseScheduleTool(parent, inspector) {
  4634. var _this = _super.call(this, 'fa', 'fa-pause', parent, inspector, 'Pause the automatic update of properties') || this;
  4635. _this._isPause = false;
  4636. return _this;
  4637. }
  4638. // Action : refresh the whole panel
  4639. PauseScheduleTool.prototype.action = function () {
  4640. if (this._isPause) {
  4641. INSPECTOR.Scheduler.getInstance().pause = false;
  4642. this._updateIcon('fa-pause');
  4643. }
  4644. else {
  4645. INSPECTOR.Scheduler.getInstance().pause = true;
  4646. this._updateIcon('fa-play');
  4647. }
  4648. this._isPause = !this._isPause;
  4649. };
  4650. return PauseScheduleTool;
  4651. }(INSPECTOR.AbstractTool));
  4652. INSPECTOR.PauseScheduleTool = PauseScheduleTool;
  4653. })(INSPECTOR || (INSPECTOR = {}));
  4654. var __extends = (this && this.__extends) || (function () {
  4655. var extendStatics = Object.setPrototypeOf ||
  4656. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4657. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4658. return function (d, b) {
  4659. extendStatics(d, b);
  4660. function __() { this.constructor = d; }
  4661. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4662. };
  4663. })();
  4664. var INSPECTOR;
  4665. (function (INSPECTOR) {
  4666. var PickTool = /** @class */ (function (_super) {
  4667. __extends(PickTool, _super);
  4668. function PickTool(parent, inspector) {
  4669. var _this = _super.call(this, 'fa', 'fa-mouse-pointer', parent, inspector, 'Select a mesh in the scene') || this;
  4670. _this._isActive = false;
  4671. // Create handler
  4672. _this._pickHandler = _this._pickMesh.bind(_this);
  4673. return _this;
  4674. }
  4675. // Action : find the corresponding tree item in the correct tab and display it
  4676. PickTool.prototype.action = function () {
  4677. if (this._isActive) {
  4678. this._deactivate();
  4679. }
  4680. else {
  4681. this.toHtml().classList.add('active');
  4682. // Add event handler : pick on a mesh in the scene
  4683. var canvas = this._inspector.scene.getEngine().getRenderingCanvas();
  4684. canvas.addEventListener('click', this._pickHandler);
  4685. this._isActive = true;
  4686. }
  4687. };
  4688. /** Deactivate this tool */
  4689. PickTool.prototype._deactivate = function () {
  4690. this.toHtml().classList.remove('active');
  4691. // Remove event handler
  4692. var canvas = this._inspector.scene.getEngine().getRenderingCanvas();
  4693. canvas.removeEventListener('click', this._pickHandler);
  4694. this._isActive = false;
  4695. };
  4696. /** Pick a mesh in the scene */
  4697. PickTool.prototype._pickMesh = function (evt) {
  4698. var pos = this._updatePointerPosition(evt);
  4699. var pi = this._inspector.scene.pick(pos.x, pos.y, function (mesh) { return true; });
  4700. if (pi && pi.pickedMesh) {
  4701. this._inspector.displayObjectDetails(pi.pickedMesh);
  4702. }
  4703. this._deactivate();
  4704. };
  4705. PickTool.prototype._updatePointerPosition = function (evt) {
  4706. var canvasRect = this._inspector.scene.getEngine().getRenderingCanvasClientRect();
  4707. var pointerX = evt.clientX - canvasRect.left;
  4708. var pointerY = evt.clientY - canvasRect.top;
  4709. return { x: pointerX, y: pointerY };
  4710. };
  4711. ;
  4712. return PickTool;
  4713. }(INSPECTOR.AbstractTool));
  4714. INSPECTOR.PickTool = PickTool;
  4715. })(INSPECTOR || (INSPECTOR = {}));
  4716. var __extends = (this && this.__extends) || (function () {
  4717. var extendStatics = Object.setPrototypeOf ||
  4718. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4719. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4720. return function (d, b) {
  4721. extendStatics(d, b);
  4722. function __() { this.constructor = d; }
  4723. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4724. };
  4725. })();
  4726. var INSPECTOR;
  4727. (function (INSPECTOR) {
  4728. var PopupTool = /** @class */ (function (_super) {
  4729. __extends(PopupTool, _super);
  4730. function PopupTool(parent, inspector) {
  4731. return _super.call(this, 'fas', 'fa-external-link-alt', parent, inspector, 'Open the inspector in a popup') || this;
  4732. }
  4733. // Action : refresh the whole panel
  4734. PopupTool.prototype.action = function () {
  4735. this._inspector.openPopup();
  4736. };
  4737. return PopupTool;
  4738. }(INSPECTOR.AbstractTool));
  4739. INSPECTOR.PopupTool = PopupTool;
  4740. })(INSPECTOR || (INSPECTOR = {}));
  4741. var __extends = (this && this.__extends) || (function () {
  4742. var extendStatics = Object.setPrototypeOf ||
  4743. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4744. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4745. return function (d, b) {
  4746. extendStatics(d, b);
  4747. function __() { this.constructor = d; }
  4748. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4749. };
  4750. })();
  4751. var INSPECTOR;
  4752. (function (INSPECTOR) {
  4753. var RefreshTool = /** @class */ (function (_super) {
  4754. __extends(RefreshTool, _super);
  4755. function RefreshTool(parent, inspector) {
  4756. return _super.call(this, 'fa', 'fa-sync', parent, inspector, 'Refresh the current tab') || this;
  4757. }
  4758. // Action : refresh the whole panel
  4759. RefreshTool.prototype.action = function () {
  4760. this._inspector.refresh();
  4761. };
  4762. return RefreshTool;
  4763. }(INSPECTOR.AbstractTool));
  4764. INSPECTOR.RefreshTool = RefreshTool;
  4765. })(INSPECTOR || (INSPECTOR = {}));
  4766. var __extends = (this && this.__extends) || (function () {
  4767. var extendStatics = Object.setPrototypeOf ||
  4768. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4769. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4770. return function (d, b) {
  4771. extendStatics(d, b);
  4772. function __() { this.constructor = d; }
  4773. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4774. };
  4775. })();
  4776. var INSPECTOR;
  4777. (function (INSPECTOR) {
  4778. var LabelTool = /** @class */ (function (_super) {
  4779. __extends(LabelTool, _super);
  4780. function LabelTool(parent, inspector) {
  4781. var _this = _super.call(this, 'fa', 'fa-tags', parent, inspector, 'Display mesh names on the canvas') || this;
  4782. /** True if label are displayed, false otherwise */
  4783. _this._isDisplayed = false;
  4784. _this._advancedTexture = null;
  4785. _this._labelInitialized = false;
  4786. _this._scene = null;
  4787. _this._guiLoaded = false;
  4788. _this._scene = inspector.scene;
  4789. return _this;
  4790. }
  4791. LabelTool.prototype.dispose = function () {
  4792. if (this._advancedTexture) {
  4793. this._advancedTexture.dispose();
  4794. }
  4795. };
  4796. LabelTool.prototype._checkGUILoaded = function () {
  4797. if (this._guiLoaded === true) {
  4798. return true;
  4799. }
  4800. if (BABYLON.GUI) {
  4801. this._guiLoaded = true;
  4802. }
  4803. return this._guiLoaded;
  4804. };
  4805. LabelTool.prototype._initializeLabels = function () {
  4806. var _this = this;
  4807. // Check if the label are already initialized and quit if it's the case
  4808. if (this._labelInitialized || !this._scene) {
  4809. return;
  4810. }
  4811. // Can't initialize them if the GUI lib is not loaded yet
  4812. if (!this._checkGUILoaded()) {
  4813. return;
  4814. }
  4815. // Create the canvas that will be used to display the labels
  4816. this._advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");
  4817. // Create label for all the Meshes, Lights and Cameras
  4818. // Those that will be created/removed after this method is called will be taken care by the event handlers added below
  4819. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  4820. var m = _a[_i];
  4821. this._createLabel(m);
  4822. }
  4823. this._scene.onNewMeshAddedObservable.add(function (m, s) {
  4824. _this._createLabel(m);
  4825. });
  4826. this._scene.onMeshRemovedObservable.add(function (m, s) {
  4827. _this._removeLabel(m);
  4828. });
  4829. this._labelInitialized = true;
  4830. };
  4831. LabelTool.prototype._createLabel = function (mesh) {
  4832. // Don't create label for "system nodes" (starting and ending with ###)
  4833. var name = mesh.name;
  4834. if (INSPECTOR.Helpers.IsSystemName(name)) {
  4835. return;
  4836. }
  4837. if (mesh && this._advancedTexture) {
  4838. var rect1 = new BABYLON.GUI.Rectangle();
  4839. rect1.width = 4 + 10 * name.length + "px";
  4840. rect1.height = "22px";
  4841. rect1.background = "rgba(0,0,0,0.6)";
  4842. rect1.color = "black";
  4843. this._advancedTexture.addControl(rect1);
  4844. var label = new BABYLON.GUI.TextBlock();
  4845. label.text = name;
  4846. label.fontSize = 12;
  4847. rect1.addControl(label);
  4848. rect1.linkWithMesh(mesh);
  4849. }
  4850. };
  4851. LabelTool.prototype._removeLabel = function (mesh) {
  4852. if (!this._advancedTexture) {
  4853. return;
  4854. }
  4855. for (var _i = 0, _a = this._advancedTexture._rootContainer.children; _i < _a.length; _i++) {
  4856. var g = _a[_i];
  4857. var ed = g._linkedMesh;
  4858. if (ed === mesh) {
  4859. this._advancedTexture.removeControl(g);
  4860. break;
  4861. }
  4862. }
  4863. };
  4864. // Action : Display/hide mesh names on the canvas
  4865. LabelTool.prototype.action = function () {
  4866. // Don't toggle if the script is not loaded
  4867. if (!this._checkGUILoaded() || !this._advancedTexture) {
  4868. return;
  4869. }
  4870. // Toggle the label display state
  4871. this._isDisplayed = !this._isDisplayed;
  4872. // Check if we have to display the labels
  4873. if (this._isDisplayed) {
  4874. this._initializeLabels();
  4875. this._advancedTexture._rootContainer.isVisible = true;
  4876. }
  4877. // Or to hide them
  4878. else {
  4879. this._advancedTexture._rootContainer.isVisible = false;
  4880. }
  4881. };
  4882. return LabelTool;
  4883. }(INSPECTOR.AbstractTool));
  4884. INSPECTOR.LabelTool = LabelTool;
  4885. })(INSPECTOR || (INSPECTOR = {}));
  4886. var __extends = (this && this.__extends) || (function () {
  4887. var extendStatics = Object.setPrototypeOf ||
  4888. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4889. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4890. return function (d, b) {
  4891. extendStatics(d, b);
  4892. function __() { this.constructor = d; }
  4893. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4894. };
  4895. })();
  4896. var INSPECTOR;
  4897. (function (INSPECTOR) {
  4898. var Toolbar = /** @class */ (function (_super) {
  4899. __extends(Toolbar, _super);
  4900. function Toolbar(inspector) {
  4901. var _this = _super.call(this) || this;
  4902. _this._tools = [];
  4903. _this._inspector = inspector;
  4904. _this._build();
  4905. _this._addTools();
  4906. return _this;
  4907. }
  4908. // A toolbar cannot be updated
  4909. Toolbar.prototype.update = function () { };
  4910. ;
  4911. Toolbar.prototype._build = function () {
  4912. this._div.className = 'toolbar';
  4913. };
  4914. ;
  4915. Toolbar.prototype._addTools = function () {
  4916. // Refresh
  4917. this._tools.push(new INSPECTOR.RefreshTool(this._div, this._inspector));
  4918. // Display labels
  4919. this._tools.push(new INSPECTOR.LabelTool(this._div, this._inspector));
  4920. // Pick object
  4921. this._tools.push(new INSPECTOR.PickTool(this._div, this._inspector));
  4922. // Add the popup mode only if the inspector is not in popup mode and if the brower is not edge
  4923. // Edge is
  4924. if (!this._inspector.popupMode && !INSPECTOR.Helpers.IsBrowserEdge()) {
  4925. this._tools.push(new INSPECTOR.PopupTool(this._div, this._inspector));
  4926. }
  4927. // FullScreen
  4928. this._tools.push(new INSPECTOR.FullscreenTool(this._div, this._inspector));
  4929. // Pause schedule
  4930. this._tools.push(new INSPECTOR.PauseScheduleTool(this._div, this._inspector));
  4931. // Pause schedule
  4932. this._tools.push(new INSPECTOR.DisposeTool(this._div, this._inspector));
  4933. };
  4934. /**
  4935. * Returns the total width in pixel of the tabbar,
  4936. * that corresponds to the sum of the width of each tab + toolbar width
  4937. */
  4938. Toolbar.prototype.getPixelWidth = function () {
  4939. var sum = 0;
  4940. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4941. var tool = _a[_i];
  4942. sum += tool.getPixelWidth();
  4943. }
  4944. return sum;
  4945. };
  4946. return Toolbar;
  4947. }(INSPECTOR.BasicElement));
  4948. INSPECTOR.Toolbar = Toolbar;
  4949. })(INSPECTOR || (INSPECTOR = {}));
  4950. var __extends = (this && this.__extends) || (function () {
  4951. var extendStatics = Object.setPrototypeOf ||
  4952. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4953. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4954. return function (d, b) {
  4955. extendStatics(d, b);
  4956. function __() { this.constructor = d; }
  4957. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4958. };
  4959. })();
  4960. var INSPECTOR;
  4961. (function (INSPECTOR) {
  4962. /**
  4963. * Removes the inspector panel
  4964. */
  4965. var DisposeTool = /** @class */ (function (_super) {
  4966. __extends(DisposeTool, _super);
  4967. function DisposeTool(parent, inspector) {
  4968. return _super.call(this, 'fa', 'fa-times', parent, inspector, 'Close the inspector panel') || this;
  4969. }
  4970. // Action : refresh the whole panel
  4971. DisposeTool.prototype.action = function () {
  4972. this._inspector.dispose();
  4973. };
  4974. return DisposeTool;
  4975. }(INSPECTOR.AbstractTool));
  4976. INSPECTOR.DisposeTool = DisposeTool;
  4977. })(INSPECTOR || (INSPECTOR = {}));
  4978. var __extends = (this && this.__extends) || (function () {
  4979. var extendStatics = Object.setPrototypeOf ||
  4980. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4981. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4982. return function (d, b) {
  4983. extendStatics(d, b);
  4984. function __() { this.constructor = d; }
  4985. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4986. };
  4987. })();
  4988. var INSPECTOR;
  4989. (function (INSPECTOR) {
  4990. var FullscreenTool = /** @class */ (function (_super) {
  4991. __extends(FullscreenTool, _super);
  4992. function FullscreenTool(parent, inspector) {
  4993. return _super.call(this, 'fa', 'fa-expand', parent, inspector, 'Open the scene in fullscreen, press Esc to exit') || this;
  4994. }
  4995. // Action : refresh the whole panel
  4996. FullscreenTool.prototype.action = function () {
  4997. var elem = document.body;
  4998. function requestFullScreen(element) {
  4999. // Supports most browsers and their versions.
  5000. var requestMethod = element.requestFullscreen || element.webkitRequestFullScreen;
  5001. requestMethod.call(element);
  5002. }
  5003. requestFullScreen(elem);
  5004. };
  5005. return FullscreenTool;
  5006. }(INSPECTOR.AbstractTool));
  5007. INSPECTOR.FullscreenTool = FullscreenTool;
  5008. })(INSPECTOR || (INSPECTOR = {}));
  5009. var __extends = (this && this.__extends) || (function () {
  5010. var extendStatics = Object.setPrototypeOf ||
  5011. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5012. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5013. return function (d, b) {
  5014. extendStatics(d, b);
  5015. function __() { this.constructor = d; }
  5016. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5017. };
  5018. })();
  5019. var INSPECTOR;
  5020. (function (INSPECTOR) {
  5021. var TreeItem = /** @class */ (function (_super) {
  5022. __extends(TreeItem, _super);
  5023. function TreeItem(tab, obj) {
  5024. var _this = _super.call(this) || this;
  5025. _this.children = [];
  5026. _this._tab = tab;
  5027. _this._adapter = obj;
  5028. _this._tools = _this._adapter.getTools();
  5029. _this._build();
  5030. return _this;
  5031. }
  5032. Object.defineProperty(TreeItem.prototype, "id", {
  5033. /** Returns the item ID == its adapter ID */
  5034. get: function () {
  5035. return this._adapter.id();
  5036. },
  5037. enumerable: true,
  5038. configurable: true
  5039. });
  5040. /** Add the given item as a child of this one */
  5041. TreeItem.prototype.add = function (child) {
  5042. this.children.push(child);
  5043. this.update();
  5044. };
  5045. Object.defineProperty(TreeItem.prototype, "adapter", {
  5046. /**
  5047. * Returns the original adapter
  5048. */
  5049. get: function () {
  5050. return this._adapter;
  5051. },
  5052. enumerable: true,
  5053. configurable: true
  5054. });
  5055. /**
  5056. * Function used to compare this item to another tree item.
  5057. * Returns the alphabetical sort of the adapter ID
  5058. */
  5059. TreeItem.prototype.compareTo = function (item) {
  5060. var str1 = this.id;
  5061. var str2 = item.id;
  5062. return str1.localeCompare(str2, [], { numeric: true });
  5063. };
  5064. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  5065. TreeItem.prototype.correspondsTo = function (obj) {
  5066. return this._adapter.correspondsTo(obj);
  5067. };
  5068. /** hide all children of this item */
  5069. TreeItem.prototype.fold = function () {
  5070. // Do nothing id no children
  5071. if (this.children.length > 0) {
  5072. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  5073. var elem = _a[_i];
  5074. elem.toHtml().style.display = 'none';
  5075. }
  5076. this._div.classList.add('folded');
  5077. this._div.classList.remove('unfolded');
  5078. }
  5079. };
  5080. /** Show all children of this item */
  5081. TreeItem.prototype.unfold = function () {
  5082. // Do nothing id no children
  5083. if (this.children.length > 0) {
  5084. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  5085. var elem = _a[_i];
  5086. elem.toHtml().style.display = 'block';
  5087. }
  5088. this._div.classList.add('unfolded');
  5089. this._div.classList.remove('folded');
  5090. }
  5091. };
  5092. /** Build the HTML of this item */
  5093. TreeItem.prototype._build = function () {
  5094. /**
  5095. * Hide the debug objects :
  5096. * - Axis : xline, yline, zline
  5097. * */
  5098. var adapterId = this._adapter.id();
  5099. if (adapterId == "xline"
  5100. || adapterId == "yline"
  5101. || adapterId == "zline") {
  5102. this._div.className = "line_invisible";
  5103. }
  5104. else
  5105. this._div.className = 'line';
  5106. // special class for transform node ONLY
  5107. if (this.adapter instanceof INSPECTOR.MeshAdapter) {
  5108. var obj = this.adapter.object;
  5109. if (obj instanceof BABYLON.TransformNode && !(obj instanceof BABYLON.AbstractMesh)) {
  5110. this._div.className += ' transformNode';
  5111. }
  5112. }
  5113. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  5114. var tool = _a[_i];
  5115. this._div.appendChild(tool.toHtml());
  5116. }
  5117. // Id
  5118. var text = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  5119. text.textContent = this._adapter.id();
  5120. this._div.appendChild(text);
  5121. // Type
  5122. var type = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  5123. type.className = 'property-type';
  5124. if (this._adapter.type() !== 'type_not_defined') {
  5125. type.textContent = ' - ' + this._adapter.type();
  5126. }
  5127. this._div.appendChild(type);
  5128. this._lineContent = INSPECTOR.Helpers.CreateDiv('line-content', this._div);
  5129. this._addEvent();
  5130. };
  5131. /**
  5132. * Returns one HTML element (.details) containing all details of this primitive
  5133. */
  5134. TreeItem.prototype.getDetails = function () {
  5135. return this._adapter.getProperties();
  5136. };
  5137. TreeItem.prototype.update = function () {
  5138. // Clean division holding all children
  5139. INSPECTOR.Helpers.CleanDiv(this._lineContent);
  5140. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  5141. var child = _a[_i];
  5142. var elem = child.toHtml();
  5143. this._lineContent.appendChild(elem);
  5144. }
  5145. if (this.children.length > 0) {
  5146. // Check if folded or not
  5147. if (!this._div.classList.contains('folded') && !this._div.classList.contains('unfolded')) {
  5148. this._div.classList.add('folded');
  5149. }
  5150. }
  5151. this.fold();
  5152. };
  5153. /**
  5154. * Add an event listener on the item :
  5155. * - one click display details
  5156. */
  5157. TreeItem.prototype._addEvent = function () {
  5158. var _this = this;
  5159. this._div.addEventListener('click', function (e) {
  5160. _this._tab.select(_this);
  5161. // Fold/unfold the tree
  5162. if (_this._isFolded()) {
  5163. _this.unfold();
  5164. }
  5165. else {
  5166. _this.fold();
  5167. }
  5168. e.stopPropagation();
  5169. });
  5170. };
  5171. /** Returns true if the node is folded, false otherwise */
  5172. TreeItem.prototype._isFolded = function () {
  5173. return !this._div.classList.contains('unfolded');
  5174. };
  5175. /** Set this item as active (background lighter) in the tree panel */
  5176. TreeItem.prototype.active = function (b) {
  5177. this._div.classList.remove('active');
  5178. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  5179. var child = _a[_i];
  5180. child.active(false);
  5181. }
  5182. if (b) {
  5183. this._div.classList.add('active');
  5184. }
  5185. };
  5186. TreeItem.prototype.getDiv = function () {
  5187. return this._div;
  5188. };
  5189. return TreeItem;
  5190. }(INSPECTOR.BasicElement));
  5191. INSPECTOR.TreeItem = TreeItem;
  5192. })(INSPECTOR || (INSPECTOR = {}));
  5193. var INSPECTOR;
  5194. (function (INSPECTOR) {
  5195. var AbstractTreeTool = /** @class */ (function () {
  5196. function AbstractTreeTool() {
  5197. /** Is the tool enabled ? */
  5198. this._on = false;
  5199. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  5200. this._elem.className = 'treeTool fa';
  5201. this._addEvents();
  5202. }
  5203. AbstractTreeTool.prototype.toHtml = function () {
  5204. return this._elem;
  5205. };
  5206. AbstractTreeTool.prototype._addEvents = function () {
  5207. var _this = this;
  5208. this._elem.addEventListener('click', function (e) {
  5209. _this.action();
  5210. e.stopPropagation();
  5211. });
  5212. };
  5213. /**
  5214. * Action launched when clicked on this element
  5215. * Should be overrided
  5216. */
  5217. AbstractTreeTool.prototype.action = function () {
  5218. this._on = !this._on;
  5219. };
  5220. return AbstractTreeTool;
  5221. }());
  5222. INSPECTOR.AbstractTreeTool = AbstractTreeTool;
  5223. })(INSPECTOR || (INSPECTOR = {}));
  5224. var __extends = (this && this.__extends) || (function () {
  5225. var extendStatics = Object.setPrototypeOf ||
  5226. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5227. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5228. return function (d, b) {
  5229. extendStatics(d, b);
  5230. function __() { this.constructor = d; }
  5231. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5232. };
  5233. })();
  5234. var INSPECTOR;
  5235. (function (INSPECTOR) {
  5236. /**
  5237. * Checkbox to display/hide the primitive
  5238. */
  5239. var BoundingBox = /** @class */ (function (_super) {
  5240. __extends(BoundingBox, _super);
  5241. function BoundingBox(obj) {
  5242. var _this = _super.call(this) || this;
  5243. _this._obj = obj;
  5244. _this._elem.classList.add('fa-square-o');
  5245. _this._on = _this._obj.isBoxVisible();
  5246. _this._check();
  5247. return _this;
  5248. }
  5249. // For a checkbox, set visible/invisible the corresponding prim
  5250. BoundingBox.prototype.action = function () {
  5251. _super.prototype.action.call(this);
  5252. // update object and gui according to the new status
  5253. this._check();
  5254. };
  5255. BoundingBox.prototype._check = function () {
  5256. if (this._on) {
  5257. // set icon eye
  5258. this._elem.classList.add('active');
  5259. }
  5260. else {
  5261. // set icon eye-slash
  5262. this._elem.classList.remove('active');
  5263. }
  5264. this._obj.setBoxVisible(this._on);
  5265. };
  5266. return BoundingBox;
  5267. }(INSPECTOR.AbstractTreeTool));
  5268. INSPECTOR.BoundingBox = BoundingBox;
  5269. })(INSPECTOR || (INSPECTOR = {}));
  5270. var __extends = (this && this.__extends) || (function () {
  5271. var extendStatics = Object.setPrototypeOf ||
  5272. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5273. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5274. return function (d, b) {
  5275. extendStatics(d, b);
  5276. function __() { this.constructor = d; }
  5277. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5278. };
  5279. })();
  5280. var INSPECTOR;
  5281. (function (INSPECTOR) {
  5282. /**
  5283. *
  5284. */
  5285. var CameraPOV = /** @class */ (function (_super) {
  5286. __extends(CameraPOV, _super);
  5287. function CameraPOV(camera) {
  5288. var _this = _super.call(this) || this;
  5289. _this.cameraPOV = camera;
  5290. // Setting the id of the line with the name of the camera
  5291. _this._elem.id = _this.cameraPOV.id();
  5292. // Put the right icon
  5293. if (_this._elem.id == _this.cameraPOV.getCurrentActiveCamera()) {
  5294. _this._elem.classList.add('fa-check-circle');
  5295. }
  5296. else {
  5297. _this._elem.classList.add('fa-circle');
  5298. }
  5299. return _this;
  5300. }
  5301. CameraPOV.prototype.action = function () {
  5302. _super.prototype.action.call(this);
  5303. this._gotoPOV();
  5304. };
  5305. CameraPOV.prototype._gotoPOV = function () {
  5306. // Uncheck all the radio buttons
  5307. var actives = INSPECTOR.Inspector.DOCUMENT.querySelectorAll(".fa-check-circle");
  5308. for (var i = 0; i < actives.length; i++) {
  5309. actives[i].classList.remove('fa-check-circle');
  5310. actives[i].classList.add('fa-circle');
  5311. }
  5312. // setting the point off view to the right camera
  5313. this.cameraPOV.setPOV();
  5314. // Check the right radio button
  5315. if (this._elem.id == this.cameraPOV.getCurrentActiveCamera()) {
  5316. this._elem.classList.remove('fa-circle');
  5317. this._elem.classList.add('fa-check-circle');
  5318. }
  5319. };
  5320. return CameraPOV;
  5321. }(INSPECTOR.AbstractTreeTool));
  5322. INSPECTOR.CameraPOV = CameraPOV;
  5323. })(INSPECTOR || (INSPECTOR = {}));
  5324. var __extends = (this && this.__extends) || (function () {
  5325. var extendStatics = Object.setPrototypeOf ||
  5326. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5327. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5328. return function (d, b) {
  5329. extendStatics(d, b);
  5330. function __() { this.constructor = d; }
  5331. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5332. };
  5333. })();
  5334. var INSPECTOR;
  5335. (function (INSPECTOR) {
  5336. /**
  5337. *
  5338. */
  5339. var SoundInteractions = /** @class */ (function (_super) {
  5340. __extends(SoundInteractions, _super);
  5341. function SoundInteractions(playSound) {
  5342. var _this = _super.call(this) || this;
  5343. _this.playSound = playSound;
  5344. _this._elem.classList.add('fa-play');
  5345. return _this;
  5346. }
  5347. SoundInteractions.prototype.action = function () {
  5348. _super.prototype.action.call(this);
  5349. this._playSound();
  5350. };
  5351. SoundInteractions.prototype._playSound = function () {
  5352. var _this = this;
  5353. if (this._elem.classList.contains('fa-play')) {
  5354. this._elem.classList.remove('fa-play');
  5355. this._elem.classList.add('fa-pause');
  5356. }
  5357. else {
  5358. this._elem.classList.remove('fa-pause');
  5359. this._elem.classList.add('fa-play');
  5360. }
  5361. this.playSound.setPlaying(function () {
  5362. _this._elem.classList.remove('fa-pause');
  5363. _this._elem.classList.add('fa-play');
  5364. });
  5365. };
  5366. return SoundInteractions;
  5367. }(INSPECTOR.AbstractTreeTool));
  5368. INSPECTOR.SoundInteractions = SoundInteractions;
  5369. })(INSPECTOR || (INSPECTOR = {}));
  5370. var __extends = (this && this.__extends) || (function () {
  5371. var extendStatics = Object.setPrototypeOf ||
  5372. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5373. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5374. return function (d, b) {
  5375. extendStatics(d, b);
  5376. function __() { this.constructor = d; }
  5377. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5378. };
  5379. })();
  5380. var INSPECTOR;
  5381. (function (INSPECTOR) {
  5382. /**
  5383. * Checkbox to display/hide the primitive
  5384. */
  5385. var Checkbox = /** @class */ (function (_super) {
  5386. __extends(Checkbox, _super);
  5387. function Checkbox(obj) {
  5388. var _this = _super.call(this) || this;
  5389. _this._obj = obj;
  5390. _this._elem.classList.add('fa-eye');
  5391. _this._on = _this._obj.isVisible();
  5392. _this._check(true);
  5393. return _this;
  5394. }
  5395. // For a checkbox, set visible/invisible the corresponding prim
  5396. Checkbox.prototype.action = function () {
  5397. _super.prototype.action.call(this);
  5398. // update object and gui according to the new status
  5399. this._check();
  5400. };
  5401. Checkbox.prototype._check = function (dontEnable) {
  5402. if (this._on) {
  5403. // set icon eye
  5404. this._elem.classList.add('fa-eye');
  5405. this._elem.classList.add('active');
  5406. this._elem.classList.remove('fa-eye-slash');
  5407. }
  5408. else {
  5409. // set icon eye-slash
  5410. this._elem.classList.remove('fa-eye');
  5411. this._elem.classList.remove('active');
  5412. this._elem.classList.add('fa-eye-slash');
  5413. }
  5414. if (!dontEnable) {
  5415. this._obj.setVisible(this._on);
  5416. }
  5417. };
  5418. return Checkbox;
  5419. }(INSPECTOR.AbstractTreeTool));
  5420. INSPECTOR.Checkbox = Checkbox;
  5421. })(INSPECTOR || (INSPECTOR = {}));
  5422. var __extends = (this && this.__extends) || (function () {
  5423. var extendStatics = Object.setPrototypeOf ||
  5424. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5425. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5426. return function (d, b) {
  5427. extendStatics(d, b);
  5428. function __() { this.constructor = d; }
  5429. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5430. };
  5431. })();
  5432. var INSPECTOR;
  5433. (function (INSPECTOR) {
  5434. var DebugArea = /** @class */ (function (_super) {
  5435. __extends(DebugArea, _super);
  5436. function DebugArea(obj) {
  5437. var _this = _super.call(this) || this;
  5438. _this._obj = obj;
  5439. _this._elem.classList.add('fa-wrench');
  5440. return _this;
  5441. }
  5442. DebugArea.prototype.action = function () {
  5443. _super.prototype.action.call(this);
  5444. if (this._on) {
  5445. // set icon activated
  5446. this._elem.classList.add('active');
  5447. }
  5448. else {
  5449. // set icon deactivated
  5450. this._elem.classList.remove('active');
  5451. }
  5452. this._obj.debug(this._on);
  5453. };
  5454. return DebugArea;
  5455. }(INSPECTOR.AbstractTreeTool));
  5456. INSPECTOR.DebugArea = DebugArea;
  5457. })(INSPECTOR || (INSPECTOR = {}));
  5458. var __extends = (this && this.__extends) || (function () {
  5459. var extendStatics = Object.setPrototypeOf ||
  5460. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5461. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5462. return function (d, b) {
  5463. extendStatics(d, b);
  5464. function __() { this.constructor = d; }
  5465. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5466. };
  5467. })();
  5468. var INSPECTOR;
  5469. (function (INSPECTOR) {
  5470. /**
  5471. * Checkbox to display/hide the primitive
  5472. */
  5473. var Info = /** @class */ (function (_super) {
  5474. __extends(Info, _super);
  5475. function Info(obj) {
  5476. var _this = _super.call(this) || this;
  5477. _this._obj = obj;
  5478. _this._elem.classList.add('fa-info-circle');
  5479. new INSPECTOR.Tooltip(_this._elem, _this._obj.getInfo(), _this._elem);
  5480. return _this;
  5481. }
  5482. // Nothing to do on click
  5483. Info.prototype.action = function () {
  5484. _super.prototype.action.call(this);
  5485. };
  5486. return Info;
  5487. }(INSPECTOR.AbstractTreeTool));
  5488. INSPECTOR.Info = Info;
  5489. })(INSPECTOR || (INSPECTOR = {}));