babylon.inspector.js 208 KB

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