babylon.inspector.js 228 KB

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