babylon.inspector.js 228 KB

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