babylon.inspector.js 216 KB

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