babylon.inspector.js 207 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854
  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(), BABYLON.Vector3.Zero(), x);
  1283. xAxis.parent = this._obj;
  1284. this._axis.push(xAxis);
  1285. // Y axis
  1286. var yAxis = _drawAxis(BABYLON.Color3.Green(), BABYLON.Vector3.Zero(), y);
  1287. yAxis.parent = this._obj;
  1288. this._axis.push(yAxis);
  1289. // Z axis
  1290. var zAxis = _drawAxis(BABYLON.Color3.Blue(), BABYLON.Vector3.Zero(), z);
  1291. zAxis.parent = this._obj;
  1292. this._axis.push(zAxis);
  1293. };
  1294. return MeshAdapter;
  1295. }(INSPECTOR.Adapter));
  1296. INSPECTOR.MeshAdapter = MeshAdapter;
  1297. })(INSPECTOR || (INSPECTOR = {}));
  1298. //# sourceMappingURL=MeshAdapter.js.map
  1299. var __extends = (this && this.__extends) || (function () {
  1300. var extendStatics = Object.setPrototypeOf ||
  1301. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1302. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1303. return function (d, b) {
  1304. extendStatics(d, b);
  1305. function __() { this.constructor = d; }
  1306. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1307. };
  1308. })();
  1309. var INSPECTOR;
  1310. (function (INSPECTOR) {
  1311. var DetailPanel = (function (_super) {
  1312. __extends(DetailPanel, _super);
  1313. function DetailPanel(dr) {
  1314. var _this = _super.call(this) || this;
  1315. // Contains all details rows that belongs to the item above
  1316. _this._detailRows = [];
  1317. // Store the sort direction of each header column
  1318. _this._sortDirection = {};
  1319. _this._build();
  1320. if (dr) {
  1321. _this._detailRows = dr;
  1322. _this.update();
  1323. }
  1324. return _this;
  1325. }
  1326. Object.defineProperty(DetailPanel.prototype, "details", {
  1327. set: function (detailsRow) {
  1328. this.clean();
  1329. this._detailRows = detailsRow;
  1330. // Refresh HTML
  1331. this.update();
  1332. },
  1333. enumerable: true,
  1334. configurable: true
  1335. });
  1336. DetailPanel.prototype._build = function () {
  1337. this._div.className = 'insp-details';
  1338. this._div.id = 'insp-details';
  1339. // Create header row
  1340. this._createHeaderRow();
  1341. this._div.appendChild(this._headerRow);
  1342. };
  1343. /** Updates the HTML of the detail panel */
  1344. DetailPanel.prototype.update = function () {
  1345. this._sortDetails('name', 1);
  1346. this._addDetails();
  1347. };
  1348. /** Add all lines in the html div. Does not sort them! */
  1349. DetailPanel.prototype._addDetails = function () {
  1350. var details = INSPECTOR.Helpers.CreateDiv('details', this._div);
  1351. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1352. var row = _a[_i];
  1353. details.appendChild(row.toHtml());
  1354. }
  1355. };
  1356. /**
  1357. * Sort the details row by comparing the given property of each row
  1358. */
  1359. DetailPanel.prototype._sortDetails = function (property, _direction) {
  1360. // Clean header
  1361. var elems = INSPECTOR.Inspector.DOCUMENT.querySelectorAll('.sort-direction');
  1362. for (var e = 0; e < elems.length; e++) {
  1363. elems[e].classList.remove('fa-chevron-up');
  1364. elems[e].classList.remove('fa-chevron-down');
  1365. }
  1366. if (_direction || !this._sortDirection[property]) {
  1367. this._sortDirection[property] = _direction || 1;
  1368. }
  1369. else {
  1370. this._sortDirection[property] *= -1;
  1371. }
  1372. var direction = this._sortDirection[property];
  1373. if (direction == 1) {
  1374. this._headerRow.querySelector("#sort-direction-" + property).classList.remove('fa-chevron-down');
  1375. this._headerRow.querySelector("#sort-direction-" + property).classList.add('fa-chevron-up');
  1376. }
  1377. else {
  1378. this._headerRow.querySelector("#sort-direction-" + property).classList.remove('fa-chevron-up');
  1379. this._headerRow.querySelector("#sort-direction-" + property).classList.add('fa-chevron-down');
  1380. }
  1381. var isString = function (s) {
  1382. return typeof (s) === 'string' || s instanceof String;
  1383. };
  1384. this._detailRows.sort(function (detail1, detail2) {
  1385. var str1 = String(detail1[property]);
  1386. var str2 = String(detail2[property]);
  1387. if (!isString(str1)) {
  1388. str1 = detail1[property].toString();
  1389. }
  1390. if (!isString(str2)) {
  1391. str2 = detail2[property].toString();
  1392. }
  1393. // Compare numbers as numbers and string as string with 'numeric=true'
  1394. return str1.localeCompare(str2, [], { numeric: true }) * direction;
  1395. });
  1396. };
  1397. /**
  1398. * Removes all data in the detail panel but keep the header row
  1399. */
  1400. DetailPanel.prototype.clean = function () {
  1401. // Delete all details row
  1402. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1403. var pline = _a[_i];
  1404. pline.dispose();
  1405. }
  1406. INSPECTOR.Helpers.CleanDiv(this._div);
  1407. // Header row
  1408. this._div.appendChild(this._headerRow);
  1409. };
  1410. /** Overrides basicelement.dispose */
  1411. DetailPanel.prototype.dispose = function () {
  1412. // Delete all details row
  1413. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1414. var pline = _a[_i];
  1415. pline.dispose();
  1416. }
  1417. };
  1418. /**
  1419. * Creates the header row : name, value, id
  1420. */
  1421. DetailPanel.prototype._createHeaderRow = function () {
  1422. var _this = this;
  1423. this._headerRow = INSPECTOR.Helpers.CreateDiv('header-row');
  1424. var createDiv = function (name, cssClass) {
  1425. var div = INSPECTOR.Helpers.CreateDiv(cssClass + ' header-col');
  1426. // Column title - first letter in uppercase
  1427. var spanName = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  1428. spanName.textContent = name.charAt(0).toUpperCase() + name.slice(1);
  1429. // sort direction
  1430. var spanDirection = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  1431. spanDirection.className = 'sort-direction fa';
  1432. spanDirection.id = 'sort-direction-' + name;
  1433. div.appendChild(spanName);
  1434. div.appendChild(spanDirection);
  1435. div.addEventListener('click', function (e) {
  1436. _this._sortDetails(name);
  1437. _this._addDetails();
  1438. });
  1439. return div;
  1440. };
  1441. this._headerRow.appendChild(createDiv('name', 'prop-name'));
  1442. this._headerRow.appendChild(createDiv('value', 'prop-value'));
  1443. };
  1444. return DetailPanel;
  1445. }(INSPECTOR.BasicElement));
  1446. INSPECTOR.DetailPanel = DetailPanel;
  1447. })(INSPECTOR || (INSPECTOR = {}));
  1448. //# sourceMappingURL=DetailPanel.js.map
  1449. var INSPECTOR;
  1450. (function (INSPECTOR) {
  1451. /**
  1452. * A property is a link between a data (string) and an object.
  1453. */
  1454. var Property = (function () {
  1455. function Property(prop, obj) {
  1456. this._property = prop;
  1457. this._obj = obj;
  1458. }
  1459. Object.defineProperty(Property.prototype, "name", {
  1460. get: function () {
  1461. return this._property;
  1462. },
  1463. enumerable: true,
  1464. configurable: true
  1465. });
  1466. Object.defineProperty(Property.prototype, "value", {
  1467. get: function () {
  1468. return this._obj[this._property];
  1469. },
  1470. set: function (newValue) {
  1471. this._obj[this._property] = newValue;
  1472. },
  1473. enumerable: true,
  1474. configurable: true
  1475. });
  1476. Object.defineProperty(Property.prototype, "type", {
  1477. get: function () {
  1478. return INSPECTOR.Helpers.GET_TYPE(this.value);
  1479. },
  1480. enumerable: true,
  1481. configurable: true
  1482. });
  1483. Object.defineProperty(Property.prototype, "obj", {
  1484. get: function () {
  1485. return this._obj;
  1486. },
  1487. set: function (newObj) {
  1488. this._obj = newObj;
  1489. },
  1490. enumerable: true,
  1491. configurable: true
  1492. });
  1493. return Property;
  1494. }());
  1495. INSPECTOR.Property = Property;
  1496. })(INSPECTOR || (INSPECTOR = {}));
  1497. //# sourceMappingURL=Property.js.map
  1498. var INSPECTOR;
  1499. (function (INSPECTOR) {
  1500. var PropertyFormatter = (function () {
  1501. function PropertyFormatter() {
  1502. }
  1503. /**
  1504. * Format the value of the given property of the given object.
  1505. */
  1506. PropertyFormatter.format = function (obj, prop) {
  1507. // Get original value;
  1508. var value = obj[prop];
  1509. // test if type PrimitiveAlignment is available (only included in canvas2d)
  1510. if (BABYLON.PrimitiveAlignment) {
  1511. if (obj instanceof BABYLON.PrimitiveAlignment) {
  1512. if (prop === 'horizontal') {
  1513. switch (value) {
  1514. case BABYLON.PrimitiveAlignment.AlignLeft:
  1515. return 'left';
  1516. case BABYLON.PrimitiveAlignment.AlignRight:
  1517. return 'right';
  1518. case BABYLON.PrimitiveAlignment.AlignCenter:
  1519. return 'center';
  1520. case BABYLON.PrimitiveAlignment.AlignStretch:
  1521. return 'stretch';
  1522. }
  1523. }
  1524. else if (prop === 'vertical') {
  1525. switch (value) {
  1526. case BABYLON.PrimitiveAlignment.AlignTop:
  1527. return 'top';
  1528. case BABYLON.PrimitiveAlignment.AlignBottom:
  1529. return 'bottom';
  1530. case BABYLON.PrimitiveAlignment.AlignCenter:
  1531. return 'center';
  1532. case BABYLON.PrimitiveAlignment.AlignStretch:
  1533. return 'stretch';
  1534. }
  1535. }
  1536. }
  1537. }
  1538. return value;
  1539. };
  1540. return PropertyFormatter;
  1541. }());
  1542. INSPECTOR.PropertyFormatter = PropertyFormatter;
  1543. /**
  1544. * A property line represents a line in the detail panel. This line is composed of :
  1545. * - a name (the property name)
  1546. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  1547. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  1548. * - a ID if defined (otherwise an empty string is displayed)
  1549. * The original object is sent to the value object who will update it at will.
  1550. *
  1551. * A property line can contain OTHER property line objects in the case of a complex type.
  1552. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  1553. *
  1554. */
  1555. var PropertyLine = (function () {
  1556. function PropertyLine(prop, parent, level) {
  1557. if (level === void 0) { level = 0; }
  1558. // If the type is complex, this property will have child to update
  1559. this._children = [];
  1560. /** The list of viewer element displayed at the end of the line (color, texture...) */
  1561. this._elements = [];
  1562. this._property = prop;
  1563. this._level = level;
  1564. this._parent = parent;
  1565. this._div = INSPECTOR.Helpers.CreateDiv('row');
  1566. this._div.style.marginLeft = this._level + "px";
  1567. // Property name
  1568. var propName = INSPECTOR.Helpers.CreateDiv('prop-name', this._div);
  1569. propName.textContent = "" + this.name;
  1570. // Value
  1571. this._valueDiv = INSPECTOR.Helpers.CreateDiv('prop-value', this._div);
  1572. this._valueDiv.textContent = this._displayValueContent() || '-'; // Init value text node
  1573. this._createElements();
  1574. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1575. var elem = _a[_i];
  1576. this._valueDiv.appendChild(elem.toHtml());
  1577. }
  1578. this._updateValue();
  1579. // If the property type is not simple, add click event to unfold its children
  1580. if (!this._isSimple()) {
  1581. this._valueDiv.classList.add('clickable');
  1582. this._valueDiv.addEventListener('click', this._addDetails.bind(this));
  1583. }
  1584. else {
  1585. this._initInput();
  1586. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1587. this._input.addEventListener('keypress', this._validateInputHandler);
  1588. this._input.addEventListener('keydown', this._escapeInputHandler);
  1589. }
  1590. // Add this property to the scheduler
  1591. INSPECTOR.Scheduler.getInstance().add(this);
  1592. }
  1593. /**
  1594. * Init the input element and al its handler :
  1595. * - a click in the window remove the input and restore the old property value
  1596. * - enters updates the property
  1597. */
  1598. PropertyLine.prototype._initInput = function () {
  1599. // Create the input element
  1600. this._input = document.createElement('input');
  1601. this._input.setAttribute('type', 'text');
  1602. // if the property is 'simple', add an event listener to create an input
  1603. this._displayInputHandler = this._displayInput.bind(this);
  1604. this._validateInputHandler = this._validateInput.bind(this);
  1605. this._escapeInputHandler = this._escapeInput.bind(this);
  1606. };
  1607. /**
  1608. * On enter : validates the new value and removes the input
  1609. * On escape : removes the input
  1610. */
  1611. PropertyLine.prototype._validateInput = function (e) {
  1612. if (e.keyCode == 13) {
  1613. // Enter : validate the new value
  1614. var newValue = this._input.value;
  1615. this.updateObject();
  1616. this._property.value = newValue;
  1617. // Remove input
  1618. this.update();
  1619. // resume scheduler
  1620. INSPECTOR.Scheduler.getInstance().pause = false;
  1621. }
  1622. else if (e.keyCode == 27) {
  1623. // Esc : remove input
  1624. this.update();
  1625. }
  1626. };
  1627. /**
  1628. * On escape : removes the input
  1629. */
  1630. PropertyLine.prototype._escapeInput = function (e) {
  1631. if (e.keyCode == 27) {
  1632. // Esc : remove input
  1633. this.update();
  1634. }
  1635. };
  1636. /** Removes the input without validating the new value */
  1637. PropertyLine.prototype._removeInputWithoutValidating = function () {
  1638. INSPECTOR.Helpers.CleanDiv(this._valueDiv);
  1639. this._valueDiv.textContent = "-";
  1640. // restore elements
  1641. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1642. var elem = _a[_i];
  1643. this._valueDiv.appendChild(elem.toHtml());
  1644. }
  1645. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1646. };
  1647. /** Replaces the default display with an input */
  1648. PropertyLine.prototype._displayInput = function (e) {
  1649. // Remove the displayInput event listener
  1650. this._valueDiv.removeEventListener('click', this._displayInputHandler);
  1651. // Set input value
  1652. var valueTxt = this._valueDiv.textContent;
  1653. this._valueDiv.textContent = "";
  1654. this._input.value = valueTxt;
  1655. this._valueDiv.appendChild(this._input);
  1656. // Pause the scheduler
  1657. INSPECTOR.Scheduler.getInstance().pause = true;
  1658. };
  1659. /** Retrieve the correct object from its parent.
  1660. * If no parent exists, returns the property value.
  1661. * This method is used at each update in case the property object is removed from the original object
  1662. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  1663. */
  1664. PropertyLine.prototype.updateObject = function () {
  1665. if (this._parent) {
  1666. this._property.obj = this._parent.updateObject();
  1667. }
  1668. return this._property.value;
  1669. };
  1670. Object.defineProperty(PropertyLine.prototype, "name", {
  1671. // Returns the property name
  1672. get: function () {
  1673. return this._property.name;
  1674. },
  1675. enumerable: true,
  1676. configurable: true
  1677. });
  1678. Object.defineProperty(PropertyLine.prototype, "value", {
  1679. // Returns the value of the property
  1680. get: function () {
  1681. return PropertyFormatter.format(this._property.obj, this._property.name);
  1682. },
  1683. enumerable: true,
  1684. configurable: true
  1685. });
  1686. Object.defineProperty(PropertyLine.prototype, "type", {
  1687. // Returns the type of the property
  1688. get: function () {
  1689. return this._property.type;
  1690. },
  1691. enumerable: true,
  1692. configurable: true
  1693. });
  1694. /**
  1695. * Creates elements that wil be displayed on a property line, depending on the
  1696. * type of the property.
  1697. */
  1698. PropertyLine.prototype._createElements = function () {
  1699. // Colors
  1700. if (this.type == 'Color3' || this.type == 'Color4') {
  1701. this._elements.push(new INSPECTOR.ColorElement(this.value));
  1702. }
  1703. // Texture
  1704. if (this.type == 'Texture') {
  1705. this._elements.push(new INSPECTOR.TextureElement(this.value));
  1706. }
  1707. // HDR Texture
  1708. if (this.type == 'HDRCubeTexture') {
  1709. this._elements.push(new INSPECTOR.HDRCubeTextureElement(this.value));
  1710. }
  1711. if (this.type == 'CubeTexture') {
  1712. this._elements.push(new INSPECTOR.CubeTextureElement(this.value));
  1713. }
  1714. };
  1715. // Returns the text displayed on the left of the property name :
  1716. // - If the type is simple, display its value
  1717. // - If the type is complex, but instance of Vector2, Size, display the type and its tostring
  1718. // - If the type is another one, display the Type
  1719. PropertyLine.prototype._displayValueContent = function () {
  1720. var value = this.value;
  1721. // If the value is a number, truncate it if needed
  1722. if (typeof value === 'number') {
  1723. return INSPECTOR.Helpers.Trunc(value);
  1724. }
  1725. // If it's a string or a boolean, display its value
  1726. if (typeof value === 'string' || typeof value === 'boolean') {
  1727. return value;
  1728. }
  1729. return INSPECTOR.PROPERTIES.format(value);
  1730. };
  1731. /** Delete properly this property line.
  1732. * Removes itself from the scheduler.
  1733. * Dispose all viewer element (color, texture...)
  1734. */
  1735. PropertyLine.prototype.dispose = function () {
  1736. // console.log('delete properties', this.name);
  1737. INSPECTOR.Scheduler.getInstance().remove(this);
  1738. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1739. var child = _a[_i];
  1740. // console.log('delete properties', child.name);
  1741. INSPECTOR.Scheduler.getInstance().remove(child);
  1742. }
  1743. for (var _b = 0, _c = this._elements; _b < _c.length; _b++) {
  1744. var elem = _c[_b];
  1745. elem.dispose();
  1746. }
  1747. this._elements = [];
  1748. };
  1749. /** Updates the content of _valueDiv with the value of the property,
  1750. * and all HTML element correpsonding to this type.
  1751. * Elements are updated as well
  1752. */
  1753. PropertyLine.prototype._updateValue = function () {
  1754. // Update the property object first
  1755. this.updateObject();
  1756. // Then update its value
  1757. // this._valueDiv.textContent = " "; // TOFIX this removes the elements after
  1758. this._valueDiv.childNodes[0].nodeValue = this._displayValueContent();
  1759. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1760. var elem = _a[_i];
  1761. elem.update(this.value);
  1762. }
  1763. };
  1764. /**
  1765. * Update the property division with the new property value.
  1766. * If this property is complex, update its child, otherwise update its text content
  1767. */
  1768. PropertyLine.prototype.update = function () {
  1769. this._removeInputWithoutValidating();
  1770. this._updateValue();
  1771. };
  1772. /**
  1773. * Returns true if the given instance is a simple type
  1774. */
  1775. PropertyLine._IS_TYPE_SIMPLE = function (inst) {
  1776. var type = INSPECTOR.Helpers.GET_TYPE(inst);
  1777. return PropertyLine._SIMPLE_TYPE.indexOf(type) != -1;
  1778. };
  1779. /**
  1780. * Returns true if the type of this property is simple, false otherwise.
  1781. * Returns true if the value is null
  1782. */
  1783. PropertyLine.prototype._isSimple = function () {
  1784. if (this.value != null && this.type !== 'type_not_defined') {
  1785. if (PropertyLine._SIMPLE_TYPE.indexOf(this.type) == -1) {
  1786. // complex type : return the type name
  1787. return false;
  1788. }
  1789. else {
  1790. // simple type : return value
  1791. return true;
  1792. }
  1793. }
  1794. else {
  1795. return true;
  1796. }
  1797. };
  1798. PropertyLine.prototype.toHtml = function () {
  1799. return this._div;
  1800. };
  1801. /**
  1802. * Add sub properties in case of a complex type
  1803. */
  1804. PropertyLine.prototype._addDetails = function () {
  1805. if (this._div.classList.contains('unfolded')) {
  1806. // Remove class unfolded
  1807. this._div.classList.remove('unfolded');
  1808. // remove html children
  1809. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1810. var child = _a[_i];
  1811. this._div.parentNode.removeChild(child.toHtml());
  1812. }
  1813. }
  1814. else {
  1815. // if children does not exists, generate it
  1816. this._div.classList.toggle('unfolded');
  1817. if (this._children.length == 0) {
  1818. var objToDetail = this.value;
  1819. var propToDisplay = INSPECTOR.PROPERTIES[INSPECTOR.Helpers.GET_TYPE(objToDetail)].properties.reverse();
  1820. var propertyLine = null;
  1821. for (var _b = 0, propToDisplay_1 = propToDisplay; _b < propToDisplay_1.length; _b++) {
  1822. var prop = propToDisplay_1[_b];
  1823. var infos = new INSPECTOR.Property(prop, this._property.value);
  1824. var child = new PropertyLine(infos, this, this._level + PropertyLine._MARGIN_LEFT);
  1825. this._children.push(child);
  1826. }
  1827. }
  1828. // otherwise display it
  1829. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  1830. var child = _d[_c];
  1831. this._div.parentNode.insertBefore(child.toHtml(), this._div.nextSibling);
  1832. }
  1833. }
  1834. };
  1835. return PropertyLine;
  1836. }());
  1837. // Array representing the simple type. All others are considered 'complex'
  1838. PropertyLine._SIMPLE_TYPE = ['number', 'string', 'boolean'];
  1839. // The number of pixel at each children step
  1840. PropertyLine._MARGIN_LEFT = 15;
  1841. INSPECTOR.PropertyLine = PropertyLine;
  1842. })(INSPECTOR || (INSPECTOR = {}));
  1843. //# sourceMappingURL=PropertyLine.js.map
  1844. var __extends = (this && this.__extends) || (function () {
  1845. var extendStatics = Object.setPrototypeOf ||
  1846. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1847. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1848. return function (d, b) {
  1849. extendStatics(d, b);
  1850. function __() { this.constructor = d; }
  1851. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1852. };
  1853. })();
  1854. var INSPECTOR;
  1855. (function (INSPECTOR) {
  1856. /**
  1857. * Display a very small div corresponding to the given color
  1858. */
  1859. var ColorElement = (function (_super) {
  1860. __extends(ColorElement, _super);
  1861. // The color as hexadecimal string
  1862. function ColorElement(color) {
  1863. var _this = _super.call(this) || this;
  1864. _this._div.className = 'color-element';
  1865. _this._div.style.backgroundColor = _this._toRgba(color);
  1866. return _this;
  1867. }
  1868. ColorElement.prototype.update = function (color) {
  1869. if (color) {
  1870. this._div.style.backgroundColor = this._toRgba(color);
  1871. }
  1872. };
  1873. ColorElement.prototype._toRgba = function (color) {
  1874. if (color) {
  1875. var r = (color.r * 255) | 0;
  1876. var g = (color.g * 255) | 0;
  1877. var b = (color.b * 255) | 0;
  1878. var a = 1;
  1879. if (color instanceof BABYLON.Color4) {
  1880. var a_1 = color.a;
  1881. }
  1882. return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
  1883. }
  1884. else {
  1885. return '';
  1886. }
  1887. };
  1888. return ColorElement;
  1889. }(INSPECTOR.BasicElement));
  1890. INSPECTOR.ColorElement = ColorElement;
  1891. })(INSPECTOR || (INSPECTOR = {}));
  1892. //# sourceMappingURL=ColorElement.js.map
  1893. var __extends = (this && this.__extends) || (function () {
  1894. var extendStatics = Object.setPrototypeOf ||
  1895. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1896. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1897. return function (d, b) {
  1898. extendStatics(d, b);
  1899. function __() { this.constructor = d; }
  1900. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1901. };
  1902. })();
  1903. var INSPECTOR;
  1904. (function (INSPECTOR) {
  1905. /**
  1906. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  1907. * cube texture in a cube
  1908. */
  1909. var CubeTextureElement = (function (_super) {
  1910. __extends(CubeTextureElement, _super);
  1911. /** The texture given as a parameter should be cube. */
  1912. function CubeTextureElement(tex) {
  1913. var _this = _super.call(this) || this;
  1914. // On pause the engine will not render anything
  1915. _this._pause = false;
  1916. _this._div.className = 'fa fa-search texture-element';
  1917. // Create the texture viewer
  1918. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  1919. // canvas
  1920. _this._canvas = INSPECTOR.Helpers.CreateElement('canvas', 'texture-viewer-img', _this._textureDiv);
  1921. if (tex) {
  1922. _this._textureUrl = tex.name;
  1923. }
  1924. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  1925. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  1926. return _this;
  1927. }
  1928. CubeTextureElement.prototype.update = function (tex) {
  1929. if (tex && tex.url === this._textureUrl) {
  1930. // Nothing to do, as the old texture is the same as the old one
  1931. }
  1932. else {
  1933. if (tex) {
  1934. this._textureUrl = tex.name;
  1935. }
  1936. if (this._engine) {
  1937. // Dispose old material and cube
  1938. this._cube.material.dispose(true, true);
  1939. this._cube.dispose();
  1940. }
  1941. else {
  1942. this._initEngine();
  1943. }
  1944. // and create it again
  1945. this._populateScene();
  1946. }
  1947. };
  1948. /** Creates the box */
  1949. CubeTextureElement.prototype._populateScene = function () {
  1950. var _this = this;
  1951. // Create the hdr texture
  1952. var hdrTexture = new BABYLON.CubeTexture(this._textureUrl, this._scene);
  1953. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  1954. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  1955. var hdrSkyboxMaterial = new BABYLON.StandardMaterial("skyBox", this._scene);
  1956. hdrSkyboxMaterial.backFaceCulling = false;
  1957. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  1958. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  1959. hdrSkyboxMaterial.disableLighting = true;
  1960. this._cube.material = hdrSkyboxMaterial;
  1961. this._cube.registerBeforeRender(function () {
  1962. _this._cube.rotation.y += 0.01;
  1963. });
  1964. };
  1965. /** Init the babylon engine */
  1966. CubeTextureElement.prototype._initEngine = function () {
  1967. var _this = this;
  1968. this._engine = new BABYLON.Engine(this._canvas);
  1969. this._scene = new BABYLON.Scene(this._engine);
  1970. this._scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
  1971. var cam = new BABYLON.FreeCamera('cam', new BABYLON.Vector3(0, 0, -20), this._scene);
  1972. var light = new BABYLON.HemisphericLight('', new BABYLON.Vector3(0, 1, 0), this._scene);
  1973. this._engine.runRenderLoop(function () {
  1974. if (!_this._pause) {
  1975. _this._scene.render();
  1976. }
  1977. });
  1978. this._canvas.setAttribute('width', '110');
  1979. this._canvas.setAttribute('height', '110');
  1980. };
  1981. CubeTextureElement.prototype._showViewer = function (mode) {
  1982. // If displaying...
  1983. if (mode != 'none') {
  1984. // ... and the canvas is not initialized
  1985. if (!this._engine) {
  1986. this._initEngine();
  1987. this._populateScene();
  1988. }
  1989. // In every cases, unpause the engine
  1990. this._pause = false;
  1991. }
  1992. else {
  1993. // hide : pause the engine
  1994. this._pause = true;
  1995. }
  1996. this._textureDiv.style.display = mode;
  1997. };
  1998. /** Removes properly the babylon engine */
  1999. CubeTextureElement.prototype.dispose = function () {
  2000. if (this._engine) {
  2001. this._engine.dispose();
  2002. this._engine = null;
  2003. }
  2004. };
  2005. return CubeTextureElement;
  2006. }(INSPECTOR.BasicElement));
  2007. INSPECTOR.CubeTextureElement = CubeTextureElement;
  2008. })(INSPECTOR || (INSPECTOR = {}));
  2009. //# sourceMappingURL=CubeTextureElement.js.map
  2010. var __extends = (this && this.__extends) || (function () {
  2011. var extendStatics = Object.setPrototypeOf ||
  2012. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2013. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2014. return function (d, b) {
  2015. extendStatics(d, b);
  2016. function __() { this.constructor = d; }
  2017. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2018. };
  2019. })();
  2020. var INSPECTOR;
  2021. (function (INSPECTOR) {
  2022. /**
  2023. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  2024. * cube texture in a cube
  2025. */
  2026. var HDRCubeTextureElement = (function (_super) {
  2027. __extends(HDRCubeTextureElement, _super);
  2028. /** The texture given as a parameter should be cube. */
  2029. function HDRCubeTextureElement(tex) {
  2030. return _super.call(this, tex) || this;
  2031. }
  2032. /** Creates the box */
  2033. HDRCubeTextureElement.prototype._populateScene = function () {
  2034. var _this = this;
  2035. // Create the hdr texture
  2036. var hdrTexture = new BABYLON.HDRCubeTexture(this._textureUrl, this._scene, 512);
  2037. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2038. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  2039. var hdrSkyboxMaterial = new BABYLON.PBRMaterial("skyBox", this._scene);
  2040. hdrSkyboxMaterial.backFaceCulling = false;
  2041. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  2042. hdrSkyboxMaterial.microSurface = 1.0;
  2043. hdrSkyboxMaterial.disableLighting = true;
  2044. this._cube.material = hdrSkyboxMaterial;
  2045. this._cube.registerBeforeRender(function () {
  2046. _this._cube.rotation.y += 0.01;
  2047. });
  2048. };
  2049. return HDRCubeTextureElement;
  2050. }(INSPECTOR.CubeTextureElement));
  2051. INSPECTOR.HDRCubeTextureElement = HDRCubeTextureElement;
  2052. })(INSPECTOR || (INSPECTOR = {}));
  2053. var __extends = (this && this.__extends) || (function () {
  2054. var extendStatics = Object.setPrototypeOf ||
  2055. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2056. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2057. return function (d, b) {
  2058. extendStatics(d, b);
  2059. function __() { this.constructor = d; }
  2060. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2061. };
  2062. })();
  2063. var INSPECTOR;
  2064. (function (INSPECTOR) {
  2065. /**
  2066. * A search bar can be used to filter elements in the tree panel.
  2067. * At each keypress on the input, the treepanel will be filtered.
  2068. */
  2069. var SearchBar = (function (_super) {
  2070. __extends(SearchBar, _super);
  2071. function SearchBar(tab) {
  2072. var _this = _super.call(this) || this;
  2073. _this._tab = tab;
  2074. _this._div.classList.add('searchbar');
  2075. var filter = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  2076. filter.className = 'fa fa-search';
  2077. _this._div.appendChild(filter);
  2078. // Create input
  2079. _this._inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  2080. _this._inputElement.placeholder = 'Filter by name...';
  2081. _this._div.appendChild(_this._inputElement);
  2082. _this._inputElement.addEventListener('keyup', function (evt) {
  2083. var filter = _this._inputElement.value;
  2084. _this._tab.filter(filter);
  2085. });
  2086. return _this;
  2087. }
  2088. /** Delete all characters typped in the input element */
  2089. SearchBar.prototype.reset = function () {
  2090. this._inputElement.value = '';
  2091. };
  2092. SearchBar.prototype.update = function () {
  2093. // Nothing to update
  2094. };
  2095. return SearchBar;
  2096. }(INSPECTOR.BasicElement));
  2097. INSPECTOR.SearchBar = SearchBar;
  2098. })(INSPECTOR || (INSPECTOR = {}));
  2099. var __extends = (this && this.__extends) || (function () {
  2100. var extendStatics = Object.setPrototypeOf ||
  2101. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2102. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2103. return function (d, b) {
  2104. extendStatics(d, b);
  2105. function __() { this.constructor = d; }
  2106. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2107. };
  2108. })();
  2109. var INSPECTOR;
  2110. (function (INSPECTOR) {
  2111. /**
  2112. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  2113. */
  2114. var TextureElement = (function (_super) {
  2115. __extends(TextureElement, _super);
  2116. function TextureElement(tex) {
  2117. var _this = _super.call(this) || this;
  2118. _this._div.className = 'fa fa-search texture-element';
  2119. // Create the texture viewer
  2120. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  2121. // Img
  2122. var imgDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer-img', _this._textureDiv);
  2123. // Texture size
  2124. var sizeDiv = INSPECTOR.Helpers.CreateDiv(null, _this._textureDiv);
  2125. if (tex) {
  2126. sizeDiv.textContent = tex.getBaseSize().width + "px x " + tex.getBaseSize().height + "px";
  2127. imgDiv.style.backgroundImage = "url('" + tex.url + "')";
  2128. imgDiv.style.width = tex.getBaseSize().width + "px";
  2129. imgDiv.style.height = tex.getBaseSize().height + "px";
  2130. }
  2131. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  2132. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  2133. return _this;
  2134. }
  2135. TextureElement.prototype.update = function (tex) {
  2136. };
  2137. TextureElement.prototype._showViewer = function (mode) {
  2138. this._textureDiv.style.display = mode;
  2139. };
  2140. return TextureElement;
  2141. }(INSPECTOR.BasicElement));
  2142. INSPECTOR.TextureElement = TextureElement;
  2143. })(INSPECTOR || (INSPECTOR = {}));
  2144. var INSPECTOR;
  2145. (function (INSPECTOR) {
  2146. /**
  2147. * Creates a tooltip for the parent of the given html element
  2148. */
  2149. var Tooltip = (function () {
  2150. function Tooltip(elem, tip, attachTo) {
  2151. var _this = this;
  2152. this._elem = elem;
  2153. if (!attachTo) {
  2154. attachTo = this._elem.parentElement;
  2155. }
  2156. this._infoDiv = INSPECTOR.Helpers.CreateDiv('tooltip', attachTo);
  2157. this._elem.addEventListener('mouseover', function () {
  2158. _this._infoDiv.textContent = tip;
  2159. _this._infoDiv.style.display = 'block';
  2160. });
  2161. this._elem.addEventListener('mouseout', function () { _this._infoDiv.style.display = 'none'; });
  2162. }
  2163. return Tooltip;
  2164. }());
  2165. INSPECTOR.Tooltip = Tooltip;
  2166. })(INSPECTOR || (INSPECTOR = {}));
  2167. var INSPECTOR;
  2168. (function (INSPECTOR) {
  2169. var Helpers = (function () {
  2170. function Helpers() {
  2171. }
  2172. /**
  2173. * Returns the type of the given object. First
  2174. * uses getClassName. If nothing is returned, used the type of the constructor
  2175. */
  2176. Helpers.GET_TYPE = function (obj) {
  2177. if (obj != null && obj != undefined) {
  2178. var classname = BABYLON.Tools.getClassName(obj);
  2179. if (!classname || classname === 'object') {
  2180. classname = obj.constructor.name;
  2181. // classname is undefined in IE11
  2182. if (!classname) {
  2183. classname = this._GetFnName(obj.constructor);
  2184. }
  2185. }
  2186. // If the class name has no matching properties, check every type
  2187. if (!this._CheckIfTypeExists(classname)) {
  2188. return this._GetTypeFor(obj);
  2189. }
  2190. return classname;
  2191. }
  2192. else {
  2193. return 'type_not_defined';
  2194. }
  2195. };
  2196. /**
  2197. * Check if some properties are defined for the given type.
  2198. */
  2199. Helpers._CheckIfTypeExists = function (type) {
  2200. var properties = INSPECTOR.PROPERTIES[type];
  2201. if (properties) {
  2202. return true;
  2203. }
  2204. return false;
  2205. };
  2206. /**
  2207. * Returns true if the user browser is edge.
  2208. */
  2209. Helpers.IsBrowserEdge = function () {
  2210. //Detect if we are running on a faulty buggy OS.
  2211. var regexp = /Edge/;
  2212. return regexp.test(navigator.userAgent);
  2213. };
  2214. /**
  2215. * Returns the name of the type of the given object, where the name
  2216. * is in PROPERTIES constant.
  2217. * Returns 'Undefined' if no type exists for this object
  2218. */
  2219. Helpers._GetTypeFor = function (obj) {
  2220. for (var type in INSPECTOR.PROPERTIES) {
  2221. var typeBlock = INSPECTOR.PROPERTIES[type];
  2222. if (typeBlock.type) {
  2223. if (obj instanceof typeBlock.type) {
  2224. return type;
  2225. }
  2226. }
  2227. }
  2228. return 'type_not_defined';
  2229. };
  2230. /**
  2231. * Returns the name of a function (workaround to get object type for IE11)
  2232. */
  2233. Helpers._GetFnName = function (fn) {
  2234. var f = typeof fn == 'function';
  2235. var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
  2236. return (!f && 'not a function') || (s && s[1] || 'anonymous');
  2237. };
  2238. /** Send the event which name is given in parameter to the window */
  2239. Helpers.SEND_EVENT = function (eventName) {
  2240. var event;
  2241. if (INSPECTOR.Inspector.DOCUMENT.createEvent) {
  2242. event = INSPECTOR.Inspector.DOCUMENT.createEvent('HTMLEvents');
  2243. event.initEvent(eventName, true, true);
  2244. }
  2245. else {
  2246. event = new Event(eventName);
  2247. }
  2248. window.dispatchEvent(event);
  2249. };
  2250. /** Returns the given number with 2 decimal number max if a decimal part exists */
  2251. Helpers.Trunc = function (nb) {
  2252. if (Math.round(nb) !== nb) {
  2253. return nb.toFixed(2);
  2254. }
  2255. return nb;
  2256. };
  2257. ;
  2258. /**
  2259. * Useful function used to create a div
  2260. */
  2261. Helpers.CreateDiv = function (className, parent) {
  2262. return Helpers.CreateElement('div', className, parent);
  2263. };
  2264. Helpers.CreateElement = function (element, className, parent) {
  2265. var elem = INSPECTOR.Inspector.DOCUMENT.createElement(element);
  2266. if (className) {
  2267. elem.className = className;
  2268. }
  2269. if (parent) {
  2270. parent.appendChild(elem);
  2271. }
  2272. return elem;
  2273. };
  2274. /**
  2275. * Removes all children of the given div.
  2276. */
  2277. Helpers.CleanDiv = function (div) {
  2278. while (div.firstChild) {
  2279. div.removeChild(div.firstChild);
  2280. }
  2281. };
  2282. /**
  2283. * 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)
  2284. */
  2285. Helpers.Css = function (elem, cssAttribute) {
  2286. var clone = elem.cloneNode(true);
  2287. var div = Helpers.CreateDiv('', INSPECTOR.Inspector.DOCUMENT.body);
  2288. div.style.display = 'none';
  2289. div.appendChild(clone);
  2290. var value = INSPECTOR.Inspector.WINDOW.getComputedStyle(clone)[cssAttribute];
  2291. div.parentNode.removeChild(div);
  2292. return value;
  2293. };
  2294. Helpers.LoadScript = function () {
  2295. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js", function (elem) {
  2296. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2297. script.textContent = elem;
  2298. // Load glsl detection
  2299. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/languages/glsl.min.js", function (elem) {
  2300. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2301. script.textContent = elem;
  2302. // Load css style
  2303. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/zenburn.min.css", function (elem) {
  2304. var style = Helpers.CreateElement('style', '', INSPECTOR.Inspector.DOCUMENT.body);
  2305. style.textContent = elem;
  2306. });
  2307. }, null, null, null, function () {
  2308. console.log("erreur");
  2309. });
  2310. }, null, null, null, function () {
  2311. console.log("erreur");
  2312. });
  2313. };
  2314. Helpers.IsSystemName = function (name) {
  2315. if (name == null) {
  2316. return false;
  2317. }
  2318. return name.indexOf("###") === 0 && name.lastIndexOf("###") === (name.length - 3);
  2319. };
  2320. return Helpers;
  2321. }());
  2322. INSPECTOR.Helpers = Helpers;
  2323. })(INSPECTOR || (INSPECTOR = {}));
  2324. var INSPECTOR;
  2325. (function (INSPECTOR) {
  2326. var Scheduler = (function () {
  2327. function Scheduler() {
  2328. /** Is this scheduler in pause ? */
  2329. this.pause = false;
  2330. /** The list of data to update */
  2331. this._updatableProperties = [];
  2332. this._timer = setInterval(this._update.bind(this), Scheduler.REFRESH_TIME);
  2333. }
  2334. Scheduler.getInstance = function () {
  2335. if (!Scheduler._instance) {
  2336. Scheduler._instance = new Scheduler();
  2337. }
  2338. return Scheduler._instance;
  2339. };
  2340. /** Add a property line to be updated every X ms */
  2341. Scheduler.prototype.add = function (prop) {
  2342. this._updatableProperties.push(prop);
  2343. };
  2344. /** Removes the given property from the list of properties to update */
  2345. Scheduler.prototype.remove = function (prop) {
  2346. var index = this._updatableProperties.indexOf(prop);
  2347. if (index != -1) {
  2348. this._updatableProperties.splice(index, 1);
  2349. }
  2350. };
  2351. Scheduler.prototype._update = function () {
  2352. // If not in pause, update
  2353. if (!this.pause) {
  2354. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  2355. var prop = _a[_i];
  2356. prop.update();
  2357. }
  2358. }
  2359. };
  2360. return Scheduler;
  2361. }());
  2362. /** All properties are refreshed every 250ms */
  2363. Scheduler.REFRESH_TIME = 250;
  2364. INSPECTOR.Scheduler = Scheduler;
  2365. })(INSPECTOR || (INSPECTOR = {}));
  2366. var __extends = (this && this.__extends) || (function () {
  2367. var extendStatics = Object.setPrototypeOf ||
  2368. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2369. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2370. return function (d, b) {
  2371. extendStatics(d, b);
  2372. function __() { this.constructor = d; }
  2373. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2374. };
  2375. })();
  2376. var INSPECTOR;
  2377. (function (INSPECTOR) {
  2378. var Tab = (function (_super) {
  2379. __extends(Tab, _super);
  2380. function Tab(tabbar, name) {
  2381. var _this = _super.call(this) || this;
  2382. _this._isActive = false;
  2383. _this._tabbar = tabbar;
  2384. _this.name = name;
  2385. _this._build();
  2386. return _this;
  2387. }
  2388. /** True if the tab is active, false otherwise */
  2389. Tab.prototype.isActive = function () {
  2390. return this._isActive;
  2391. };
  2392. Tab.prototype._build = function () {
  2393. var _this = this;
  2394. this._div.className = 'tab';
  2395. this._div.textContent = this.name;
  2396. this._div.addEventListener('click', function (evt) {
  2397. // Set this tab as active
  2398. _this._tabbar.switchTab(_this);
  2399. });
  2400. };
  2401. /** Set this tab as active or not, depending on the current state */
  2402. Tab.prototype.active = function (b) {
  2403. if (b) {
  2404. this._div.classList.add('active');
  2405. }
  2406. else {
  2407. this._div.classList.remove('active');
  2408. }
  2409. this._isActive = b;
  2410. };
  2411. Tab.prototype.update = function () {
  2412. // Nothing for the moment
  2413. };
  2414. /** Creates the tab panel for this tab. */
  2415. Tab.prototype.getPanel = function () {
  2416. return this._panel;
  2417. };
  2418. /** Add this in the propertytab with the searchbar */
  2419. Tab.prototype.filter = function (str) { };
  2420. ;
  2421. /** Select an item in the tree */
  2422. Tab.prototype.select = function (item) {
  2423. // To define in subclasses if needed
  2424. };
  2425. /** Highlight the given node, and downplay all others */
  2426. Tab.prototype.highlightNode = function (item) {
  2427. // To define in subclasses if needed
  2428. };
  2429. /**
  2430. * Returns the total width in pixel of this tab, 0 by default
  2431. */
  2432. Tab.prototype.getPixelWidth = function () {
  2433. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._div);
  2434. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  2435. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  2436. return (this._div.clientWidth || 0) + left + right;
  2437. };
  2438. return Tab;
  2439. }(INSPECTOR.BasicElement));
  2440. INSPECTOR.Tab = Tab;
  2441. })(INSPECTOR || (INSPECTOR = {}));
  2442. var __extends = (this && this.__extends) || (function () {
  2443. var extendStatics = Object.setPrototypeOf ||
  2444. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2445. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2446. return function (d, b) {
  2447. extendStatics(d, b);
  2448. function __() { this.constructor = d; }
  2449. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2450. };
  2451. })();
  2452. var INSPECTOR;
  2453. (function (INSPECTOR) {
  2454. /**
  2455. * A Property tab can creates two panels:
  2456. * a tree panel and a detail panel,
  2457. * in which properties will be displayed.
  2458. * Both panels are separated by a resize bar
  2459. */
  2460. var PropertyTab = (function (_super) {
  2461. __extends(PropertyTab, _super);
  2462. function PropertyTab(tabbar, name, insp) {
  2463. var _this = _super.call(this, tabbar, name) || this;
  2464. _this._treeItems = [];
  2465. _this._inspector = insp;
  2466. // Build the properties panel : a div that will contains the tree and the detail panel
  2467. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2468. _this._panel.classList.add('searchable');
  2469. // Search bar
  2470. _this._searchBar = new INSPECTOR.SearchBar(_this);
  2471. // Add searchbar
  2472. _this._panel.appendChild(_this._searchBar.toHtml());
  2473. // Build the treepanel
  2474. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  2475. // Build the detail panel
  2476. _this._detailsPanel = new INSPECTOR.DetailPanel();
  2477. _this._panel.appendChild(_this._detailsPanel.toHtml());
  2478. Split([_this._treePanel, _this._detailsPanel.toHtml()], {
  2479. blockDrag: _this._inspector.popupMode,
  2480. direction: 'vertical'
  2481. });
  2482. _this.update();
  2483. return _this;
  2484. }
  2485. /** Overrides dispose */
  2486. PropertyTab.prototype.dispose = function () {
  2487. this._detailsPanel.dispose();
  2488. };
  2489. PropertyTab.prototype.update = function (_items) {
  2490. var items;
  2491. if (_items) {
  2492. items = _items;
  2493. }
  2494. else {
  2495. // Rebuild the tree
  2496. this._treeItems = this._getTree();
  2497. items = this._treeItems;
  2498. }
  2499. // Clean the tree
  2500. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  2501. // Clean the detail properties
  2502. this._detailsPanel.clean();
  2503. // Sort items alphabetically
  2504. items.sort(function (item1, item2) {
  2505. return item1.compareTo(item2);
  2506. });
  2507. // Display items
  2508. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  2509. var item = items_1[_i];
  2510. this._treePanel.appendChild(item.toHtml());
  2511. }
  2512. };
  2513. /** Display the details of the given item */
  2514. PropertyTab.prototype.displayDetails = function (item) {
  2515. // Remove active state on all items
  2516. this.activateNode(item);
  2517. // Update the detail panel
  2518. this._detailsPanel.details = item.getDetails();
  2519. };
  2520. /** Select an item in the tree */
  2521. PropertyTab.prototype.select = function (item) {
  2522. // Remove the node highlight
  2523. this.highlightNode();
  2524. // Active the node
  2525. this.activateNode(item);
  2526. // Display its details
  2527. this.displayDetails(item);
  2528. };
  2529. /** Highlight the given node, and downplay all others */
  2530. PropertyTab.prototype.highlightNode = function (item) {
  2531. if (this._treeItems) {
  2532. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2533. var node = _a[_i];
  2534. node.highlight(false);
  2535. }
  2536. }
  2537. if (item) {
  2538. item.highlight(true);
  2539. }
  2540. };
  2541. /** Set the given item as active in the tree */
  2542. PropertyTab.prototype.activateNode = function (item) {
  2543. if (this._treeItems) {
  2544. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2545. var node = _a[_i];
  2546. node.active(false);
  2547. }
  2548. }
  2549. item.active(true);
  2550. };
  2551. /** Returns the treeitem corersponding to the given obj, null if not found */
  2552. PropertyTab.prototype.getItemFor = function (_obj) {
  2553. var obj = _obj;
  2554. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2555. var item = _a[_i];
  2556. if (item.correspondsTo(obj)) {
  2557. return item;
  2558. }
  2559. }
  2560. return null;
  2561. };
  2562. PropertyTab.prototype.filter = function (filter) {
  2563. var items = [];
  2564. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2565. var item = _a[_i];
  2566. if (item.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2567. items.push(item);
  2568. }
  2569. for (var _b = 0, _c = item.children; _b < _c.length; _b++) {
  2570. var child = _c[_b];
  2571. if (child.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2572. items.push(item);
  2573. }
  2574. }
  2575. }
  2576. this.update(items);
  2577. };
  2578. return PropertyTab;
  2579. }(INSPECTOR.Tab));
  2580. INSPECTOR.PropertyTab = PropertyTab;
  2581. })(INSPECTOR || (INSPECTOR = {}));
  2582. var __extends = (this && this.__extends) || (function () {
  2583. var extendStatics = Object.setPrototypeOf ||
  2584. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2585. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2586. return function (d, b) {
  2587. extendStatics(d, b);
  2588. function __() { this.constructor = d; }
  2589. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2590. };
  2591. })();
  2592. var INSPECTOR;
  2593. (function (INSPECTOR) {
  2594. var CameraTab = (function (_super) {
  2595. __extends(CameraTab, _super);
  2596. function CameraTab(tabbar, inspector) {
  2597. return _super.call(this, tabbar, 'Camera', inspector) || this;
  2598. }
  2599. /* Overrides super */
  2600. CameraTab.prototype._getTree = function () {
  2601. var arr = [];
  2602. // get all cameras from the first scene
  2603. var instances = this._inspector.scene;
  2604. for (var _i = 0, _a = instances.cameras; _i < _a.length; _i++) {
  2605. var camera = _a[_i];
  2606. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.CameraAdapter(camera)));
  2607. }
  2608. return arr;
  2609. };
  2610. return CameraTab;
  2611. }(INSPECTOR.PropertyTab));
  2612. INSPECTOR.CameraTab = CameraTab;
  2613. })(INSPECTOR || (INSPECTOR = {}));
  2614. var __extends = (this && this.__extends) || (function () {
  2615. var extendStatics = Object.setPrototypeOf ||
  2616. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2617. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2618. return function (d, b) {
  2619. extendStatics(d, b);
  2620. function __() { this.constructor = d; }
  2621. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2622. };
  2623. })();
  2624. var INSPECTOR;
  2625. (function (INSPECTOR) {
  2626. var SoundTab = (function (_super) {
  2627. __extends(SoundTab, _super);
  2628. function SoundTab(tabbar, inspector) {
  2629. return _super.call(this, tabbar, 'Audio', inspector) || this;
  2630. }
  2631. /* Overrides super */
  2632. SoundTab.prototype._getTree = function () {
  2633. var _this = this;
  2634. var arr = [];
  2635. // get all cameras from the first scene
  2636. var instances = this._inspector.scene;
  2637. for (var _i = 0, _a = instances.soundTracks; _i < _a.length; _i++) {
  2638. var sounds = _a[_i];
  2639. var sound = sounds.soundCollection;
  2640. sound.forEach(function (element) {
  2641. arr.push(new INSPECTOR.TreeItem(_this, new INSPECTOR.SoundAdapter(element)));
  2642. });
  2643. }
  2644. return arr;
  2645. };
  2646. return SoundTab;
  2647. }(INSPECTOR.PropertyTab));
  2648. INSPECTOR.SoundTab = SoundTab;
  2649. })(INSPECTOR || (INSPECTOR = {}));
  2650. var __extends = (this && this.__extends) || (function () {
  2651. var extendStatics = Object.setPrototypeOf ||
  2652. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2653. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2654. return function (d, b) {
  2655. extendStatics(d, b);
  2656. function __() { this.constructor = d; }
  2657. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2658. };
  2659. })();
  2660. var INSPECTOR;
  2661. (function (INSPECTOR) {
  2662. var TextureTab = (function (_super) {
  2663. __extends(TextureTab, _super);
  2664. function TextureTab(tabbar, inspector) {
  2665. var _this = _super.call(this, tabbar, 'Textures') || this;
  2666. _this._treeItems = [];
  2667. _this._inspector = inspector;
  2668. // Build the properties panel : a div that will contains the tree and the detail panel
  2669. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2670. // Build the treepanel
  2671. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  2672. _this._imagePanel = INSPECTOR.Helpers.CreateDiv('image-panel', _this._panel);
  2673. Split([_this._treePanel, _this._imagePanel], {
  2674. blockDrag: _this._inspector.popupMode,
  2675. direction: 'vertical'
  2676. });
  2677. _this.update();
  2678. return _this;
  2679. }
  2680. TextureTab.prototype.dispose = function () {
  2681. // Nothing to dispose
  2682. };
  2683. TextureTab.prototype.update = function (_items) {
  2684. var items;
  2685. if (_items) {
  2686. items = _items;
  2687. }
  2688. else {
  2689. // Rebuild the tree
  2690. this._treeItems = this._getTree();
  2691. items = this._treeItems;
  2692. }
  2693. // Clean the tree
  2694. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  2695. INSPECTOR.Helpers.CleanDiv(this._imagePanel);
  2696. // Sort items alphabetically
  2697. items.sort(function (item1, item2) {
  2698. return item1.compareTo(item2);
  2699. });
  2700. // Display items
  2701. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  2702. var item = items_1[_i];
  2703. this._treePanel.appendChild(item.toHtml());
  2704. }
  2705. };
  2706. /* Overrides super */
  2707. TextureTab.prototype._getTree = function () {
  2708. var arr = [];
  2709. // get all cameras from the first scene
  2710. var instances = this._inspector.scene;
  2711. for (var _i = 0, _a = instances.textures; _i < _a.length; _i++) {
  2712. var tex = _a[_i];
  2713. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.TextureAdapter(tex)));
  2714. }
  2715. return arr;
  2716. };
  2717. /** Display the details of the given item */
  2718. TextureTab.prototype.displayDetails = function (item) {
  2719. // Remove active state on all items
  2720. this.activateNode(item);
  2721. INSPECTOR.Helpers.CleanDiv(this._imagePanel);
  2722. // Get the texture object
  2723. var texture = item.adapter.object;
  2724. var img = INSPECTOR.Helpers.CreateElement('img', 'texture-image', this._imagePanel);
  2725. if (texture instanceof BABYLON.MapTexture) {
  2726. // instance of Map texture
  2727. texture.bindTextureForPosSize(new BABYLON.Vector2(0, 0), new BABYLON.Size(texture.getSize().width, texture.getSize().height), false);
  2728. BABYLON.Tools.DumpFramebuffer(texture.getSize().width, texture.getSize().height, this._inspector.scene.getEngine(), function (data) { return img.src = data; });
  2729. texture.unbindTexture();
  2730. }
  2731. else if (texture instanceof BABYLON.RenderTargetTexture) {
  2732. // RenderTarget textures
  2733. BABYLON.Tools.CreateScreenshotUsingRenderTarget(this._inspector.scene.getEngine(), texture.activeCamera, { precision: 1 }, function (data) { return img.src = data; });
  2734. }
  2735. else if (texture.url) {
  2736. // If an url is present, the texture is an image
  2737. img.src = texture.url;
  2738. }
  2739. else if (texture['_canvas']) {
  2740. // Dynamic texture
  2741. var base64Image = texture['_canvas'].toDataURL("image/png");
  2742. img.src = base64Image;
  2743. }
  2744. };
  2745. /** Select an item in the tree */
  2746. TextureTab.prototype.select = function (item) {
  2747. // Remove the node highlight
  2748. this.highlightNode();
  2749. // Active the node
  2750. this.activateNode(item);
  2751. // Display its details
  2752. this.displayDetails(item);
  2753. };
  2754. /** Set the given item as active in the tree */
  2755. TextureTab.prototype.activateNode = function (item) {
  2756. if (this._treeItems) {
  2757. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2758. var node = _a[_i];
  2759. node.active(false);
  2760. }
  2761. }
  2762. item.active(true);
  2763. };
  2764. /** Highlight the given node, and downplay all others */
  2765. TextureTab.prototype.highlightNode = function (item) {
  2766. if (this._treeItems) {
  2767. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2768. var node = _a[_i];
  2769. node.highlight(false);
  2770. }
  2771. }
  2772. if (item) {
  2773. item.highlight(true);
  2774. }
  2775. };
  2776. return TextureTab;
  2777. }(INSPECTOR.Tab));
  2778. INSPECTOR.TextureTab = TextureTab;
  2779. })(INSPECTOR || (INSPECTOR = {}));
  2780. var __extends = (this && this.__extends) || (function () {
  2781. var extendStatics = Object.setPrototypeOf ||
  2782. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2783. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2784. return function (d, b) {
  2785. extendStatics(d, b);
  2786. function __() { this.constructor = d; }
  2787. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2788. };
  2789. })();
  2790. var INSPECTOR;
  2791. (function (INSPECTOR) {
  2792. var Canvas2DTab = (function (_super) {
  2793. __extends(Canvas2DTab, _super);
  2794. function Canvas2DTab(tabbar, inspector) {
  2795. return _super.call(this, tabbar, 'Canvas2D', inspector) || this;
  2796. }
  2797. /* Overrides */
  2798. Canvas2DTab.prototype._getTree = function () {
  2799. var _this = this;
  2800. var arr = [];
  2801. // get all canvas2D
  2802. var instances = BABYLON.Canvas2D.instances || [];
  2803. // Recursive method building the tree panel
  2804. var createNode = function (obj) {
  2805. if (obj.children && obj.children.length > 0) {
  2806. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.Canvas2DAdapter(obj));
  2807. for (var _i = 0, _a = obj.children; _i < _a.length; _i++) {
  2808. var child = _a[_i];
  2809. if (!INSPECTOR.Helpers.IsSystemName(child.id)) {
  2810. var n = createNode(child);
  2811. node.add(n);
  2812. }
  2813. }
  2814. node.update();
  2815. return node;
  2816. }
  2817. else {
  2818. return new INSPECTOR.TreeItem(_this, new INSPECTOR.Canvas2DAdapter(obj));
  2819. }
  2820. };
  2821. for (var _i = 0, instances_1 = instances; _i < instances_1.length; _i++) {
  2822. var inst = instances_1[_i];
  2823. if (INSPECTOR.Helpers.IsSystemName(inst.id)) {
  2824. continue;
  2825. }
  2826. var c2d = inst;
  2827. var nodes = createNode(c2d);
  2828. arr.push(nodes);
  2829. }
  2830. return arr;
  2831. };
  2832. return Canvas2DTab;
  2833. }(INSPECTOR.PropertyTab));
  2834. INSPECTOR.Canvas2DTab = Canvas2DTab;
  2835. })(INSPECTOR || (INSPECTOR = {}));
  2836. var __extends = (this && this.__extends) || (function () {
  2837. var extendStatics = Object.setPrototypeOf ||
  2838. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2839. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2840. return function (d, b) {
  2841. extendStatics(d, b);
  2842. function __() { this.constructor = d; }
  2843. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2844. };
  2845. })();
  2846. var INSPECTOR;
  2847. (function (INSPECTOR) {
  2848. var LightTab = (function (_super) {
  2849. __extends(LightTab, _super);
  2850. function LightTab(tabbar, inspector) {
  2851. return _super.call(this, tabbar, 'Light', inspector) || this;
  2852. }
  2853. /* Overrides super */
  2854. LightTab.prototype._getTree = function () {
  2855. var arr = [];
  2856. // get all lights from the first scene
  2857. var instances = this._inspector.scene;
  2858. for (var _i = 0, _a = instances.lights; _i < _a.length; _i++) {
  2859. var light = _a[_i];
  2860. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.LightAdapter(light)));
  2861. }
  2862. return arr;
  2863. };
  2864. return LightTab;
  2865. }(INSPECTOR.PropertyTab));
  2866. INSPECTOR.LightTab = LightTab;
  2867. })(INSPECTOR || (INSPECTOR = {}));
  2868. var __extends = (this && this.__extends) || (function () {
  2869. var extendStatics = Object.setPrototypeOf ||
  2870. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2871. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2872. return function (d, b) {
  2873. extendStatics(d, b);
  2874. function __() { this.constructor = d; }
  2875. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2876. };
  2877. })();
  2878. var INSPECTOR;
  2879. (function (INSPECTOR) {
  2880. var MaterialTab = (function (_super) {
  2881. __extends(MaterialTab, _super);
  2882. function MaterialTab(tabbar, inspector) {
  2883. return _super.call(this, tabbar, 'Material', inspector) || this;
  2884. }
  2885. /* Overrides super */
  2886. MaterialTab.prototype._getTree = function () {
  2887. var arr = [];
  2888. // get all meshes from the first scene
  2889. var instances = this._inspector.scene;
  2890. for (var _i = 0, _a = instances.materials; _i < _a.length; _i++) {
  2891. var mat = _a[_i];
  2892. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.MaterialAdapter(mat)));
  2893. }
  2894. return arr;
  2895. };
  2896. return MaterialTab;
  2897. }(INSPECTOR.PropertyTab));
  2898. INSPECTOR.MaterialTab = MaterialTab;
  2899. })(INSPECTOR || (INSPECTOR = {}));
  2900. var __extends = (this && this.__extends) || (function () {
  2901. var extendStatics = Object.setPrototypeOf ||
  2902. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2903. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2904. return function (d, b) {
  2905. extendStatics(d, b);
  2906. function __() { this.constructor = d; }
  2907. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2908. };
  2909. })();
  2910. var INSPECTOR;
  2911. (function (INSPECTOR) {
  2912. var MeshTab = (function (_super) {
  2913. __extends(MeshTab, _super);
  2914. function MeshTab(tabbar, inspector) {
  2915. return _super.call(this, tabbar, 'Mesh', inspector) || this;
  2916. }
  2917. /* Overrides super */
  2918. MeshTab.prototype._getTree = function () {
  2919. var _this = this;
  2920. var arr = [];
  2921. // Tab containign mesh already in results
  2922. var alreadyIn = [];
  2923. // Returns true if the id of the given object starts and ends with '###'
  2924. var shouldExcludeThisMesh = function (obj) {
  2925. return (obj.name && obj.name.indexOf('###') == 0 && obj.name.lastIndexOf('###', 0) === 0);
  2926. };
  2927. // Recursive method building the tree panel
  2928. var createNode = function (obj) {
  2929. var descendants = obj.getDescendants(true);
  2930. if (descendants.length > 0) {
  2931. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.MeshAdapter(obj));
  2932. alreadyIn.push(node);
  2933. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  2934. var child = descendants_1[_i];
  2935. if (child instanceof BABYLON.AbstractMesh) {
  2936. if (!INSPECTOR.Helpers.IsSystemName(child.name)) {
  2937. var n = createNode(child);
  2938. node.add(n);
  2939. }
  2940. }
  2941. }
  2942. node.update();
  2943. return node;
  2944. }
  2945. else {
  2946. alreadyIn.push(obj);
  2947. return new INSPECTOR.TreeItem(_this, new INSPECTOR.MeshAdapter(obj));
  2948. }
  2949. };
  2950. // get all meshes from the first scene
  2951. var instances = this._inspector.scene;
  2952. for (var _i = 0, _a = instances.meshes; _i < _a.length; _i++) {
  2953. var mesh = _a[_i];
  2954. if (alreadyIn.indexOf(mesh) == -1) {
  2955. var node = createNode(mesh);
  2956. arr.push(node);
  2957. }
  2958. }
  2959. return arr;
  2960. };
  2961. return MeshTab;
  2962. }(INSPECTOR.PropertyTab));
  2963. INSPECTOR.MeshTab = MeshTab;
  2964. })(INSPECTOR || (INSPECTOR = {}));
  2965. var __extends = (this && this.__extends) || (function () {
  2966. var extendStatics = Object.setPrototypeOf ||
  2967. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2968. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2969. return function (d, b) {
  2970. extendStatics(d, b);
  2971. function __() { this.constructor = d; }
  2972. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2973. };
  2974. })();
  2975. var INSPECTOR;
  2976. (function (INSPECTOR) {
  2977. var SceneTab = (function (_super) {
  2978. __extends(SceneTab, _super);
  2979. function SceneTab(tabbar, insp) {
  2980. var _this = _super.call(this, tabbar, 'Scene') || this;
  2981. /** The list of skeleton viewer */
  2982. _this._skeletonViewers = [];
  2983. _this._inspector = insp;
  2984. // Build the properties panel : a div that will contains the tree and the detail panel
  2985. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2986. _this._actions = INSPECTOR.Helpers.CreateDiv('scene-actions', _this._panel);
  2987. _this._detailsPanel = new INSPECTOR.DetailPanel();
  2988. _this._panel.appendChild(_this._detailsPanel.toHtml());
  2989. // build propertiesline
  2990. var details = [];
  2991. for (var _i = 0, _a = INSPECTOR.PROPERTIES['Scene'].properties; _i < _a.length; _i++) {
  2992. var prop = _a[_i];
  2993. details.push(new INSPECTOR.PropertyLine(new INSPECTOR.Property(prop, _this._inspector.scene)));
  2994. }
  2995. _this._detailsPanel.details = details;
  2996. Split([_this._actions, _this._detailsPanel.toHtml()], {
  2997. blockDrag: _this._inspector.popupMode,
  2998. sizes: [50, 50],
  2999. direction: 'vertical'
  3000. });
  3001. // Build actions
  3002. {
  3003. // Rendering mode
  3004. var title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3005. title.textContent = 'Rendering mode';
  3006. var point = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3007. var wireframe = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3008. var solid = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3009. point.textContent = 'Point';
  3010. wireframe.textContent = 'Wireframe';
  3011. solid.textContent = 'Solid';
  3012. if (_this._inspector.scene.forcePointsCloud) {
  3013. point.classList.add('active');
  3014. }
  3015. else if (_this._inspector.scene.forceWireframe) {
  3016. wireframe.classList.add('active');
  3017. }
  3018. else {
  3019. solid.classList.add('active');
  3020. }
  3021. _this._generateRadioAction([point, wireframe, solid]);
  3022. point.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = true; _this._inspector.scene.forceWireframe = false; });
  3023. wireframe.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = true; });
  3024. solid.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = false; });
  3025. // Textures
  3026. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3027. title.textContent = 'Textures channels';
  3028. _this._generateActionLine('Diffuse Texture', BABYLON.StandardMaterial.DiffuseTextureEnabled, function (b) { BABYLON.StandardMaterial.DiffuseTextureEnabled = b; });
  3029. _this._generateActionLine('Ambient Texture', BABYLON.StandardMaterial.AmbientTextureEnabled, function (b) { BABYLON.StandardMaterial.AmbientTextureEnabled = b; });
  3030. _this._generateActionLine('Specular Texture', BABYLON.StandardMaterial.SpecularTextureEnabled, function (b) { BABYLON.StandardMaterial.SpecularTextureEnabled = b; });
  3031. _this._generateActionLine('Emissive Texture', BABYLON.StandardMaterial.EmissiveTextureEnabled, function (b) { BABYLON.StandardMaterial.EmissiveTextureEnabled = b; });
  3032. _this._generateActionLine('Bump Texture', BABYLON.StandardMaterial.BumpTextureEnabled, function (b) { BABYLON.StandardMaterial.BumpTextureEnabled = b; });
  3033. _this._generateActionLine('Opacity Texture', BABYLON.StandardMaterial.OpacityTextureEnabled, function (b) { BABYLON.StandardMaterial.OpacityTextureEnabled = b; });
  3034. _this._generateActionLine('Reflection Texture', BABYLON.StandardMaterial.ReflectionTextureEnabled, function (b) { BABYLON.StandardMaterial.ReflectionTextureEnabled = b; });
  3035. _this._generateActionLine('Refraction Texture', BABYLON.StandardMaterial.RefractionTextureEnabled, function (b) { BABYLON.StandardMaterial.RefractionTextureEnabled = b; });
  3036. _this._generateActionLine('ColorGrading', BABYLON.StandardMaterial.ColorGradingTextureEnabled, function (b) { BABYLON.StandardMaterial.ColorGradingTextureEnabled = b; });
  3037. _this._generateActionLine('Lightmap Texture', BABYLON.StandardMaterial.LightmapTextureEnabled, function (b) { BABYLON.StandardMaterial.LightmapTextureEnabled = b; });
  3038. _this._generateActionLine('Fresnel', BABYLON.StandardMaterial.FresnelEnabled, function (b) { BABYLON.StandardMaterial.FresnelEnabled = b; });
  3039. // Options
  3040. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3041. title.textContent = 'Options';
  3042. _this._generateActionLine('Animations', _this._inspector.scene.animationsEnabled, function (b) { _this._inspector.scene.animationsEnabled = b; });
  3043. _this._generateActionLine('Collisions', _this._inspector.scene.collisionsEnabled, function (b) { _this._inspector.scene.collisionsEnabled = b; });
  3044. _this._generateActionLine('Fog', _this._inspector.scene.fogEnabled, function (b) { _this._inspector.scene.fogEnabled = b; });
  3045. _this._generateActionLine('Lens flares', _this._inspector.scene.lensFlaresEnabled, function (b) { _this._inspector.scene.lensFlaresEnabled = b; });
  3046. _this._generateActionLine('Lights', _this._inspector.scene.lightsEnabled, function (b) { _this._inspector.scene.lightsEnabled = b; });
  3047. _this._generateActionLine('Particles', _this._inspector.scene.particlesEnabled, function (b) { _this._inspector.scene.particlesEnabled = b; });
  3048. _this._generateActionLine('Post-processes', _this._inspector.scene.postProcessesEnabled, function (b) { _this._inspector.scene.postProcessesEnabled = b; });
  3049. _this._generateActionLine('Probes', _this._inspector.scene.probesEnabled, function (b) { _this._inspector.scene.probesEnabled = b; });
  3050. _this._generateActionLine('Procedural textures', _this._inspector.scene.proceduralTexturesEnabled, function (b) { _this._inspector.scene.proceduralTexturesEnabled = b; });
  3051. _this._generateActionLine('Render targets', _this._inspector.scene.renderTargetsEnabled, function (b) { _this._inspector.scene.renderTargetsEnabled = b; });
  3052. _this._generateActionLine('Shadows', _this._inspector.scene.shadowsEnabled, function (b) { _this._inspector.scene.shadowsEnabled = b; });
  3053. _this._generateActionLine('Skeletons', _this._inspector.scene.skeletonsEnabled, function (b) { _this._inspector.scene.skeletonsEnabled = b; });
  3054. _this._generateActionLine('Sprites', _this._inspector.scene.spritesEnabled, function (b) { _this._inspector.scene.spritesEnabled = b; });
  3055. _this._generateActionLine('Textures', _this._inspector.scene.texturesEnabled, function (b) { _this._inspector.scene.texturesEnabled = b; });
  3056. // Audio
  3057. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3058. title.textContent = 'Audio';
  3059. var headphones = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3060. var normalSpeaker = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3061. _this._generateActionLine('Disable audio', !_this._inspector.scene.audioEnabled, function (b) { _this._inspector.scene.audioEnabled = !b; });
  3062. headphones.textContent = 'Headphones';
  3063. normalSpeaker.textContent = 'Normal speakers';
  3064. _this._generateRadioAction([headphones, normalSpeaker]);
  3065. if (_this._inspector.scene.headphone) {
  3066. headphones.classList.add('active');
  3067. }
  3068. else {
  3069. normalSpeaker.classList.add('active');
  3070. }
  3071. headphones.addEventListener('click', function () { _this._inspector.scene.headphone = true; });
  3072. normalSpeaker.addEventListener('click', function () { _this._inspector.scene.headphone = false; });
  3073. // Viewers
  3074. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3075. title.textContent = 'Viewer';
  3076. _this._generateActionLine('Skeletons', false, function (b) {
  3077. if (b) {
  3078. for (var index = 0; index < _this._inspector.scene.meshes.length; index++) {
  3079. var mesh = _this._inspector.scene.meshes[index];
  3080. if (mesh.skeleton) {
  3081. var found = false;
  3082. for (var sIndex = 0; sIndex < _this._skeletonViewers.length; sIndex++) {
  3083. if (_this._skeletonViewers[sIndex].skeleton === mesh.skeleton) {
  3084. found = true;
  3085. break;
  3086. }
  3087. }
  3088. if (found) {
  3089. continue;
  3090. }
  3091. var viewer = new BABYLON.Debug.SkeletonViewer(mesh.skeleton, mesh, _this._inspector.scene);
  3092. viewer.isEnabled = true;
  3093. _this._skeletonViewers.push(viewer);
  3094. }
  3095. }
  3096. }
  3097. else {
  3098. for (var index = 0; index < _this._skeletonViewers.length; index++) {
  3099. _this._skeletonViewers[index].dispose();
  3100. }
  3101. _this._skeletonViewers = [];
  3102. }
  3103. });
  3104. }
  3105. return _this;
  3106. }
  3107. /** Overrides super.dispose */
  3108. SceneTab.prototype.dispose = function () {
  3109. this._detailsPanel.dispose();
  3110. };
  3111. /** generates a div which correspond to an option that can be activated/deactivated */
  3112. SceneTab.prototype._generateActionLine = function (name, initValue, action) {
  3113. var div = INSPECTOR.Helpers.CreateDiv('scene-actions', this._actions);
  3114. div.textContent = name;
  3115. div.classList.add('action');
  3116. if (initValue) {
  3117. div.classList.add('active');
  3118. }
  3119. div.addEventListener('click', function (e) {
  3120. div.classList.toggle('active');
  3121. var isActivated = div.classList.contains('active');
  3122. action(isActivated);
  3123. });
  3124. };
  3125. /**
  3126. * Add a click action for all given elements :
  3127. * the clicked element is set as active, all others elements are deactivated
  3128. */
  3129. SceneTab.prototype._generateRadioAction = function (arr) {
  3130. var active = function (elem, evt) {
  3131. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  3132. var e = arr_1[_i];
  3133. e.classList.remove('active');
  3134. }
  3135. elem.classList.add('active');
  3136. };
  3137. for (var _i = 0, arr_2 = arr; _i < arr_2.length; _i++) {
  3138. var elem = arr_2[_i];
  3139. elem.addEventListener('click', active.bind(this, elem));
  3140. }
  3141. };
  3142. return SceneTab;
  3143. }(INSPECTOR.Tab));
  3144. INSPECTOR.SceneTab = SceneTab;
  3145. })(INSPECTOR || (INSPECTOR = {}));
  3146. var __extends = (this && this.__extends) || (function () {
  3147. var extendStatics = Object.setPrototypeOf ||
  3148. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3149. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3150. return function (d, b) {
  3151. extendStatics(d, b);
  3152. function __() { this.constructor = d; }
  3153. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3154. };
  3155. })();
  3156. var INSPECTOR;
  3157. (function (INSPECTOR) {
  3158. var ShaderTab = (function (_super) {
  3159. __extends(ShaderTab, _super);
  3160. function ShaderTab(tabbar, insp) {
  3161. var _this = _super.call(this, tabbar, 'Shader') || this;
  3162. _this._inspector = insp;
  3163. // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
  3164. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3165. var shaderPanel = INSPECTOR.Helpers.CreateDiv('shader-tree-panel');
  3166. _this._vertexPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
  3167. _this._fragmentPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
  3168. _this._panel.appendChild(shaderPanel);
  3169. _this._panel.appendChild(_this._vertexPanel);
  3170. _this._panel.appendChild(_this._fragmentPanel);
  3171. INSPECTOR.Helpers.LoadScript();
  3172. Split([_this._vertexPanel, _this._fragmentPanel], {
  3173. blockDrag: _this._inspector.popupMode,
  3174. sizes: [50, 50],
  3175. direction: 'vertical'
  3176. });
  3177. var comboBox = INSPECTOR.Helpers.CreateElement('select', '', shaderPanel);
  3178. comboBox.addEventListener('change', _this._selectShader.bind(_this));
  3179. var option = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
  3180. option.textContent = 'Select a shader';
  3181. option.setAttribute('value', "");
  3182. option.setAttribute('disabled', 'true');
  3183. option.setAttribute('selected', 'true');
  3184. // Build shaders combobox
  3185. for (var _i = 0, _a = _this._inspector.scene.materials; _i < _a.length; _i++) {
  3186. var mat = _a[_i];
  3187. if (mat instanceof BABYLON.ShaderMaterial) {
  3188. var option_1 = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
  3189. option_1.setAttribute('value', mat.id);
  3190. option_1.textContent = mat.name + " - " + mat.id;
  3191. }
  3192. }
  3193. return _this;
  3194. }
  3195. ShaderTab.prototype._selectShader = function (event) {
  3196. var id = event.target.value;
  3197. var mat = this._inspector.scene.getMaterialByID(id);
  3198. // Clean shader panel
  3199. INSPECTOR.Helpers.CleanDiv(this._vertexPanel);
  3200. // add the title - vertex shader
  3201. var title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._vertexPanel);
  3202. title.textContent = 'Vertex shader';
  3203. // add code
  3204. var code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._vertexPanel));
  3205. code.textContent = this._beautify(mat.getEffect().getVertexShaderSource());
  3206. INSPECTOR.Helpers.CleanDiv(this._fragmentPanel);
  3207. // add the title - fragment shader
  3208. title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._fragmentPanel);
  3209. title.textContent = 'Frgament shader';
  3210. // add code
  3211. code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._fragmentPanel));
  3212. code.textContent = this._beautify(mat.getEffect().getFragmentShaderSource());
  3213. // Init the syntax highlighting
  3214. var styleInit = INSPECTOR.Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  3215. styleInit.textContent = 'hljs.initHighlighting();';
  3216. };
  3217. /** Overrides super.dispose */
  3218. ShaderTab.prototype.dispose = function () {
  3219. };
  3220. /** Returns the position of the first { and the corresponding } */
  3221. ShaderTab.prototype._getBracket = function (str) {
  3222. var fb = str.indexOf('{');
  3223. var arr = str.substr(fb + 1).split('');
  3224. var counter = 1;
  3225. var currentPosInString = fb;
  3226. var lastBracketIndex = 0;
  3227. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  3228. var char = arr_1[_i];
  3229. currentPosInString++;
  3230. if (char === '{') {
  3231. counter++;
  3232. }
  3233. if (char === '}') {
  3234. counter--;
  3235. }
  3236. if (counter == 0) {
  3237. lastBracketIndex = currentPosInString;
  3238. break;
  3239. }
  3240. }
  3241. return { firstBracket: fb, lastBracket: lastBracketIndex };
  3242. };
  3243. /**
  3244. * Beautify the given string : correct indentation
  3245. */
  3246. ShaderTab.prototype._beautify = function (glsl, level) {
  3247. if (level === void 0) { level = 0; }
  3248. // return condition : no brackets at all
  3249. var brackets = this._getBracket(glsl);
  3250. var firstBracket = brackets.firstBracket;
  3251. var lastBracket = brackets.lastBracket;
  3252. var spaces = "";
  3253. for (var i = 0; i < level; i++) {
  3254. spaces += " "; // 4 spaces
  3255. }
  3256. // If no brackets, return the indented string
  3257. if (firstBracket == -1) {
  3258. glsl = spaces + glsl; // indent first line
  3259. glsl = glsl
  3260. .replace(/;./g, function (x) { return '\n' + x.substr(1); }); // new line after ; except the last one
  3261. glsl = glsl.replace(/=/g, " = "); // space around =
  3262. glsl = glsl.replace(/\n/g, "\n" + spaces); // indentation
  3263. return glsl;
  3264. }
  3265. else {
  3266. // if brackets, beautify the inside
  3267. // let insideWithBrackets = glsl.substr(firstBracket, lastBracket-firstBracket+1);
  3268. var left = glsl.substr(0, firstBracket);
  3269. var right = glsl.substr(lastBracket + 1, glsl.length);
  3270. var inside = glsl.substr(firstBracket + 1, lastBracket - firstBracket - 1);
  3271. inside = this._beautify(inside, level + 1);
  3272. return this._beautify(left, level) + '{\n' + inside + '\n' + spaces + '}\n' + this._beautify(right, level);
  3273. }
  3274. };
  3275. return ShaderTab;
  3276. }(INSPECTOR.Tab));
  3277. INSPECTOR.ShaderTab = ShaderTab;
  3278. })(INSPECTOR || (INSPECTOR = {}));
  3279. var __extends = (this && this.__extends) || (function () {
  3280. var extendStatics = Object.setPrototypeOf ||
  3281. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3282. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3283. return function (d, b) {
  3284. extendStatics(d, b);
  3285. function __() { this.constructor = d; }
  3286. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3287. };
  3288. })();
  3289. var INSPECTOR;
  3290. (function (INSPECTOR) {
  3291. /**
  3292. * The console tab will have two features :
  3293. * - hook all console.log call and display them in this panel (and in the browser console as well)
  3294. * - display all Babylon logs (called with Tools.Log...)
  3295. */
  3296. var ConsoleTab = (function (_super) {
  3297. __extends(ConsoleTab, _super);
  3298. function ConsoleTab(tabbar, insp) {
  3299. var _this = _super.call(this, tabbar, 'Console') || this;
  3300. _this._inspector = insp;
  3301. // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
  3302. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3303. var consolePanel = INSPECTOR.Helpers.CreateDiv('console-panel');
  3304. var bjsPanel = INSPECTOR.Helpers.CreateDiv('console-panel');
  3305. _this._panel.appendChild(consolePanel);
  3306. _this._panel.appendChild(bjsPanel);
  3307. Split([consolePanel, bjsPanel], {
  3308. blockDrag: _this._inspector.popupMode,
  3309. sizes: [50, 50],
  3310. direction: 'vertical'
  3311. });
  3312. // Titles
  3313. var title = INSPECTOR.Helpers.CreateDiv('console-panel-title', consolePanel);
  3314. title.textContent = 'Console logs';
  3315. title = INSPECTOR.Helpers.CreateDiv('console-panel-title', bjsPanel);
  3316. title.textContent = 'Babylon.js logs';
  3317. // Contents
  3318. _this._consolePanelContent = INSPECTOR.Helpers.CreateDiv('console-panel-content', consolePanel);
  3319. _this._bjsPanelContent = INSPECTOR.Helpers.CreateDiv('console-panel-content', bjsPanel);
  3320. // save old console.log
  3321. _this._oldConsoleLog = console.log;
  3322. _this._oldConsoleWarn = console.warn;
  3323. _this._oldConsoleError = console.error;
  3324. console.log = _this._addConsoleLog.bind(_this);
  3325. console.warn = _this._addConsoleWarn.bind(_this);
  3326. console.error = _this._addConsoleError.bind(_this);
  3327. // Bjs logs
  3328. _this._bjsPanelContent.innerHTML = BABYLON.Tools.LogCache;
  3329. BABYLON.Tools.OnNewCacheEntry = function (entry) {
  3330. _this._bjsPanelContent.innerHTML += entry;
  3331. _this._bjsPanelContent.scrollTop = _this._bjsPanelContent.scrollHeight;
  3332. };
  3333. return _this;
  3334. // Testing
  3335. //console.log("This is a console.log message");
  3336. // console.log("That's right, console.log calls are hooked to be written in this window");
  3337. // console.log("Object are also stringify-ed", {width:10, height:30, shape:'rectangular'});
  3338. // console.warn("This is a console.warn message");
  3339. // console.error("This is a console.error message");
  3340. // BABYLON.Tools.Log("This is a message");
  3341. // BABYLON.Tools.Warn("This is a warning");
  3342. // BABYLON.Tools.Error("This is a error");
  3343. }
  3344. /** Overrides super.dispose */
  3345. ConsoleTab.prototype.dispose = function () {
  3346. console.log = this._oldConsoleLog;
  3347. console.warn = this._oldConsoleWarn;
  3348. console.error = this._oldConsoleError;
  3349. };
  3350. ConsoleTab.prototype._message = function (type, message, caller) {
  3351. var callerLine = INSPECTOR.Helpers.CreateDiv('caller', this._consolePanelContent);
  3352. callerLine.textContent = caller;
  3353. var line = INSPECTOR.Helpers.CreateDiv(type, this._consolePanelContent);
  3354. line.textContent += message;
  3355. this._consolePanelContent.scrollTop = this._consolePanelContent.scrollHeight;
  3356. };
  3357. ConsoleTab.prototype._addConsoleLog = function () {
  3358. var params = [];
  3359. for (var _i = 0; _i < arguments.length; _i++) {
  3360. params[_i] = arguments[_i];
  3361. }
  3362. // Get caller name if not null
  3363. var callerFunc = this._addConsoleLog.caller;
  3364. var caller = callerFunc == null ? "Window" : "Function " + callerFunc['name'] + ": ";
  3365. for (var i = 0; i < params.length; i++) {
  3366. this._message('log', params[i], caller);
  3367. // Write again in console does not work on edge, as the console object
  3368. // is not instantiate if debugger tools is not open
  3369. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3370. this._oldConsoleLog(params[i]);
  3371. }
  3372. }
  3373. };
  3374. ConsoleTab.prototype._addConsoleWarn = function () {
  3375. var params = [];
  3376. for (var _i = 0; _i < arguments.length; _i++) {
  3377. params[_i] = arguments[_i];
  3378. }
  3379. // Get caller name if not null
  3380. var callerFunc = this._addConsoleLog.caller;
  3381. var caller = callerFunc == null ? "Window" : callerFunc['name'];
  3382. for (var i = 0; i < params.length; i++) {
  3383. this._message('warn', params[i], caller);
  3384. // Write again in console does not work on edge, as the console object
  3385. // is not instantiate if debugger tools is not open
  3386. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3387. this._oldConsoleWarn(params[i]);
  3388. }
  3389. }
  3390. };
  3391. ConsoleTab.prototype._addConsoleError = function () {
  3392. var params = [];
  3393. for (var _i = 0; _i < arguments.length; _i++) {
  3394. params[_i] = arguments[_i];
  3395. }
  3396. // Get caller name if not null
  3397. var callerFunc = this._addConsoleLog.caller;
  3398. var caller = callerFunc == null ? "Window" : callerFunc['name'];
  3399. for (var i = 0; i < params.length; i++) {
  3400. this._message('error', params[i], caller);
  3401. // Write again in console does not work on edge, as the console object
  3402. // is not instantiate if debugger tools is not open
  3403. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3404. this._oldConsoleError(params[i]);
  3405. }
  3406. }
  3407. };
  3408. return ConsoleTab;
  3409. }(INSPECTOR.Tab));
  3410. INSPECTOR.ConsoleTab = ConsoleTab;
  3411. })(INSPECTOR || (INSPECTOR = {}));
  3412. var __extends = (this && this.__extends) || (function () {
  3413. var extendStatics = Object.setPrototypeOf ||
  3414. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3415. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3416. return function (d, b) {
  3417. extendStatics(d, b);
  3418. function __() { this.constructor = d; }
  3419. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3420. };
  3421. })();
  3422. var INSPECTOR;
  3423. (function (INSPECTOR) {
  3424. var StatsTab = (function (_super) {
  3425. __extends(StatsTab, _super);
  3426. function StatsTab(tabbar, insp) {
  3427. var _this = _super.call(this, tabbar, 'Stats') || this;
  3428. /**
  3429. * Properties in this array will be updated
  3430. * in a render loop - Mostly stats properties
  3431. */
  3432. _this._updatableProperties = [];
  3433. _this._inspector = insp;
  3434. _this._scene = _this._inspector.scene;
  3435. _this._engine = _this._scene.getEngine();
  3436. _this._glInfo = _this._engine.getGlInfo();
  3437. // Build the stats panel: a div that will contains all stats
  3438. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3439. _this._panel.classList.add("stats-panel");
  3440. var title = INSPECTOR.Helpers.CreateDiv('stat-title1', _this._panel);
  3441. var fpsSpan = INSPECTOR.Helpers.CreateElement('span', 'stats-fps');
  3442. _this._updatableProperties.push({
  3443. elem: fpsSpan,
  3444. updateFct: function () { return BABYLON.Tools.Format(_this._inspector.scene.getEngine().getFps(), 0) + " fps"; }
  3445. });
  3446. var versionSpan = INSPECTOR.Helpers.CreateElement('span');
  3447. versionSpan.textContent = "Babylon.js v" + BABYLON.Engine.Version + " - ";
  3448. title.appendChild(versionSpan);
  3449. title.appendChild(fpsSpan);
  3450. _this._updateLoopHandler = _this._update.bind(_this);
  3451. // Count block
  3452. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3453. title.textContent = "Count";
  3454. {
  3455. var elemLabel = _this._createStatLabel("Total meshes", _this._panel);
  3456. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3457. _this._updatableProperties.push({
  3458. elem: elemValue,
  3459. updateFct: function () { return _this._scene.meshes.length.toString(); }
  3460. });
  3461. elemLabel = _this._createStatLabel("Draw calls", _this._panel);
  3462. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3463. _this._updatableProperties.push({
  3464. elem: elemValue,
  3465. updateFct: function () { return _this._engine.drawCalls.toString(); }
  3466. });
  3467. elemLabel = _this._createStatLabel("Total lights", _this._panel);
  3468. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3469. _this._updatableProperties.push({
  3470. elem: elemValue,
  3471. updateFct: function () { return _this._scene.lights.length.toString(); }
  3472. });
  3473. elemLabel = _this._createStatLabel("Total lights", _this._panel);
  3474. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3475. _this._updatableProperties.push({
  3476. elem: elemValue,
  3477. updateFct: function () { return _this._scene.lights.length.toString(); }
  3478. });
  3479. elemLabel = _this._createStatLabel("Total vertices", _this._panel);
  3480. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3481. _this._updatableProperties.push({
  3482. elem: elemValue,
  3483. updateFct: function () { return _this._scene.getTotalVertices().toString(); }
  3484. });
  3485. elemLabel = _this._createStatLabel("Total materials", _this._panel);
  3486. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3487. _this._updatableProperties.push({
  3488. elem: elemValue,
  3489. updateFct: function () { return _this._scene.materials.length.toString(); }
  3490. });
  3491. elemLabel = _this._createStatLabel("Total textures", _this._panel);
  3492. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3493. _this._updatableProperties.push({
  3494. elem: elemValue,
  3495. updateFct: function () { return _this._scene.textures.length.toString(); }
  3496. });
  3497. elemLabel = _this._createStatLabel("Active meshes", _this._panel);
  3498. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3499. _this._updatableProperties.push({
  3500. elem: elemValue,
  3501. updateFct: function () { return _this._scene.getActiveMeshes().length.toString(); }
  3502. });
  3503. elemLabel = _this._createStatLabel("Active indices", _this._panel);
  3504. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3505. _this._updatableProperties.push({
  3506. elem: elemValue,
  3507. updateFct: function () { return _this._scene.getActiveIndices().toString(); }
  3508. });
  3509. elemLabel = _this._createStatLabel("Active bones", _this._panel);
  3510. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3511. _this._updatableProperties.push({
  3512. elem: elemValue,
  3513. updateFct: function () { return _this._scene.getActiveBones().toString(); }
  3514. });
  3515. elemLabel = _this._createStatLabel("Active particles", _this._panel);
  3516. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3517. _this._updatableProperties.push({
  3518. elem: elemValue,
  3519. updateFct: function () { return _this._scene.getActiveParticles().toString(); }
  3520. });
  3521. }
  3522. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3523. title.textContent = "Duration";
  3524. {
  3525. var elemLabel = _this._createStatLabel("Meshes selection", _this._panel);
  3526. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3527. _this._updatableProperties.push({
  3528. elem: elemValue,
  3529. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getEvaluateActiveMeshesDuration()); }
  3530. });
  3531. elemLabel = _this._createStatLabel("Render targets", _this._panel);
  3532. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3533. _this._updatableProperties.push({
  3534. elem: elemValue,
  3535. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getRenderTargetsDuration()); }
  3536. });
  3537. elemLabel = _this._createStatLabel("Particles", _this._panel);
  3538. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3539. _this._updatableProperties.push({
  3540. elem: elemValue,
  3541. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getParticlesDuration()); }
  3542. });
  3543. elemLabel = _this._createStatLabel("Sprites", _this._panel);
  3544. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3545. _this._updatableProperties.push({
  3546. elem: elemValue,
  3547. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getSpritesDuration()); }
  3548. });
  3549. elemLabel = _this._createStatLabel("Render", _this._panel);
  3550. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3551. _this._updatableProperties.push({
  3552. elem: elemValue,
  3553. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getRenderDuration()); }
  3554. });
  3555. elemLabel = _this._createStatLabel("Frame", _this._panel);
  3556. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3557. _this._updatableProperties.push({
  3558. elem: elemValue,
  3559. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getLastFrameDuration()); }
  3560. });
  3561. elemLabel = _this._createStatLabel("Potential FPS", _this._panel);
  3562. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3563. _this._updatableProperties.push({
  3564. elem: elemValue,
  3565. updateFct: function () { return BABYLON.Tools.Format(1000.0 / _this._scene.getLastFrameDuration(), 0); }
  3566. });
  3567. elemLabel = _this._createStatLabel("Resolution", _this._panel);
  3568. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3569. _this._updatableProperties.push({
  3570. elem: elemValue,
  3571. updateFct: function () { return _this._engine.getRenderWidth() + "x" + _this._engine.getRenderHeight(); }
  3572. });
  3573. }
  3574. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3575. title.textContent = "Extensions";
  3576. {
  3577. var elemLabel = _this._createStatLabel("Std derivatives", _this._panel);
  3578. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3579. _this._updatableProperties.push({
  3580. elem: elemValue,
  3581. updateFct: function () { return (_this._engine.getCaps().standardDerivatives ? "Yes" : "No"); }
  3582. });
  3583. elemLabel = _this._createStatLabel("Compressed textures", _this._panel);
  3584. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3585. _this._updatableProperties.push({
  3586. elem: elemValue,
  3587. updateFct: function () { return (_this._engine.getCaps().s3tc ? "Yes" : "No"); }
  3588. });
  3589. elemLabel = _this._createStatLabel("Hardware instances", _this._panel);
  3590. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3591. _this._updatableProperties.push({
  3592. elem: elemValue,
  3593. updateFct: function () { return (_this._engine.getCaps().instancedArrays ? "Yes" : "No"); }
  3594. });
  3595. elemLabel = _this._createStatLabel("Texture float", _this._panel);
  3596. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3597. _this._updatableProperties.push({
  3598. elem: elemValue,
  3599. updateFct: function () { return (_this._engine.getCaps().textureFloat ? "Yes" : "No"); }
  3600. });
  3601. elemLabel = _this._createStatLabel("32bits indices", _this._panel);
  3602. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3603. _this._updatableProperties.push({
  3604. elem: elemValue,
  3605. updateFct: function () { return (_this._engine.getCaps().uintIndices ? "Yes" : "No"); }
  3606. });
  3607. elemLabel = _this._createStatLabel("Fragment depth", _this._panel);
  3608. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3609. _this._updatableProperties.push({
  3610. elem: elemValue,
  3611. updateFct: function () { return (_this._engine.getCaps().fragmentDepthSupported ? "Yes" : "No"); }
  3612. });
  3613. elemLabel = _this._createStatLabel("High precision shaders", _this._panel);
  3614. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3615. _this._updatableProperties.push({
  3616. elem: elemValue,
  3617. updateFct: function () { return (_this._engine.getCaps().highPrecisionShaderSupported ? "Yes" : "No"); }
  3618. });
  3619. elemLabel = _this._createStatLabel("Draw buffers", _this._panel);
  3620. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3621. _this._updatableProperties.push({
  3622. elem: elemValue,
  3623. updateFct: function () { return (_this._engine.getCaps().drawBuffersExtension ? "Yes" : "No"); }
  3624. });
  3625. elemLabel = _this._createStatLabel("Vertex array object", _this._panel);
  3626. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3627. _this._updatableProperties.push({
  3628. elem: elemValue,
  3629. updateFct: function () { return (_this._engine.getCaps().vertexArrayObject ? "Yes" : "No"); }
  3630. });
  3631. }
  3632. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3633. title.textContent = "Caps.";
  3634. {
  3635. var elemLabel = _this._createStatLabel("Stencil", _this._panel);
  3636. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3637. _this._updatableProperties.push({
  3638. elem: elemValue,
  3639. updateFct: function () { return (_this._engine.isStencilEnable ? "Enabled" : "Disabled"); }
  3640. });
  3641. elemLabel = _this._createStatLabel("Max textures units", _this._panel);
  3642. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3643. _this._updatableProperties.push({
  3644. elem: elemValue,
  3645. updateFct: function () { return _this._engine.getCaps().maxTexturesImageUnits.toString(); }
  3646. });
  3647. elemLabel = _this._createStatLabel("Max textures size", _this._panel);
  3648. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3649. _this._updatableProperties.push({
  3650. elem: elemValue,
  3651. updateFct: function () { return _this._engine.getCaps().maxTextureSize.toString(); }
  3652. });
  3653. elemLabel = _this._createStatLabel("Max anisotropy", _this._panel);
  3654. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3655. _this._updatableProperties.push({
  3656. elem: elemValue,
  3657. updateFct: function () { return _this._engine.getCaps().maxAnisotropy.toString(); }
  3658. });
  3659. }
  3660. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3661. title.textContent = "Info";
  3662. {
  3663. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-infos', _this._panel);
  3664. _this._updatableProperties.push({
  3665. elem: elemValue,
  3666. updateFct: function () { return "WebGL v" + _this._engine.webGLVersion + " - " + _this._glInfo.version + " - " + _this._glInfo.renderer; }
  3667. });
  3668. }
  3669. // Register the update loop
  3670. _this._scene.registerAfterRender(_this._updateLoopHandler);
  3671. return _this;
  3672. }
  3673. StatsTab.prototype._createStatLabel = function (content, parent) {
  3674. var elem = INSPECTOR.Helpers.CreateDiv('stat-label', parent);
  3675. elem.textContent = content;
  3676. return elem;
  3677. };
  3678. /** Update each properties of the stats panel */
  3679. StatsTab.prototype._update = function () {
  3680. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  3681. var prop = _a[_i];
  3682. prop.elem.textContent = prop.updateFct();
  3683. }
  3684. };
  3685. StatsTab.prototype.dispose = function () {
  3686. this._scene.unregisterAfterRender(this._updateLoopHandler);
  3687. };
  3688. return StatsTab;
  3689. }(INSPECTOR.Tab));
  3690. INSPECTOR.StatsTab = StatsTab;
  3691. })(INSPECTOR || (INSPECTOR = {}));
  3692. var __extends = (this && this.__extends) || (function () {
  3693. var extendStatics = Object.setPrototypeOf ||
  3694. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3695. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3696. return function (d, b) {
  3697. extendStatics(d, b);
  3698. function __() { this.constructor = d; }
  3699. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3700. };
  3701. })();
  3702. var INSPECTOR;
  3703. (function (INSPECTOR) {
  3704. /**
  3705. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  3706. * The default active tab is the first one of the list.
  3707. */
  3708. var TabBar = (function (_super) {
  3709. __extends(TabBar, _super);
  3710. function TabBar(inspector, initialTab) {
  3711. var _this = _super.call(this) || this;
  3712. // The list of available tabs
  3713. _this._tabs = [];
  3714. /** The list of tab displayed by clicking on the remainingIcon */
  3715. _this._invisibleTabs = [];
  3716. /** The list of tabs visible, displayed in the tab bar */
  3717. _this._visibleTabs = [];
  3718. _this._inspector = inspector;
  3719. _this._tabs.push(new INSPECTOR.SceneTab(_this, _this._inspector));
  3720. _this._tabs.push(new INSPECTOR.ConsoleTab(_this, _this._inspector));
  3721. _this._tabs.push(new INSPECTOR.StatsTab(_this, _this._inspector));
  3722. _this._meshTab = new INSPECTOR.MeshTab(_this, _this._inspector);
  3723. _this._tabs.push(new INSPECTOR.TextureTab(_this, _this._inspector));
  3724. _this._tabs.push(_this._meshTab);
  3725. _this._tabs.push(new INSPECTOR.ShaderTab(_this, _this._inspector));
  3726. _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
  3727. // Add only the tab canvas2D if Canvas2D is defined
  3728. if (BABYLON.Canvas2D) {
  3729. _this._tabs.push(new INSPECTOR.Canvas2DTab(_this, _this._inspector));
  3730. }
  3731. _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
  3732. _this._tabs.push(new INSPECTOR.CameraTab(_this, _this._inspector));
  3733. _this._tabs.push(new INSPECTOR.SoundTab(_this, _this._inspector));
  3734. _this._toolBar = new INSPECTOR.Toolbar(_this._inspector);
  3735. _this._build();
  3736. //Check initialTab is defined and between tabs bounds
  3737. if (!initialTab || initialTab < 0 || initialTab >= _this._tabs.length) {
  3738. initialTab = 0;
  3739. console.warn('');
  3740. }
  3741. _this._tabs[initialTab].active(true);
  3742. // set all tab as visible
  3743. for (var _i = 0, _a = _this._tabs; _i < _a.length; _i++) {
  3744. var tab = _a[_i];
  3745. _this._visibleTabs.push(tab);
  3746. }
  3747. return _this;
  3748. }
  3749. // No update
  3750. TabBar.prototype.update = function () { };
  3751. TabBar.prototype._build = function () {
  3752. var _this = this;
  3753. this._div.className = 'tabbar';
  3754. this._div.appendChild(this._toolBar.toHtml());
  3755. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  3756. var tab = _a[_i];
  3757. this._div.appendChild(tab.toHtml());
  3758. }
  3759. this._moreTabsIcon = INSPECTOR.Helpers.CreateElement('i', 'fa fa-angle-double-right more-tabs');
  3760. this._moreTabsPanel = INSPECTOR.Helpers.CreateDiv('more-tabs-panel');
  3761. this._moreTabsIcon.addEventListener('click', function () {
  3762. // Hide the 'more-tabs-panel' if already displayed
  3763. if (_this._moreTabsPanel.style.display == 'flex') {
  3764. _this._moreTabsPanel.style.display = 'none';
  3765. }
  3766. else {
  3767. // Attach more-tabs-panel if not attached yet
  3768. var topPanel = _this._div.parentNode;
  3769. if (!topPanel.contains(_this._moreTabsPanel)) {
  3770. topPanel.appendChild(_this._moreTabsPanel);
  3771. }
  3772. // Clean the 'more-tabs-panel'
  3773. INSPECTOR.Helpers.CleanDiv(_this._moreTabsPanel);
  3774. // Add each invisible tabs to this panel
  3775. for (var _i = 0, _a = _this._invisibleTabs; _i < _a.length; _i++) {
  3776. var tab = _a[_i];
  3777. _this._addInvisibleTabToPanel(tab);
  3778. }
  3779. // And display it
  3780. _this._moreTabsPanel.style.display = 'flex';
  3781. }
  3782. });
  3783. };
  3784. /**
  3785. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  3786. * 'more-tabs' icon
  3787. */
  3788. TabBar.prototype._addInvisibleTabToPanel = function (tab) {
  3789. var _this = this;
  3790. var div = INSPECTOR.Helpers.CreateDiv('invisible-tab', this._moreTabsPanel);
  3791. div.textContent = tab.name;
  3792. div.addEventListener('click', function () {
  3793. _this._moreTabsPanel.style.display = 'none';
  3794. _this.switchTab(tab);
  3795. });
  3796. };
  3797. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  3798. TabBar.prototype.switchTab = function (tab) {
  3799. // Dispose the active tab
  3800. this.getActiveTab().dispose();
  3801. // Deactivate all tabs
  3802. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  3803. var t = _a[_i];
  3804. t.active(false);
  3805. }
  3806. // activate the given tab
  3807. tab.active(true);
  3808. // Refresh the inspector
  3809. this._inspector.refresh();
  3810. };
  3811. /** Display the mesh tab.
  3812. * If a parameter is given, the given mesh details are displayed
  3813. */
  3814. TabBar.prototype.switchMeshTab = function (mesh) {
  3815. this.switchTab(this._meshTab);
  3816. if (mesh) {
  3817. var item = this._meshTab.getItemFor(mesh);
  3818. this._meshTab.select(item);
  3819. }
  3820. };
  3821. /** Returns the active tab */
  3822. TabBar.prototype.getActiveTab = function () {
  3823. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  3824. var tab = _a[_i];
  3825. if (tab.isActive()) {
  3826. return tab;
  3827. }
  3828. }
  3829. };
  3830. Object.defineProperty(TabBar.prototype, "inspector", {
  3831. get: function () {
  3832. return this._inspector;
  3833. },
  3834. enumerable: true,
  3835. configurable: true
  3836. });
  3837. /**
  3838. * Returns the total width in pixel of the tabbar,
  3839. * that corresponds to the sum of the width of each visible tab + toolbar width
  3840. */
  3841. TabBar.prototype.getPixelWidth = function () {
  3842. var sum = 0;
  3843. for (var _i = 0, _a = this._visibleTabs; _i < _a.length; _i++) {
  3844. var tab = _a[_i];
  3845. sum += tab.getPixelWidth();
  3846. }
  3847. sum += this._toolBar.getPixelWidth();
  3848. if (this._div.contains(this._moreTabsIcon)) {
  3849. sum += 30; // $tabbarheight
  3850. }
  3851. return sum;
  3852. };
  3853. /** Display the remaining icon or not depending on the tabbar width.
  3854. * This function should be called each time the inspector width is updated
  3855. */
  3856. TabBar.prototype.updateWidth = function () {
  3857. var parentSize = this._div.parentElement.clientWidth;
  3858. var lastTabWidth = 75;
  3859. var currentSize = this.getPixelWidth();
  3860. // Check if a tab should be removed : if the tab bar width is greater than
  3861. // its parent width
  3862. while (this._visibleTabs.length > 0 && currentSize > parentSize) {
  3863. // Start by the last element
  3864. var tab = this._visibleTabs.pop();
  3865. // set it invisible
  3866. this._invisibleTabs.push(tab);
  3867. // and removes it from the DOM
  3868. this._div.removeChild(tab.toHtml());
  3869. currentSize = this.getPixelWidth() + lastTabWidth;
  3870. }
  3871. // Check if a tab can be added to the tab bar : if the tab bar width
  3872. // + 100 (at least 100px is needed to add a tab) is less than its parent width
  3873. if (this._invisibleTabs.length > 0) {
  3874. if (currentSize + lastTabWidth < parentSize) {
  3875. var lastTab = this._invisibleTabs.pop();
  3876. this._div.appendChild(lastTab.toHtml());
  3877. this._visibleTabs.push(lastTab);
  3878. // Update more-tab icon in last position if needed
  3879. if (this._div.contains(this._moreTabsIcon)) {
  3880. this._div.removeChild(this._moreTabsIcon);
  3881. }
  3882. }
  3883. }
  3884. if (this._invisibleTabs.length > 0 && !this._div.contains(this._moreTabsIcon)) {
  3885. this._div.appendChild(this._moreTabsIcon);
  3886. }
  3887. };
  3888. return TabBar;
  3889. }(INSPECTOR.BasicElement));
  3890. INSPECTOR.TabBar = TabBar;
  3891. })(INSPECTOR || (INSPECTOR = {}));
  3892. var INSPECTOR;
  3893. (function (INSPECTOR) {
  3894. var AbstractTool = (function () {
  3895. function AbstractTool(icon, parent, inspector, tooltip) {
  3896. var _this = this;
  3897. this._inspector = inspector;
  3898. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  3899. this._elem.className = "tool fa " + icon;
  3900. parent.appendChild(this._elem);
  3901. this._elem.addEventListener('click', function (e) {
  3902. _this.action();
  3903. });
  3904. new INSPECTOR.Tooltip(this._elem, tooltip);
  3905. }
  3906. AbstractTool.prototype.toHtml = function () {
  3907. return this._elem;
  3908. };
  3909. /**
  3910. * Returns the total width in pixel of this tool, 0 by default
  3911. */
  3912. AbstractTool.prototype.getPixelWidth = function () {
  3913. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._elem);
  3914. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  3915. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  3916. return (this._elem.clientWidth || 0) + left + right;
  3917. };
  3918. /**
  3919. * Updates the icon of this tool with the given string
  3920. */
  3921. AbstractTool.prototype._updateIcon = function (icon) {
  3922. this._elem.className = "tool fa " + icon;
  3923. };
  3924. return AbstractTool;
  3925. }());
  3926. INSPECTOR.AbstractTool = AbstractTool;
  3927. })(INSPECTOR || (INSPECTOR = {}));
  3928. var __extends = (this && this.__extends) || (function () {
  3929. var extendStatics = Object.setPrototypeOf ||
  3930. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3931. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3932. return function (d, b) {
  3933. extendStatics(d, b);
  3934. function __() { this.constructor = d; }
  3935. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3936. };
  3937. })();
  3938. var INSPECTOR;
  3939. (function (INSPECTOR) {
  3940. var PauseScheduleTool = (function (_super) {
  3941. __extends(PauseScheduleTool, _super);
  3942. function PauseScheduleTool(parent, inspector) {
  3943. var _this = _super.call(this, 'fa-pause', parent, inspector, 'Pause the automatic update of properties') || this;
  3944. _this._isPause = false;
  3945. return _this;
  3946. }
  3947. // Action : refresh the whole panel
  3948. PauseScheduleTool.prototype.action = function () {
  3949. if (this._isPause) {
  3950. INSPECTOR.Scheduler.getInstance().pause = false;
  3951. this._updateIcon('fa-pause');
  3952. }
  3953. else {
  3954. INSPECTOR.Scheduler.getInstance().pause = true;
  3955. this._updateIcon('fa-play');
  3956. }
  3957. this._isPause = !this._isPause;
  3958. };
  3959. return PauseScheduleTool;
  3960. }(INSPECTOR.AbstractTool));
  3961. INSPECTOR.PauseScheduleTool = PauseScheduleTool;
  3962. })(INSPECTOR || (INSPECTOR = {}));
  3963. var __extends = (this && this.__extends) || (function () {
  3964. var extendStatics = Object.setPrototypeOf ||
  3965. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3966. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3967. return function (d, b) {
  3968. extendStatics(d, b);
  3969. function __() { this.constructor = d; }
  3970. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3971. };
  3972. })();
  3973. var INSPECTOR;
  3974. (function (INSPECTOR) {
  3975. var PickTool = (function (_super) {
  3976. __extends(PickTool, _super);
  3977. function PickTool(parent, inspector) {
  3978. var _this = _super.call(this, 'fa-mouse-pointer', parent, inspector, 'Select a mesh in the scene') || this;
  3979. _this._isActive = false;
  3980. // Create handler
  3981. _this._pickHandler = _this._pickMesh.bind(_this);
  3982. return _this;
  3983. }
  3984. // Action : find the corresponding tree item in the correct tab and display it
  3985. PickTool.prototype.action = function () {
  3986. if (this._isActive) {
  3987. this._deactivate();
  3988. }
  3989. else {
  3990. this.toHtml().classList.add('active');
  3991. // Add event handler : pick on a mesh in the scene
  3992. this._inspector.scene.getEngine().getRenderingCanvas().addEventListener('click', this._pickHandler);
  3993. this._isActive = true;
  3994. }
  3995. };
  3996. /** Deactivate this tool */
  3997. PickTool.prototype._deactivate = function () {
  3998. this.toHtml().classList.remove('active');
  3999. // Remove event handler
  4000. this._inspector.scene.getEngine().getRenderingCanvas().removeEventListener('click', this._pickHandler);
  4001. this._isActive = false;
  4002. };
  4003. /** Pick a mesh in the scene */
  4004. PickTool.prototype._pickMesh = function (evt) {
  4005. var pos = this._updatePointerPosition(evt);
  4006. var pi = this._inspector.scene.pick(pos.x, pos.y, function (mesh) { return true; });
  4007. if (pi.pickedMesh) {
  4008. console.log(pi.pickedMesh.name);
  4009. this._inspector.displayObjectDetails(pi.pickedMesh);
  4010. }
  4011. this._deactivate();
  4012. };
  4013. PickTool.prototype._updatePointerPosition = function (evt) {
  4014. var canvasRect = this._inspector.scene.getEngine().getRenderingCanvasClientRect();
  4015. var pointerX = evt.clientX - canvasRect.left;
  4016. var pointerY = evt.clientY - canvasRect.top;
  4017. return { x: pointerX, y: pointerY };
  4018. };
  4019. ;
  4020. return PickTool;
  4021. }(INSPECTOR.AbstractTool));
  4022. INSPECTOR.PickTool = PickTool;
  4023. })(INSPECTOR || (INSPECTOR = {}));
  4024. var __extends = (this && this.__extends) || (function () {
  4025. var extendStatics = Object.setPrototypeOf ||
  4026. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4027. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4028. return function (d, b) {
  4029. extendStatics(d, b);
  4030. function __() { this.constructor = d; }
  4031. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4032. };
  4033. })();
  4034. var INSPECTOR;
  4035. (function (INSPECTOR) {
  4036. var PopupTool = (function (_super) {
  4037. __extends(PopupTool, _super);
  4038. function PopupTool(parent, inspector) {
  4039. return _super.call(this, 'fa-external-link', parent, inspector, 'Open the inspector in a popup') || this;
  4040. }
  4041. // Action : refresh the whole panel
  4042. PopupTool.prototype.action = function () {
  4043. this._inspector.openPopup();
  4044. };
  4045. return PopupTool;
  4046. }(INSPECTOR.AbstractTool));
  4047. INSPECTOR.PopupTool = PopupTool;
  4048. })(INSPECTOR || (INSPECTOR = {}));
  4049. var __extends = (this && this.__extends) || (function () {
  4050. var extendStatics = Object.setPrototypeOf ||
  4051. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4052. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4053. return function (d, b) {
  4054. extendStatics(d, b);
  4055. function __() { this.constructor = d; }
  4056. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4057. };
  4058. })();
  4059. var INSPECTOR;
  4060. (function (INSPECTOR) {
  4061. var RefreshTool = (function (_super) {
  4062. __extends(RefreshTool, _super);
  4063. function RefreshTool(parent, inspector) {
  4064. return _super.call(this, 'fa-refresh', parent, inspector, 'Refresh the current tab') || this;
  4065. }
  4066. // Action : refresh the whole panel
  4067. RefreshTool.prototype.action = function () {
  4068. this._inspector.refresh();
  4069. };
  4070. return RefreshTool;
  4071. }(INSPECTOR.AbstractTool));
  4072. INSPECTOR.RefreshTool = RefreshTool;
  4073. })(INSPECTOR || (INSPECTOR = {}));
  4074. var __extends = (this && this.__extends) || (function () {
  4075. var extendStatics = Object.setPrototypeOf ||
  4076. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4077. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4078. return function (d, b) {
  4079. extendStatics(d, b);
  4080. function __() { this.constructor = d; }
  4081. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4082. };
  4083. })();
  4084. var INSPECTOR;
  4085. (function (INSPECTOR) {
  4086. var LabelTool = (function (_super) {
  4087. __extends(LabelTool, _super);
  4088. function LabelTool(parent, inspector) {
  4089. var _this = _super.call(this, 'fa-tags', parent, inspector, 'Display mesh names on the canvas') || this;
  4090. /** True if label are displayed, false otherwise */
  4091. _this._isDisplayed = false;
  4092. _this._canvas = null;
  4093. _this._labelInitialized = false;
  4094. _this._scene = null;
  4095. _this._canvas2DLoaded = false;
  4096. _this._newMeshObserver = null;
  4097. _this._removedMeshObserver = null;
  4098. _this._newLightObserver = null;
  4099. _this._removedLightObserver = null;
  4100. _this._newCameraObserver = null;
  4101. _this._removedCameraObserver = null;
  4102. _this._scene = inspector.scene;
  4103. return _this;
  4104. }
  4105. LabelTool.prototype.dispose = function () {
  4106. if (this._newMeshObserver) {
  4107. this._scene.onNewMeshAddedObservable.remove(this._newMeshObserver);
  4108. this._scene.onMeshRemovedObservable.remove(this._removedMeshObserver);
  4109. this._scene.onNewLightAddedObservable.remove(this._newLightObserver);
  4110. this._scene.onLightRemovedObservable.remove(this._removedLightObserver);
  4111. this._scene.onNewCameraAddedObservable.remove(this._newCameraObserver);
  4112. this._scene.onCameraRemovedObservable.remove(this._removedCameraObserver);
  4113. this._newMeshObserver = this._newLightObserver = this._newCameraObserver = this._removedMeshObserver = this._removedLightObserver = this._removedCameraObserver = null;
  4114. }
  4115. this._canvas.dispose();
  4116. this._canvas = null;
  4117. };
  4118. LabelTool.prototype._checkC2DLoaded = function () {
  4119. if (this._canvas2DLoaded === true) {
  4120. return true;
  4121. }
  4122. if (BABYLON.Canvas2D) {
  4123. this._canvas2DLoaded = true;
  4124. }
  4125. return this._canvas2DLoaded;
  4126. };
  4127. LabelTool.prototype._initializeLabels = function () {
  4128. var _this = this;
  4129. // Check if the label are already initialized and quit if it's the case
  4130. if (this._labelInitialized) {
  4131. return;
  4132. }
  4133. // Can't initialize them if the Canvas2D lib is not loaded yet
  4134. if (!this._checkC2DLoaded()) {
  4135. return;
  4136. }
  4137. // Create the canvas that will be used to display the labels
  4138. this._canvas = new BABYLON.ScreenSpaceCanvas2D(this._scene, { id: "###Label Canvas###" /*, cachingStrategy: BABYLON.Canvas2D.CACHESTRATEGY_TOPLEVELGROUPS*/ });
  4139. // Create label for all the Meshes, Lights and Cameras
  4140. // Those that will be created/removed after this method is called will be taken care by the event handlers added below
  4141. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  4142. var m = _a[_i];
  4143. this._createLabel(m);
  4144. }
  4145. for (var _b = 0, _c = this._scene.lights; _b < _c.length; _b++) {
  4146. var l = _c[_b];
  4147. this._createLabel(l);
  4148. }
  4149. for (var _d = 0, _e = this._scene.cameras; _d < _e.length; _d++) {
  4150. var c = _e[_d];
  4151. this._createLabel(c);
  4152. }
  4153. // Add handlers for new/removed meshes, camera and lights
  4154. this._newMeshObserver = this._scene.onNewMeshAddedObservable.add(function (e, s) {
  4155. _this._createLabel(e);
  4156. });
  4157. this._removedMeshObserver = this._scene.onMeshRemovedObservable.add(function (e, s) {
  4158. _this._removeLabel(e);
  4159. });
  4160. this._newLightObserver = this._scene.onNewLightAddedObservable.add(function (e, s) {
  4161. _this._createLabel(e);
  4162. });
  4163. this._removedLightObserver = this._scene.onLightRemovedObservable.add(function (e, s) {
  4164. _this._removeLabel(e);
  4165. });
  4166. this._newCameraObserver = this._scene.onNewCameraAddedObservable.add(function (e, s) {
  4167. _this._createLabel(e);
  4168. });
  4169. this._removedCameraObserver = this._scene.onCameraRemovedObservable.add(function (e, s) {
  4170. _this._removeLabel(e);
  4171. });
  4172. this._labelInitialized = true;
  4173. };
  4174. LabelTool.prototype._createLabel = function (node) {
  4175. // Don't create label for "system nodes" (starting and ending with ###)
  4176. var name = node.name;
  4177. if (INSPECTOR.Helpers.IsSystemName(name)) {
  4178. return;
  4179. }
  4180. var labelGroup = new BABYLON.Group2D({ parent: this._canvas, id: "Label of " + node.name, trackNode: node, origin: BABYLON.Vector2.Zero(),
  4181. children: [
  4182. new BABYLON.Rectangle2D({ id: "LabelRect", x: 0, y: 0, width: 100, height: 30, origin: BABYLON.Vector2.Zero(), border: "#FFFFFFFF", fill: "#808080B0", children: [
  4183. new BABYLON.Text2D(node.name, { x: 10, y: 4, fontName: "bold 16px Arial", fontSignedDistanceField: true })
  4184. ]
  4185. })
  4186. ] });
  4187. var r = labelGroup.children[0];
  4188. var t = r.children[0];
  4189. var ts = t.textSize.width;
  4190. r.width = ts + 20;
  4191. r.height = t.textSize.height + 12;
  4192. labelGroup.addExternalData("owner", node);
  4193. return labelGroup;
  4194. };
  4195. LabelTool.prototype._removeLabel = function (node) {
  4196. for (var _i = 0, _a = this._canvas.children; _i < _a.length; _i++) {
  4197. var g = _a[_i];
  4198. var ed = g.getExternalData("owner");
  4199. if (ed === node) {
  4200. g.dispose();
  4201. break;
  4202. }
  4203. }
  4204. };
  4205. // Action : Display/hide mesh names on the canvas
  4206. LabelTool.prototype.action = function () {
  4207. // Don't toggle if the script is not loaded
  4208. if (!this._checkC2DLoaded()) {
  4209. return;
  4210. }
  4211. // Toggle the label display state
  4212. this._isDisplayed = !this._isDisplayed;
  4213. // Check if we have to display the labels
  4214. if (this._isDisplayed) {
  4215. this._initializeLabels();
  4216. this._canvas.levelVisible = true;
  4217. }
  4218. else {
  4219. this._canvas.levelVisible = false;
  4220. }
  4221. };
  4222. return LabelTool;
  4223. }(INSPECTOR.AbstractTool));
  4224. INSPECTOR.LabelTool = LabelTool;
  4225. })(INSPECTOR || (INSPECTOR = {}));
  4226. var __extends = (this && this.__extends) || (function () {
  4227. var extendStatics = Object.setPrototypeOf ||
  4228. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4229. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4230. return function (d, b) {
  4231. extendStatics(d, b);
  4232. function __() { this.constructor = d; }
  4233. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4234. };
  4235. })();
  4236. var INSPECTOR;
  4237. (function (INSPECTOR) {
  4238. var Toolbar = (function (_super) {
  4239. __extends(Toolbar, _super);
  4240. function Toolbar(inspector) {
  4241. var _this = _super.call(this) || this;
  4242. _this._tools = [];
  4243. _this._inspector = inspector;
  4244. _this._build();
  4245. _this._addTools();
  4246. return _this;
  4247. }
  4248. // A toolbar cannot be updated
  4249. Toolbar.prototype.update = function () { };
  4250. ;
  4251. Toolbar.prototype._build = function () {
  4252. this._div.className = 'toolbar';
  4253. };
  4254. ;
  4255. Toolbar.prototype._addTools = function () {
  4256. // Refresh
  4257. this._tools.push(new INSPECTOR.RefreshTool(this._div, this._inspector));
  4258. // Display labels
  4259. this._tools.push(new INSPECTOR.LabelTool(this._div, this._inspector));
  4260. // Pick object
  4261. this._tools.push(new INSPECTOR.PickTool(this._div, this._inspector));
  4262. // Add the popup mode only if the inspector is not in popup mode and if the brower is not edge
  4263. // Edge is
  4264. if (!this._inspector.popupMode && !INSPECTOR.Helpers.IsBrowserEdge()) {
  4265. this._tools.push(new INSPECTOR.PopupTool(this._div, this._inspector));
  4266. }
  4267. // Pause schedule
  4268. this._tools.push(new INSPECTOR.PauseScheduleTool(this._div, this._inspector));
  4269. // Pause schedule
  4270. this._tools.push(new INSPECTOR.DisposeTool(this._div, this._inspector));
  4271. };
  4272. /**
  4273. * Returns the total width in pixel of the tabbar,
  4274. * that corresponds to the sum of the width of each tab + toolbar width
  4275. */
  4276. Toolbar.prototype.getPixelWidth = function () {
  4277. var sum = 0;
  4278. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4279. var tool = _a[_i];
  4280. sum += tool.getPixelWidth();
  4281. }
  4282. return sum;
  4283. };
  4284. return Toolbar;
  4285. }(INSPECTOR.BasicElement));
  4286. INSPECTOR.Toolbar = Toolbar;
  4287. })(INSPECTOR || (INSPECTOR = {}));
  4288. var __extends = (this && this.__extends) || (function () {
  4289. var extendStatics = Object.setPrototypeOf ||
  4290. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4291. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4292. return function (d, b) {
  4293. extendStatics(d, b);
  4294. function __() { this.constructor = d; }
  4295. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4296. };
  4297. })();
  4298. var INSPECTOR;
  4299. (function (INSPECTOR) {
  4300. /**
  4301. * Removes the inspector panel
  4302. */
  4303. var DisposeTool = (function (_super) {
  4304. __extends(DisposeTool, _super);
  4305. function DisposeTool(parent, inspector) {
  4306. return _super.call(this, 'fa-times', parent, inspector, 'Close the inspector panel') || this;
  4307. }
  4308. // Action : refresh the whole panel
  4309. DisposeTool.prototype.action = function () {
  4310. this._inspector.dispose();
  4311. };
  4312. return DisposeTool;
  4313. }(INSPECTOR.AbstractTool));
  4314. INSPECTOR.DisposeTool = DisposeTool;
  4315. })(INSPECTOR || (INSPECTOR = {}));
  4316. var __extends = (this && this.__extends) || (function () {
  4317. var extendStatics = Object.setPrototypeOf ||
  4318. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4319. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4320. return function (d, b) {
  4321. extendStatics(d, b);
  4322. function __() { this.constructor = d; }
  4323. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4324. };
  4325. })();
  4326. var INSPECTOR;
  4327. (function (INSPECTOR) {
  4328. var TreeItem = (function (_super) {
  4329. __extends(TreeItem, _super);
  4330. function TreeItem(tab, obj) {
  4331. var _this = _super.call(this) || this;
  4332. _this.children = [];
  4333. _this._tab = tab;
  4334. _this._adapter = obj;
  4335. _this._tools = _this._adapter.getTools();
  4336. _this._build();
  4337. return _this;
  4338. }
  4339. Object.defineProperty(TreeItem.prototype, "id", {
  4340. /** Returns the item ID == its adapter ID */
  4341. get: function () {
  4342. return this._adapter.id();
  4343. },
  4344. enumerable: true,
  4345. configurable: true
  4346. });
  4347. /** Add the given item as a child of this one */
  4348. TreeItem.prototype.add = function (child) {
  4349. this.children.push(child);
  4350. this.update();
  4351. };
  4352. Object.defineProperty(TreeItem.prototype, "adapter", {
  4353. /**
  4354. * Returns the original adapter
  4355. */
  4356. get: function () {
  4357. return this._adapter;
  4358. },
  4359. enumerable: true,
  4360. configurable: true
  4361. });
  4362. /**
  4363. * Function used to compare this item to another tree item.
  4364. * Returns the alphabetical sort of the adapter ID
  4365. */
  4366. TreeItem.prototype.compareTo = function (item) {
  4367. var str1 = this.id;
  4368. var str2 = item.id;
  4369. return str1.localeCompare(str2, [], { numeric: true });
  4370. };
  4371. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  4372. TreeItem.prototype.correspondsTo = function (obj) {
  4373. return this._adapter.correspondsTo(obj);
  4374. };
  4375. /** hide all children of this item */
  4376. TreeItem.prototype.fold = function () {
  4377. // Do nothing id no children
  4378. if (this.children.length > 0) {
  4379. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4380. var elem = _a[_i];
  4381. elem.toHtml().style.display = 'none';
  4382. }
  4383. this._div.classList.add('folded');
  4384. this._div.classList.remove('unfolded');
  4385. }
  4386. };
  4387. /** Show all children of this item */
  4388. TreeItem.prototype.unfold = function () {
  4389. // Do nothing id no children
  4390. if (this.children.length > 0) {
  4391. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4392. var elem = _a[_i];
  4393. elem.toHtml().style.display = 'block';
  4394. }
  4395. this._div.classList.add('unfolded');
  4396. this._div.classList.remove('folded');
  4397. }
  4398. };
  4399. /** Build the HTML of this item */
  4400. TreeItem.prototype._build = function () {
  4401. this._div.className = 'line';
  4402. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4403. var tool = _a[_i];
  4404. this._div.appendChild(tool.toHtml());
  4405. }
  4406. // Id
  4407. var text = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  4408. text.textContent = this._adapter.id();
  4409. this._div.appendChild(text);
  4410. // Type
  4411. var type = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  4412. type.className = 'property-type';
  4413. if (this._adapter.type() !== 'type_not_defined') {
  4414. type.textContent = ' - ' + this._adapter.type();
  4415. }
  4416. this._div.appendChild(type);
  4417. this._lineContent = INSPECTOR.Helpers.CreateDiv('line-content', this._div);
  4418. this._addEvent();
  4419. };
  4420. /**
  4421. * Returns one HTML element (.details) containing all details of this primitive
  4422. */
  4423. TreeItem.prototype.getDetails = function () {
  4424. return this._adapter.getProperties();
  4425. };
  4426. TreeItem.prototype.update = function () {
  4427. // Clean division holding all children
  4428. INSPECTOR.Helpers.CleanDiv(this._lineContent);
  4429. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4430. var child = _a[_i];
  4431. var elem = child.toHtml();
  4432. this._lineContent.appendChild(elem);
  4433. }
  4434. if (this.children.length > 0) {
  4435. // Check if folded or not
  4436. if (!this._div.classList.contains('folded') && !this._div.classList.contains('unfolded')) {
  4437. this._div.classList.add('folded');
  4438. }
  4439. }
  4440. this.fold();
  4441. };
  4442. /**
  4443. * Add an event listener on the item :
  4444. * - one click display details
  4445. * - on mouse hover the item is highlighted
  4446. */
  4447. TreeItem.prototype._addEvent = function () {
  4448. var _this = this;
  4449. this._div.addEventListener('click', function (e) {
  4450. _this._tab.select(_this);
  4451. // Fold/unfold the tree
  4452. if (_this._isFolded()) {
  4453. _this.unfold();
  4454. }
  4455. else {
  4456. _this.fold();
  4457. }
  4458. e.stopPropagation();
  4459. });
  4460. // Highlight on mouse over
  4461. this._div.addEventListener('mouseover', function (e) {
  4462. _this._tab.highlightNode(_this);
  4463. e.stopPropagation();
  4464. });
  4465. // Remove highlight on mouse out
  4466. this._div.addEventListener('mouseout', function (e) {
  4467. _this._tab.highlightNode();
  4468. });
  4469. };
  4470. /** Highlight or downplay this node */
  4471. TreeItem.prototype.highlight = function (b) {
  4472. // Remove highlight for all children
  4473. if (!b) {
  4474. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4475. var child = _a[_i];
  4476. child._adapter.highlight(b);
  4477. }
  4478. }
  4479. // Highlight this node
  4480. this._adapter.highlight(b);
  4481. };
  4482. /** Returns true if the node is folded, false otherwise */
  4483. TreeItem.prototype._isFolded = function () {
  4484. return !this._div.classList.contains('unfolded');
  4485. };
  4486. /** Set this item as active (background lighter) in the tree panel */
  4487. TreeItem.prototype.active = function (b) {
  4488. this._div.classList.remove('active');
  4489. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4490. var child = _a[_i];
  4491. child.active(false);
  4492. }
  4493. if (b) {
  4494. this._div.classList.add('active');
  4495. }
  4496. };
  4497. return TreeItem;
  4498. }(INSPECTOR.BasicElement));
  4499. INSPECTOR.TreeItem = TreeItem;
  4500. })(INSPECTOR || (INSPECTOR = {}));
  4501. var INSPECTOR;
  4502. (function (INSPECTOR) {
  4503. var AbstractTreeTool = (function () {
  4504. function AbstractTreeTool() {
  4505. /** Is the tool enabled ? */
  4506. this._on = false;
  4507. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  4508. this._elem.className = 'treeTool fa';
  4509. this._addEvents();
  4510. }
  4511. AbstractTreeTool.prototype.toHtml = function () {
  4512. return this._elem;
  4513. };
  4514. AbstractTreeTool.prototype._addEvents = function () {
  4515. var _this = this;
  4516. this._elem.addEventListener('click', function (e) {
  4517. _this.action();
  4518. e.stopPropagation();
  4519. });
  4520. };
  4521. /**
  4522. * Action launched when clicked on this element
  4523. * Should be overrided
  4524. */
  4525. AbstractTreeTool.prototype.action = function () {
  4526. this._on = !this._on;
  4527. };
  4528. return AbstractTreeTool;
  4529. }());
  4530. INSPECTOR.AbstractTreeTool = AbstractTreeTool;
  4531. })(INSPECTOR || (INSPECTOR = {}));
  4532. var __extends = (this && this.__extends) || (function () {
  4533. var extendStatics = Object.setPrototypeOf ||
  4534. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4535. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4536. return function (d, b) {
  4537. extendStatics(d, b);
  4538. function __() { this.constructor = d; }
  4539. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4540. };
  4541. })();
  4542. var INSPECTOR;
  4543. (function (INSPECTOR) {
  4544. /**
  4545. * Checkbox to display/hide the primitive
  4546. */
  4547. var BoundingBox = (function (_super) {
  4548. __extends(BoundingBox, _super);
  4549. function BoundingBox(obj) {
  4550. var _this = _super.call(this) || this;
  4551. _this._obj = obj;
  4552. _this._elem.classList.add('fa-square-o');
  4553. _this._on = _this._obj.isBoxVisible();
  4554. _this._check();
  4555. return _this;
  4556. }
  4557. // For a checkbox, set visible/invisible the corresponding prim
  4558. BoundingBox.prototype.action = function () {
  4559. _super.prototype.action.call(this);
  4560. // update object and gui according to the new status
  4561. this._check();
  4562. };
  4563. BoundingBox.prototype._check = function () {
  4564. if (this._on) {
  4565. // set icon eye
  4566. this._elem.classList.add('active');
  4567. }
  4568. else {
  4569. // set icon eye-slash
  4570. this._elem.classList.remove('active');
  4571. }
  4572. this._obj.setBoxVisible(this._on);
  4573. };
  4574. return BoundingBox;
  4575. }(INSPECTOR.AbstractTreeTool));
  4576. INSPECTOR.BoundingBox = BoundingBox;
  4577. })(INSPECTOR || (INSPECTOR = {}));
  4578. var __extends = (this && this.__extends) || (function () {
  4579. var extendStatics = Object.setPrototypeOf ||
  4580. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4581. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4582. return function (d, b) {
  4583. extendStatics(d, b);
  4584. function __() { this.constructor = d; }
  4585. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4586. };
  4587. })();
  4588. var INSPECTOR;
  4589. (function (INSPECTOR) {
  4590. /**
  4591. *
  4592. */
  4593. var CameraPOV = (function (_super) {
  4594. __extends(CameraPOV, _super);
  4595. function CameraPOV(camera) {
  4596. var _this = _super.call(this) || this;
  4597. _this.cameraPOV = camera;
  4598. _this._elem.classList.add('fa-video-camera');
  4599. return _this;
  4600. }
  4601. CameraPOV.prototype.action = function () {
  4602. _super.prototype.action.call(this);
  4603. this._gotoPOV();
  4604. };
  4605. CameraPOV.prototype._gotoPOV = function () {
  4606. var actives = INSPECTOR.Inspector.DOCUMENT.querySelectorAll(".fa-video-camera.active");
  4607. console.log(actives);
  4608. for (var i = 0; i < actives.length; i++) {
  4609. actives[i].classList.remove('active');
  4610. }
  4611. //if (this._on) {
  4612. // set icon camera
  4613. this._elem.classList.add('active');
  4614. //}
  4615. this.cameraPOV.setPOV();
  4616. };
  4617. return CameraPOV;
  4618. }(INSPECTOR.AbstractTreeTool));
  4619. INSPECTOR.CameraPOV = CameraPOV;
  4620. })(INSPECTOR || (INSPECTOR = {}));
  4621. var __extends = (this && this.__extends) || (function () {
  4622. var extendStatics = Object.setPrototypeOf ||
  4623. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4624. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4625. return function (d, b) {
  4626. extendStatics(d, b);
  4627. function __() { this.constructor = d; }
  4628. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4629. };
  4630. })();
  4631. var INSPECTOR;
  4632. (function (INSPECTOR) {
  4633. /**
  4634. *
  4635. */
  4636. var SoundInteractions = (function (_super) {
  4637. __extends(SoundInteractions, _super);
  4638. function SoundInteractions(playSound) {
  4639. var _this = _super.call(this) || this;
  4640. _this.playSound = playSound;
  4641. _this.b = false;
  4642. _this._elem.classList.add('fa-play');
  4643. return _this;
  4644. }
  4645. SoundInteractions.prototype.action = function () {
  4646. _super.prototype.action.call(this);
  4647. this._playSound();
  4648. };
  4649. SoundInteractions.prototype._playSound = function () {
  4650. var _this = this;
  4651. if (this._elem.classList.contains('fa-play')) {
  4652. this._elem.classList.remove('fa-play');
  4653. this._elem.classList.add('fa-pause');
  4654. }
  4655. else {
  4656. this._elem.classList.remove('fa-pause');
  4657. this._elem.classList.add('fa-play');
  4658. }
  4659. this.playSound.setPlaying(function () {
  4660. _this._elem.classList.remove('fa-pause');
  4661. _this._elem.classList.add('fa-play');
  4662. });
  4663. };
  4664. return SoundInteractions;
  4665. }(INSPECTOR.AbstractTreeTool));
  4666. INSPECTOR.SoundInteractions = SoundInteractions;
  4667. })(INSPECTOR || (INSPECTOR = {}));
  4668. var __extends = (this && this.__extends) || (function () {
  4669. var extendStatics = Object.setPrototypeOf ||
  4670. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4671. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4672. return function (d, b) {
  4673. extendStatics(d, b);
  4674. function __() { this.constructor = d; }
  4675. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4676. };
  4677. })();
  4678. var INSPECTOR;
  4679. (function (INSPECTOR) {
  4680. /**
  4681. * Checkbox to display/hide the primitive
  4682. */
  4683. var Checkbox = (function (_super) {
  4684. __extends(Checkbox, _super);
  4685. function Checkbox(obj) {
  4686. var _this = _super.call(this) || this;
  4687. _this._obj = obj;
  4688. _this._elem.classList.add('fa-eye');
  4689. _this._on = _this._obj.isVisible();
  4690. _this._check(true);
  4691. return _this;
  4692. }
  4693. // For a checkbox, set visible/invisible the corresponding prim
  4694. Checkbox.prototype.action = function () {
  4695. _super.prototype.action.call(this);
  4696. // update object and gui according to the new status
  4697. this._check();
  4698. };
  4699. Checkbox.prototype._check = function (dontEnable) {
  4700. if (this._on) {
  4701. // set icon eye
  4702. this._elem.classList.add('fa-eye');
  4703. this._elem.classList.add('active');
  4704. this._elem.classList.remove('fa-eye-slash');
  4705. }
  4706. else {
  4707. // set icon eye-slash
  4708. this._elem.classList.remove('fa-eye');
  4709. this._elem.classList.remove('active');
  4710. this._elem.classList.add('fa-eye-slash');
  4711. }
  4712. if (!dontEnable) {
  4713. this._obj.setVisible(this._on);
  4714. }
  4715. };
  4716. return Checkbox;
  4717. }(INSPECTOR.AbstractTreeTool));
  4718. INSPECTOR.Checkbox = Checkbox;
  4719. })(INSPECTOR || (INSPECTOR = {}));
  4720. var __extends = (this && this.__extends) || (function () {
  4721. var extendStatics = Object.setPrototypeOf ||
  4722. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4723. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4724. return function (d, b) {
  4725. extendStatics(d, b);
  4726. function __() { this.constructor = d; }
  4727. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4728. };
  4729. })();
  4730. var INSPECTOR;
  4731. (function (INSPECTOR) {
  4732. var DebugArea = (function (_super) {
  4733. __extends(DebugArea, _super);
  4734. function DebugArea(obj) {
  4735. var _this = _super.call(this) || this;
  4736. _this._obj = obj;
  4737. _this._elem.classList.add('fa-wrench');
  4738. return _this;
  4739. }
  4740. DebugArea.prototype.action = function () {
  4741. _super.prototype.action.call(this);
  4742. if (this._on) {
  4743. // set icon activated
  4744. this._elem.classList.add('active');
  4745. }
  4746. else {
  4747. // set icon deactivated
  4748. this._elem.classList.remove('active');
  4749. }
  4750. this._obj.debug(this._on);
  4751. };
  4752. return DebugArea;
  4753. }(INSPECTOR.AbstractTreeTool));
  4754. INSPECTOR.DebugArea = DebugArea;
  4755. })(INSPECTOR || (INSPECTOR = {}));
  4756. var __extends = (this && this.__extends) || (function () {
  4757. var extendStatics = Object.setPrototypeOf ||
  4758. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4759. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4760. return function (d, b) {
  4761. extendStatics(d, b);
  4762. function __() { this.constructor = d; }
  4763. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4764. };
  4765. })();
  4766. var INSPECTOR;
  4767. (function (INSPECTOR) {
  4768. /**
  4769. * Checkbox to display/hide the primitive
  4770. */
  4771. var Info = (function (_super) {
  4772. __extends(Info, _super);
  4773. function Info(obj) {
  4774. var _this = _super.call(this) || this;
  4775. _this._obj = obj;
  4776. _this._elem.classList.add('fa-info-circle');
  4777. _this._tooltip = new INSPECTOR.Tooltip(_this._elem, _this._obj.getInfo(), _this._elem);
  4778. return _this;
  4779. }
  4780. // Nothing to do on click
  4781. Info.prototype.action = function () {
  4782. _super.prototype.action.call(this);
  4783. };
  4784. return Info;
  4785. }(INSPECTOR.AbstractTreeTool));
  4786. INSPECTOR.Info = Info;
  4787. })(INSPECTOR || (INSPECTOR = {}));