babylon.inspector.js 210 KB

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