babylon.inspector.js 201 KB

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