babylon.inspector.js 211 KB

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