babylon.inspector.js 210 KB

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