babylon.inspector.js 217 KB

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