babylon.inspector.js 205 KB

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