babylon.inspector.js 221 KB

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