babylon.inspector.js 211 KB

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