babylon.inspector.js 215 KB

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