babylon.inspector.js 225 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170
  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. var __extends = (this && this.__extends) || (function () {
  3971. var extendStatics = Object.setPrototypeOf ||
  3972. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3973. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3974. return function (d, b) {
  3975. extendStatics(d, b);
  3976. function __() { this.constructor = d; }
  3977. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3978. };
  3979. })();
  3980. var INSPECTOR;
  3981. (function (INSPECTOR) {
  3982. /**
  3983. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  3984. * The default active tab is the first one of the list.
  3985. */
  3986. var TabBar = /** @class */ (function (_super) {
  3987. __extends(TabBar, _super);
  3988. function TabBar(inspector, initialTab) {
  3989. var _this = _super.call(this) || this;
  3990. // The list of available tabs
  3991. _this._tabs = [];
  3992. /** The list of tab displayed by clicking on the remainingIcon */
  3993. _this._invisibleTabs = [];
  3994. /** The list of tabs visible, displayed in the tab bar */
  3995. _this._visibleTabs = [];
  3996. _this._inspector = inspector;
  3997. _this._tabs.push(new INSPECTOR.SceneTab(_this, _this._inspector));
  3998. _this._tabs.push(new INSPECTOR.ConsoleTab(_this, _this._inspector));
  3999. _this._tabs.push(new INSPECTOR.StatsTab(_this, _this._inspector));
  4000. _this._meshTab = new INSPECTOR.MeshTab(_this, _this._inspector);
  4001. _this._tabs.push(new INSPECTOR.TextureTab(_this, _this._inspector));
  4002. _this._tabs.push(_this._meshTab);
  4003. _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
  4004. _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
  4005. if (BABYLON.GUI) {
  4006. _this._tabs.push(new INSPECTOR.GUITab(_this, _this._inspector));
  4007. }
  4008. _this._tabs.push(new INSPECTOR.PhysicsTab(_this, _this._inspector));
  4009. _this._tabs.push(new INSPECTOR.CameraTab(_this, _this._inspector));
  4010. _this._tabs.push(new INSPECTOR.SoundTab(_this, _this._inspector));
  4011. _this._toolBar = new INSPECTOR.Toolbar(_this._inspector);
  4012. _this._build();
  4013. //Check initialTab is defined and between tabs bounds
  4014. if (!initialTab || initialTab < 0 || initialTab >= _this._tabs.length) {
  4015. initialTab = 0;
  4016. }
  4017. _this._tabs[initialTab].active(true);
  4018. // set all tab as visible
  4019. for (var _i = 0, _a = _this._tabs; _i < _a.length; _i++) {
  4020. var tab = _a[_i];
  4021. _this._visibleTabs.push(tab);
  4022. }
  4023. return _this;
  4024. }
  4025. // No update
  4026. TabBar.prototype.update = function () { };
  4027. TabBar.prototype._build = function () {
  4028. var _this = this;
  4029. this._div.className = 'tabbar';
  4030. this._div.appendChild(this._toolBar.toHtml());
  4031. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  4032. var tab = _a[_i];
  4033. this._div.appendChild(tab.toHtml());
  4034. }
  4035. this._moreTabsIcon = INSPECTOR.Helpers.CreateElement('i', 'fa fa-angle-double-right more-tabs');
  4036. this._moreTabsPanel = INSPECTOR.Helpers.CreateDiv('more-tabs-panel');
  4037. this._moreTabsIcon.addEventListener('click', function () {
  4038. // Hide the 'more-tabs-panel' if already displayed
  4039. if (_this._moreTabsPanel.style.display == 'flex') {
  4040. _this._moreTabsPanel.style.display = 'none';
  4041. }
  4042. else {
  4043. // Attach more-tabs-panel if not attached yet
  4044. var topPanel = _this._div.parentNode;
  4045. if (!topPanel.contains(_this._moreTabsPanel)) {
  4046. topPanel.appendChild(_this._moreTabsPanel);
  4047. }
  4048. // Clean the 'more-tabs-panel'
  4049. INSPECTOR.Helpers.CleanDiv(_this._moreTabsPanel);
  4050. // Add each invisible tabs to this panel
  4051. for (var _i = 0, _a = _this._invisibleTabs; _i < _a.length; _i++) {
  4052. var tab = _a[_i];
  4053. _this._addInvisibleTabToPanel(tab);
  4054. }
  4055. // And display it
  4056. _this._moreTabsPanel.style.display = 'flex';
  4057. }
  4058. });
  4059. };
  4060. /**
  4061. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  4062. * 'more-tabs' icon
  4063. */
  4064. TabBar.prototype._addInvisibleTabToPanel = function (tab) {
  4065. var _this = this;
  4066. var div = INSPECTOR.Helpers.CreateDiv('invisible-tab', this._moreTabsPanel);
  4067. div.textContent = tab.name;
  4068. div.addEventListener('click', function () {
  4069. _this._moreTabsPanel.style.display = 'none';
  4070. _this.switchTab(tab);
  4071. });
  4072. };
  4073. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  4074. TabBar.prototype.switchTab = function (tab) {
  4075. // Dispose the active tab
  4076. var activeTab = this.getActiveTab();
  4077. if (activeTab) {
  4078. activeTab.dispose();
  4079. }
  4080. // Deactivate all tabs
  4081. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  4082. var t = _a[_i];
  4083. t.active(false);
  4084. }
  4085. // activate the given tab
  4086. tab.active(true);
  4087. // Refresh the inspector
  4088. this._inspector.refresh();
  4089. };
  4090. /** Display the mesh tab.
  4091. * If a parameter is given, the given mesh details are displayed
  4092. */
  4093. TabBar.prototype.switchMeshTab = function (mesh) {
  4094. this.switchTab(this._meshTab);
  4095. if (mesh) {
  4096. var item = this._meshTab.getItemFor(mesh);
  4097. if (item) {
  4098. this._meshTab.select(item);
  4099. }
  4100. }
  4101. };
  4102. /** Returns the active tab */
  4103. TabBar.prototype.getActiveTab = function () {
  4104. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  4105. var tab = _a[_i];
  4106. if (tab.isActive()) {
  4107. return tab;
  4108. }
  4109. }
  4110. return null;
  4111. };
  4112. TabBar.prototype.getActiveTabIndex = function () {
  4113. for (var i = 0; i < this._tabs.length; i++) {
  4114. if (this._tabs[i].isActive()) {
  4115. return i;
  4116. }
  4117. }
  4118. return 0;
  4119. };
  4120. Object.defineProperty(TabBar.prototype, "inspector", {
  4121. get: function () {
  4122. return this._inspector;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. /**
  4128. * Returns the total width in pixel of the tabbar,
  4129. * that corresponds to the sum of the width of each visible tab + toolbar width
  4130. */
  4131. TabBar.prototype.getPixelWidth = function () {
  4132. var sum = 0;
  4133. for (var _i = 0, _a = this._visibleTabs; _i < _a.length; _i++) {
  4134. var tab = _a[_i];
  4135. sum += tab.getPixelWidth();
  4136. }
  4137. sum += this._toolBar.getPixelWidth();
  4138. if (this._div.contains(this._moreTabsIcon)) {
  4139. sum += 30; // $tabbarheight
  4140. }
  4141. return sum;
  4142. };
  4143. /** Display the remaining icon or not depending on the tabbar width.
  4144. * This function should be called each time the inspector width is updated
  4145. */
  4146. TabBar.prototype.updateWidth = function () {
  4147. if (!this._div.parentElement) {
  4148. return;
  4149. }
  4150. var parentSize = this._div.parentElement.clientWidth;
  4151. var lastTabWidth = 75;
  4152. var currentSize = this.getPixelWidth();
  4153. // Check if a tab should be removed : if the tab bar width is greater than
  4154. // its parent width
  4155. while (this._visibleTabs.length > 0 && currentSize > parentSize) {
  4156. // Start by the last element
  4157. var tab = this._visibleTabs.pop();
  4158. if (!tab) {
  4159. break;
  4160. }
  4161. // set it invisible
  4162. this._invisibleTabs.push(tab);
  4163. // and removes it from the DOM
  4164. this._div.removeChild(tab.toHtml());
  4165. currentSize = this.getPixelWidth() + lastTabWidth;
  4166. }
  4167. // Check if a tab can be added to the tab bar : if the tab bar width
  4168. // + 100 (at least 100px is needed to add a tab) is less than its parent width
  4169. if (this._invisibleTabs.length > 0) {
  4170. if (currentSize + lastTabWidth < parentSize) {
  4171. var lastTab = this._invisibleTabs.pop();
  4172. if (lastTab) {
  4173. this._div.appendChild(lastTab.toHtml());
  4174. this._visibleTabs.push(lastTab);
  4175. }
  4176. // Update more-tab icon in last position if needed
  4177. if (this._div.contains(this._moreTabsIcon)) {
  4178. this._div.removeChild(this._moreTabsIcon);
  4179. }
  4180. }
  4181. }
  4182. if (this._invisibleTabs.length > 0 && !this._div.contains(this._moreTabsIcon)) {
  4183. this._div.appendChild(this._moreTabsIcon);
  4184. }
  4185. };
  4186. return TabBar;
  4187. }(INSPECTOR.BasicElement));
  4188. INSPECTOR.TabBar = TabBar;
  4189. })(INSPECTOR || (INSPECTOR = {}));
  4190. var INSPECTOR;
  4191. (function (INSPECTOR) {
  4192. var AbstractTool = /** @class */ (function () {
  4193. function AbstractTool(icon, parent, inspector, tooltip) {
  4194. var _this = this;
  4195. this._inspector = inspector;
  4196. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  4197. this._elem.className = "tool fa " + icon;
  4198. parent.appendChild(this._elem);
  4199. this._elem.addEventListener('click', function (e) {
  4200. _this.action();
  4201. });
  4202. new INSPECTOR.Tooltip(this._elem, tooltip);
  4203. }
  4204. AbstractTool.prototype.toHtml = function () {
  4205. return this._elem;
  4206. };
  4207. /**
  4208. * Returns the total width in pixel of this tool, 0 by default
  4209. */
  4210. AbstractTool.prototype.getPixelWidth = function () {
  4211. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._elem);
  4212. if (!style.marginLeft || !style.marginRight) {
  4213. return 0;
  4214. }
  4215. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  4216. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  4217. return (this._elem.clientWidth || 0) + left + right;
  4218. };
  4219. /**
  4220. * Updates the icon of this tool with the given string
  4221. */
  4222. AbstractTool.prototype._updateIcon = function (icon) {
  4223. this._elem.className = "tool fa " + icon;
  4224. };
  4225. return AbstractTool;
  4226. }());
  4227. INSPECTOR.AbstractTool = AbstractTool;
  4228. })(INSPECTOR || (INSPECTOR = {}));
  4229. var __extends = (this && this.__extends) || (function () {
  4230. var extendStatics = Object.setPrototypeOf ||
  4231. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4232. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4233. return function (d, b) {
  4234. extendStatics(d, b);
  4235. function __() { this.constructor = d; }
  4236. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4237. };
  4238. })();
  4239. var INSPECTOR;
  4240. (function (INSPECTOR) {
  4241. var PauseScheduleTool = /** @class */ (function (_super) {
  4242. __extends(PauseScheduleTool, _super);
  4243. function PauseScheduleTool(parent, inspector) {
  4244. var _this = _super.call(this, 'fa-pause', parent, inspector, 'Pause the automatic update of properties') || this;
  4245. _this._isPause = false;
  4246. return _this;
  4247. }
  4248. // Action : refresh the whole panel
  4249. PauseScheduleTool.prototype.action = function () {
  4250. if (this._isPause) {
  4251. INSPECTOR.Scheduler.getInstance().pause = false;
  4252. this._updateIcon('fa-pause');
  4253. }
  4254. else {
  4255. INSPECTOR.Scheduler.getInstance().pause = true;
  4256. this._updateIcon('fa-play');
  4257. }
  4258. this._isPause = !this._isPause;
  4259. };
  4260. return PauseScheduleTool;
  4261. }(INSPECTOR.AbstractTool));
  4262. INSPECTOR.PauseScheduleTool = PauseScheduleTool;
  4263. })(INSPECTOR || (INSPECTOR = {}));
  4264. var __extends = (this && this.__extends) || (function () {
  4265. var extendStatics = Object.setPrototypeOf ||
  4266. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4267. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4268. return function (d, b) {
  4269. extendStatics(d, b);
  4270. function __() { this.constructor = d; }
  4271. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4272. };
  4273. })();
  4274. var INSPECTOR;
  4275. (function (INSPECTOR) {
  4276. var PickTool = /** @class */ (function (_super) {
  4277. __extends(PickTool, _super);
  4278. function PickTool(parent, inspector) {
  4279. var _this = _super.call(this, 'fa-mouse-pointer', parent, inspector, 'Select a mesh in the scene') || this;
  4280. _this._isActive = false;
  4281. // Create handler
  4282. _this._pickHandler = _this._pickMesh.bind(_this);
  4283. return _this;
  4284. }
  4285. // Action : find the corresponding tree item in the correct tab and display it
  4286. PickTool.prototype.action = function () {
  4287. if (this._isActive) {
  4288. this._deactivate();
  4289. }
  4290. else {
  4291. this.toHtml().classList.add('active');
  4292. // Add event handler : pick on a mesh in the scene
  4293. var canvas = this._inspector.scene.getEngine().getRenderingCanvas();
  4294. canvas.addEventListener('click', this._pickHandler);
  4295. this._isActive = true;
  4296. }
  4297. };
  4298. /** Deactivate this tool */
  4299. PickTool.prototype._deactivate = function () {
  4300. this.toHtml().classList.remove('active');
  4301. // Remove event handler
  4302. var canvas = this._inspector.scene.getEngine().getRenderingCanvas();
  4303. canvas.removeEventListener('click', this._pickHandler);
  4304. this._isActive = false;
  4305. };
  4306. /** Pick a mesh in the scene */
  4307. PickTool.prototype._pickMesh = function (evt) {
  4308. var pos = this._updatePointerPosition(evt);
  4309. var pi = this._inspector.scene.pick(pos.x, pos.y, function (mesh) { return true; });
  4310. if (pi && pi.pickedMesh) {
  4311. this._inspector.displayObjectDetails(pi.pickedMesh);
  4312. }
  4313. this._deactivate();
  4314. };
  4315. PickTool.prototype._updatePointerPosition = function (evt) {
  4316. var canvasRect = this._inspector.scene.getEngine().getRenderingCanvasClientRect();
  4317. var pointerX = evt.clientX - canvasRect.left;
  4318. var pointerY = evt.clientY - canvasRect.top;
  4319. return { x: pointerX, y: pointerY };
  4320. };
  4321. ;
  4322. return PickTool;
  4323. }(INSPECTOR.AbstractTool));
  4324. INSPECTOR.PickTool = PickTool;
  4325. })(INSPECTOR || (INSPECTOR = {}));
  4326. var __extends = (this && this.__extends) || (function () {
  4327. var extendStatics = Object.setPrototypeOf ||
  4328. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4329. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4330. return function (d, b) {
  4331. extendStatics(d, b);
  4332. function __() { this.constructor = d; }
  4333. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4334. };
  4335. })();
  4336. var INSPECTOR;
  4337. (function (INSPECTOR) {
  4338. var PopupTool = /** @class */ (function (_super) {
  4339. __extends(PopupTool, _super);
  4340. function PopupTool(parent, inspector) {
  4341. return _super.call(this, 'fa-external-link', parent, inspector, 'Open the inspector in a popup') || this;
  4342. }
  4343. // Action : refresh the whole panel
  4344. PopupTool.prototype.action = function () {
  4345. this._inspector.openPopup();
  4346. };
  4347. return PopupTool;
  4348. }(INSPECTOR.AbstractTool));
  4349. INSPECTOR.PopupTool = PopupTool;
  4350. })(INSPECTOR || (INSPECTOR = {}));
  4351. var __extends = (this && this.__extends) || (function () {
  4352. var extendStatics = Object.setPrototypeOf ||
  4353. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4354. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4355. return function (d, b) {
  4356. extendStatics(d, b);
  4357. function __() { this.constructor = d; }
  4358. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4359. };
  4360. })();
  4361. var INSPECTOR;
  4362. (function (INSPECTOR) {
  4363. var RefreshTool = /** @class */ (function (_super) {
  4364. __extends(RefreshTool, _super);
  4365. function RefreshTool(parent, inspector) {
  4366. return _super.call(this, 'fa-refresh', parent, inspector, 'Refresh the current tab') || this;
  4367. }
  4368. // Action : refresh the whole panel
  4369. RefreshTool.prototype.action = function () {
  4370. this._inspector.refresh();
  4371. };
  4372. return RefreshTool;
  4373. }(INSPECTOR.AbstractTool));
  4374. INSPECTOR.RefreshTool = RefreshTool;
  4375. })(INSPECTOR || (INSPECTOR = {}));
  4376. var __extends = (this && this.__extends) || (function () {
  4377. var extendStatics = Object.setPrototypeOf ||
  4378. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4379. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4380. return function (d, b) {
  4381. extendStatics(d, b);
  4382. function __() { this.constructor = d; }
  4383. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4384. };
  4385. })();
  4386. var INSPECTOR;
  4387. (function (INSPECTOR) {
  4388. var LabelTool = /** @class */ (function (_super) {
  4389. __extends(LabelTool, _super);
  4390. function LabelTool(parent, inspector) {
  4391. var _this = _super.call(this, 'fa-tags', parent, inspector, 'Display mesh names on the canvas') || this;
  4392. /** True if label are displayed, false otherwise */
  4393. _this._isDisplayed = false;
  4394. _this._advancedTexture = null;
  4395. _this._labelInitialized = false;
  4396. _this._scene = null;
  4397. _this._guiLoaded = false;
  4398. _this._scene = inspector.scene;
  4399. return _this;
  4400. }
  4401. LabelTool.prototype.dispose = function () {
  4402. if (this._advancedTexture) {
  4403. this._advancedTexture.dispose();
  4404. }
  4405. };
  4406. LabelTool.prototype._checkGUILoaded = function () {
  4407. if (this._guiLoaded === true) {
  4408. return true;
  4409. }
  4410. if (BABYLON.GUI) {
  4411. this._guiLoaded = true;
  4412. }
  4413. return this._guiLoaded;
  4414. };
  4415. LabelTool.prototype._initializeLabels = function () {
  4416. var _this = this;
  4417. // Check if the label are already initialized and quit if it's the case
  4418. if (this._labelInitialized || !this._scene) {
  4419. return;
  4420. }
  4421. // Can't initialize them if the GUI lib is not loaded yet
  4422. if (!this._checkGUILoaded()) {
  4423. return;
  4424. }
  4425. // Create the canvas that will be used to display the labels
  4426. this._advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");
  4427. // Create label for all the Meshes, Lights and Cameras
  4428. // Those that will be created/removed after this method is called will be taken care by the event handlers added below
  4429. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  4430. var m = _a[_i];
  4431. this._createLabel(m);
  4432. }
  4433. this._scene.onNewMeshAddedObservable.add(function (m, s) {
  4434. _this._createLabel(m);
  4435. });
  4436. this._scene.onMeshRemovedObservable.add(function (m, s) {
  4437. _this._removeLabel(m);
  4438. });
  4439. this._labelInitialized = true;
  4440. };
  4441. LabelTool.prototype._createLabel = function (mesh) {
  4442. // Don't create label for "system nodes" (starting and ending with ###)
  4443. var name = mesh.name;
  4444. if (INSPECTOR.Helpers.IsSystemName(name)) {
  4445. return;
  4446. }
  4447. if (mesh && this._advancedTexture) {
  4448. var rect1 = new BABYLON.GUI.Rectangle();
  4449. rect1.width = 4 + 10 * name.length + "px";
  4450. rect1.height = "22px";
  4451. rect1.background = "rgba(0,0,0,0.6)";
  4452. rect1.color = "black";
  4453. this._advancedTexture.addControl(rect1);
  4454. var label = new BABYLON.GUI.TextBlock();
  4455. label.text = name;
  4456. label.fontSize = 12;
  4457. rect1.addControl(label);
  4458. rect1.linkWithMesh(mesh);
  4459. }
  4460. };
  4461. LabelTool.prototype._removeLabel = function (mesh) {
  4462. if (!this._advancedTexture) {
  4463. return;
  4464. }
  4465. for (var _i = 0, _a = this._advancedTexture._rootContainer.children; _i < _a.length; _i++) {
  4466. var g = _a[_i];
  4467. var ed = g._linkedMesh;
  4468. if (ed === mesh) {
  4469. this._advancedTexture.removeControl(g);
  4470. break;
  4471. }
  4472. }
  4473. };
  4474. // Action : Display/hide mesh names on the canvas
  4475. LabelTool.prototype.action = function () {
  4476. // Don't toggle if the script is not loaded
  4477. if (!this._checkGUILoaded() || !this._advancedTexture) {
  4478. return;
  4479. }
  4480. // Toggle the label display state
  4481. this._isDisplayed = !this._isDisplayed;
  4482. // Check if we have to display the labels
  4483. if (this._isDisplayed) {
  4484. this._initializeLabels();
  4485. this._advancedTexture._rootContainer.isVisible = true;
  4486. }
  4487. // Or to hide them
  4488. else {
  4489. this._advancedTexture._rootContainer.isVisible = false;
  4490. }
  4491. };
  4492. return LabelTool;
  4493. }(INSPECTOR.AbstractTool));
  4494. INSPECTOR.LabelTool = LabelTool;
  4495. })(INSPECTOR || (INSPECTOR = {}));
  4496. var __extends = (this && this.__extends) || (function () {
  4497. var extendStatics = Object.setPrototypeOf ||
  4498. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4499. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4500. return function (d, b) {
  4501. extendStatics(d, b);
  4502. function __() { this.constructor = d; }
  4503. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4504. };
  4505. })();
  4506. var INSPECTOR;
  4507. (function (INSPECTOR) {
  4508. var Toolbar = /** @class */ (function (_super) {
  4509. __extends(Toolbar, _super);
  4510. function Toolbar(inspector) {
  4511. var _this = _super.call(this) || this;
  4512. _this._tools = [];
  4513. _this._inspector = inspector;
  4514. _this._build();
  4515. _this._addTools();
  4516. return _this;
  4517. }
  4518. // A toolbar cannot be updated
  4519. Toolbar.prototype.update = function () { };
  4520. ;
  4521. Toolbar.prototype._build = function () {
  4522. this._div.className = 'toolbar';
  4523. };
  4524. ;
  4525. Toolbar.prototype._addTools = function () {
  4526. // Refresh
  4527. this._tools.push(new INSPECTOR.RefreshTool(this._div, this._inspector));
  4528. // Display labels
  4529. this._tools.push(new INSPECTOR.LabelTool(this._div, this._inspector));
  4530. // Pick object
  4531. this._tools.push(new INSPECTOR.PickTool(this._div, this._inspector));
  4532. // Add the popup mode only if the inspector is not in popup mode and if the brower is not edge
  4533. // Edge is
  4534. if (!this._inspector.popupMode && !INSPECTOR.Helpers.IsBrowserEdge()) {
  4535. this._tools.push(new INSPECTOR.PopupTool(this._div, this._inspector));
  4536. }
  4537. // FullScreen
  4538. this._tools.push(new INSPECTOR.FullscreenTool(this._div, this._inspector));
  4539. // Pause schedule
  4540. this._tools.push(new INSPECTOR.PauseScheduleTool(this._div, this._inspector));
  4541. // Pause schedule
  4542. this._tools.push(new INSPECTOR.DisposeTool(this._div, this._inspector));
  4543. };
  4544. /**
  4545. * Returns the total width in pixel of the tabbar,
  4546. * that corresponds to the sum of the width of each tab + toolbar width
  4547. */
  4548. Toolbar.prototype.getPixelWidth = function () {
  4549. var sum = 0;
  4550. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4551. var tool = _a[_i];
  4552. sum += tool.getPixelWidth();
  4553. }
  4554. return sum;
  4555. };
  4556. return Toolbar;
  4557. }(INSPECTOR.BasicElement));
  4558. INSPECTOR.Toolbar = Toolbar;
  4559. })(INSPECTOR || (INSPECTOR = {}));
  4560. var __extends = (this && this.__extends) || (function () {
  4561. var extendStatics = Object.setPrototypeOf ||
  4562. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4563. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4564. return function (d, b) {
  4565. extendStatics(d, b);
  4566. function __() { this.constructor = d; }
  4567. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4568. };
  4569. })();
  4570. var INSPECTOR;
  4571. (function (INSPECTOR) {
  4572. /**
  4573. * Removes the inspector panel
  4574. */
  4575. var DisposeTool = /** @class */ (function (_super) {
  4576. __extends(DisposeTool, _super);
  4577. function DisposeTool(parent, inspector) {
  4578. return _super.call(this, 'fa-times', parent, inspector, 'Close the inspector panel') || this;
  4579. }
  4580. // Action : refresh the whole panel
  4581. DisposeTool.prototype.action = function () {
  4582. this._inspector.dispose();
  4583. };
  4584. return DisposeTool;
  4585. }(INSPECTOR.AbstractTool));
  4586. INSPECTOR.DisposeTool = DisposeTool;
  4587. })(INSPECTOR || (INSPECTOR = {}));
  4588. var __extends = (this && this.__extends) || (function () {
  4589. var extendStatics = Object.setPrototypeOf ||
  4590. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4591. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4592. return function (d, b) {
  4593. extendStatics(d, b);
  4594. function __() { this.constructor = d; }
  4595. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4596. };
  4597. })();
  4598. var INSPECTOR;
  4599. (function (INSPECTOR) {
  4600. var FullscreenTool = /** @class */ (function (_super) {
  4601. __extends(FullscreenTool, _super);
  4602. function FullscreenTool(parent, inspector) {
  4603. return _super.call(this, 'fa-expand', parent, inspector, 'Open the scene in fullscreen, press Esc to exit') || this;
  4604. }
  4605. // Action : refresh the whole panel
  4606. FullscreenTool.prototype.action = function () {
  4607. var elem = document.body;
  4608. function requestFullScreen(element) {
  4609. // Supports most browsers and their versions.
  4610. var requestMethod = element.requestFullscreen || element.webkitRequestFullScreen;
  4611. requestMethod.call(element);
  4612. }
  4613. requestFullScreen(elem);
  4614. };
  4615. return FullscreenTool;
  4616. }(INSPECTOR.AbstractTool));
  4617. INSPECTOR.FullscreenTool = FullscreenTool;
  4618. })(INSPECTOR || (INSPECTOR = {}));
  4619. var __extends = (this && this.__extends) || (function () {
  4620. var extendStatics = Object.setPrototypeOf ||
  4621. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4622. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4623. return function (d, b) {
  4624. extendStatics(d, b);
  4625. function __() { this.constructor = d; }
  4626. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4627. };
  4628. })();
  4629. var INSPECTOR;
  4630. (function (INSPECTOR) {
  4631. var TreeItem = /** @class */ (function (_super) {
  4632. __extends(TreeItem, _super);
  4633. function TreeItem(tab, obj) {
  4634. var _this = _super.call(this) || this;
  4635. _this.children = [];
  4636. _this._tab = tab;
  4637. _this._adapter = obj;
  4638. _this._tools = _this._adapter.getTools();
  4639. _this._build();
  4640. return _this;
  4641. }
  4642. Object.defineProperty(TreeItem.prototype, "id", {
  4643. /** Returns the item ID == its adapter ID */
  4644. get: function () {
  4645. return this._adapter.id();
  4646. },
  4647. enumerable: true,
  4648. configurable: true
  4649. });
  4650. /** Add the given item as a child of this one */
  4651. TreeItem.prototype.add = function (child) {
  4652. this.children.push(child);
  4653. this.update();
  4654. };
  4655. Object.defineProperty(TreeItem.prototype, "adapter", {
  4656. /**
  4657. * Returns the original adapter
  4658. */
  4659. get: function () {
  4660. return this._adapter;
  4661. },
  4662. enumerable: true,
  4663. configurable: true
  4664. });
  4665. /**
  4666. * Function used to compare this item to another tree item.
  4667. * Returns the alphabetical sort of the adapter ID
  4668. */
  4669. TreeItem.prototype.compareTo = function (item) {
  4670. var str1 = this.id;
  4671. var str2 = item.id;
  4672. return str1.localeCompare(str2, [], { numeric: true });
  4673. };
  4674. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  4675. TreeItem.prototype.correspondsTo = function (obj) {
  4676. return this._adapter.correspondsTo(obj);
  4677. };
  4678. /** hide all children of this item */
  4679. TreeItem.prototype.fold = function () {
  4680. // Do nothing id no children
  4681. if (this.children.length > 0) {
  4682. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4683. var elem = _a[_i];
  4684. elem.toHtml().style.display = 'none';
  4685. }
  4686. this._div.classList.add('folded');
  4687. this._div.classList.remove('unfolded');
  4688. }
  4689. };
  4690. /** Show all children of this item */
  4691. TreeItem.prototype.unfold = function () {
  4692. // Do nothing id no children
  4693. if (this.children.length > 0) {
  4694. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4695. var elem = _a[_i];
  4696. elem.toHtml().style.display = 'block';
  4697. }
  4698. this._div.classList.add('unfolded');
  4699. this._div.classList.remove('folded');
  4700. }
  4701. };
  4702. /** Build the HTML of this item */
  4703. TreeItem.prototype._build = function () {
  4704. /**
  4705. * Hide the debug objects :
  4706. * - Axis : xline, yline, zline
  4707. * */
  4708. var adapterId = this._adapter.id();
  4709. if (adapterId == "xline"
  4710. || adapterId == "yline"
  4711. || adapterId == "zline") {
  4712. this._div.className = "line_invisible";
  4713. }
  4714. else
  4715. this._div.className = 'line';
  4716. // special class for transform node ONLY
  4717. if (this.adapter instanceof INSPECTOR.MeshAdapter) {
  4718. var obj = this.adapter.object;
  4719. if (obj instanceof BABYLON.TransformNode && !(obj instanceof BABYLON.AbstractMesh)) {
  4720. this._div.className += ' transformNode';
  4721. }
  4722. }
  4723. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4724. var tool = _a[_i];
  4725. this._div.appendChild(tool.toHtml());
  4726. }
  4727. // Id
  4728. var text = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  4729. text.textContent = this._adapter.id();
  4730. this._div.appendChild(text);
  4731. // Type
  4732. var type = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  4733. type.className = 'property-type';
  4734. if (this._adapter.type() !== 'type_not_defined') {
  4735. type.textContent = ' - ' + this._adapter.type();
  4736. }
  4737. this._div.appendChild(type);
  4738. this._lineContent = INSPECTOR.Helpers.CreateDiv('line-content', this._div);
  4739. this._addEvent();
  4740. };
  4741. /**
  4742. * Returns one HTML element (.details) containing all details of this primitive
  4743. */
  4744. TreeItem.prototype.getDetails = function () {
  4745. return this._adapter.getProperties();
  4746. };
  4747. TreeItem.prototype.update = function () {
  4748. // Clean division holding all children
  4749. INSPECTOR.Helpers.CleanDiv(this._lineContent);
  4750. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4751. var child = _a[_i];
  4752. var elem = child.toHtml();
  4753. this._lineContent.appendChild(elem);
  4754. }
  4755. if (this.children.length > 0) {
  4756. // Check if folded or not
  4757. if (!this._div.classList.contains('folded') && !this._div.classList.contains('unfolded')) {
  4758. this._div.classList.add('folded');
  4759. }
  4760. }
  4761. this.fold();
  4762. };
  4763. /**
  4764. * Add an event listener on the item :
  4765. * - one click display details
  4766. */
  4767. TreeItem.prototype._addEvent = function () {
  4768. var _this = this;
  4769. this._div.addEventListener('click', function (e) {
  4770. _this._tab.select(_this);
  4771. // Fold/unfold the tree
  4772. if (_this._isFolded()) {
  4773. _this.unfold();
  4774. }
  4775. else {
  4776. _this.fold();
  4777. }
  4778. e.stopPropagation();
  4779. });
  4780. };
  4781. /** Returns true if the node is folded, false otherwise */
  4782. TreeItem.prototype._isFolded = function () {
  4783. return !this._div.classList.contains('unfolded');
  4784. };
  4785. /** Set this item as active (background lighter) in the tree panel */
  4786. TreeItem.prototype.active = function (b) {
  4787. this._div.classList.remove('active');
  4788. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4789. var child = _a[_i];
  4790. child.active(false);
  4791. }
  4792. if (b) {
  4793. this._div.classList.add('active');
  4794. }
  4795. };
  4796. TreeItem.prototype.getDiv = function () {
  4797. return this._div;
  4798. };
  4799. return TreeItem;
  4800. }(INSPECTOR.BasicElement));
  4801. INSPECTOR.TreeItem = TreeItem;
  4802. })(INSPECTOR || (INSPECTOR = {}));
  4803. var INSPECTOR;
  4804. (function (INSPECTOR) {
  4805. var AbstractTreeTool = /** @class */ (function () {
  4806. function AbstractTreeTool() {
  4807. /** Is the tool enabled ? */
  4808. this._on = false;
  4809. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  4810. this._elem.className = 'treeTool fa';
  4811. this._addEvents();
  4812. }
  4813. AbstractTreeTool.prototype.toHtml = function () {
  4814. return this._elem;
  4815. };
  4816. AbstractTreeTool.prototype._addEvents = function () {
  4817. var _this = this;
  4818. this._elem.addEventListener('click', function (e) {
  4819. _this.action();
  4820. e.stopPropagation();
  4821. });
  4822. };
  4823. /**
  4824. * Action launched when clicked on this element
  4825. * Should be overrided
  4826. */
  4827. AbstractTreeTool.prototype.action = function () {
  4828. this._on = !this._on;
  4829. };
  4830. return AbstractTreeTool;
  4831. }());
  4832. INSPECTOR.AbstractTreeTool = AbstractTreeTool;
  4833. })(INSPECTOR || (INSPECTOR = {}));
  4834. var __extends = (this && this.__extends) || (function () {
  4835. var extendStatics = Object.setPrototypeOf ||
  4836. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4837. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4838. return function (d, b) {
  4839. extendStatics(d, b);
  4840. function __() { this.constructor = d; }
  4841. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4842. };
  4843. })();
  4844. var INSPECTOR;
  4845. (function (INSPECTOR) {
  4846. /**
  4847. * Checkbox to display/hide the primitive
  4848. */
  4849. var BoundingBox = /** @class */ (function (_super) {
  4850. __extends(BoundingBox, _super);
  4851. function BoundingBox(obj) {
  4852. var _this = _super.call(this) || this;
  4853. _this._obj = obj;
  4854. _this._elem.classList.add('fa-square-o');
  4855. _this._on = _this._obj.isBoxVisible();
  4856. _this._check();
  4857. return _this;
  4858. }
  4859. // For a checkbox, set visible/invisible the corresponding prim
  4860. BoundingBox.prototype.action = function () {
  4861. _super.prototype.action.call(this);
  4862. // update object and gui according to the new status
  4863. this._check();
  4864. };
  4865. BoundingBox.prototype._check = function () {
  4866. if (this._on) {
  4867. // set icon eye
  4868. this._elem.classList.add('active');
  4869. }
  4870. else {
  4871. // set icon eye-slash
  4872. this._elem.classList.remove('active');
  4873. }
  4874. this._obj.setBoxVisible(this._on);
  4875. };
  4876. return BoundingBox;
  4877. }(INSPECTOR.AbstractTreeTool));
  4878. INSPECTOR.BoundingBox = BoundingBox;
  4879. })(INSPECTOR || (INSPECTOR = {}));
  4880. var __extends = (this && this.__extends) || (function () {
  4881. var extendStatics = Object.setPrototypeOf ||
  4882. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4883. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4884. return function (d, b) {
  4885. extendStatics(d, b);
  4886. function __() { this.constructor = d; }
  4887. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4888. };
  4889. })();
  4890. var INSPECTOR;
  4891. (function (INSPECTOR) {
  4892. /**
  4893. *
  4894. */
  4895. var CameraPOV = /** @class */ (function (_super) {
  4896. __extends(CameraPOV, _super);
  4897. function CameraPOV(camera) {
  4898. var _this = _super.call(this) || this;
  4899. _this.cameraPOV = camera;
  4900. // Setting the id of the line with the name of the camera
  4901. _this._elem.id = _this.cameraPOV.id();
  4902. // Put the right icon
  4903. if (_this._elem.id == _this.cameraPOV.getCurrentActiveCamera()) {
  4904. _this._elem.classList.add('fa-check-circle');
  4905. }
  4906. else {
  4907. _this._elem.classList.add('fa-circle');
  4908. }
  4909. return _this;
  4910. }
  4911. CameraPOV.prototype.action = function () {
  4912. _super.prototype.action.call(this);
  4913. this._gotoPOV();
  4914. };
  4915. CameraPOV.prototype._gotoPOV = function () {
  4916. // Uncheck all the radio buttons
  4917. var actives = INSPECTOR.Inspector.DOCUMENT.querySelectorAll(".fa-check-circle");
  4918. for (var i = 0; i < actives.length; i++) {
  4919. actives[i].classList.remove('fa-check-circle');
  4920. actives[i].classList.add('fa-circle');
  4921. }
  4922. // setting the point off view to the right camera
  4923. this.cameraPOV.setPOV();
  4924. // Check the right radio button
  4925. if (this._elem.id == this.cameraPOV.getCurrentActiveCamera()) {
  4926. this._elem.classList.remove('fa-circle');
  4927. this._elem.classList.add('fa-check-circle');
  4928. }
  4929. };
  4930. return CameraPOV;
  4931. }(INSPECTOR.AbstractTreeTool));
  4932. INSPECTOR.CameraPOV = CameraPOV;
  4933. })(INSPECTOR || (INSPECTOR = {}));
  4934. var __extends = (this && this.__extends) || (function () {
  4935. var extendStatics = Object.setPrototypeOf ||
  4936. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4937. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4938. return function (d, b) {
  4939. extendStatics(d, b);
  4940. function __() { this.constructor = d; }
  4941. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4942. };
  4943. })();
  4944. var INSPECTOR;
  4945. (function (INSPECTOR) {
  4946. /**
  4947. *
  4948. */
  4949. var SoundInteractions = /** @class */ (function (_super) {
  4950. __extends(SoundInteractions, _super);
  4951. function SoundInteractions(playSound) {
  4952. var _this = _super.call(this) || this;
  4953. _this.playSound = playSound;
  4954. _this._elem.classList.add('fa-play');
  4955. return _this;
  4956. }
  4957. SoundInteractions.prototype.action = function () {
  4958. _super.prototype.action.call(this);
  4959. this._playSound();
  4960. };
  4961. SoundInteractions.prototype._playSound = function () {
  4962. var _this = this;
  4963. if (this._elem.classList.contains('fa-play')) {
  4964. this._elem.classList.remove('fa-play');
  4965. this._elem.classList.add('fa-pause');
  4966. }
  4967. else {
  4968. this._elem.classList.remove('fa-pause');
  4969. this._elem.classList.add('fa-play');
  4970. }
  4971. this.playSound.setPlaying(function () {
  4972. _this._elem.classList.remove('fa-pause');
  4973. _this._elem.classList.add('fa-play');
  4974. });
  4975. };
  4976. return SoundInteractions;
  4977. }(INSPECTOR.AbstractTreeTool));
  4978. INSPECTOR.SoundInteractions = SoundInteractions;
  4979. })(INSPECTOR || (INSPECTOR = {}));
  4980. var __extends = (this && this.__extends) || (function () {
  4981. var extendStatics = Object.setPrototypeOf ||
  4982. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4983. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4984. return function (d, b) {
  4985. extendStatics(d, b);
  4986. function __() { this.constructor = d; }
  4987. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4988. };
  4989. })();
  4990. var INSPECTOR;
  4991. (function (INSPECTOR) {
  4992. /**
  4993. * Checkbox to display/hide the primitive
  4994. */
  4995. var Checkbox = /** @class */ (function (_super) {
  4996. __extends(Checkbox, _super);
  4997. function Checkbox(obj) {
  4998. var _this = _super.call(this) || this;
  4999. _this._obj = obj;
  5000. _this._elem.classList.add('fa-eye');
  5001. _this._on = _this._obj.isVisible();
  5002. _this._check(true);
  5003. return _this;
  5004. }
  5005. // For a checkbox, set visible/invisible the corresponding prim
  5006. Checkbox.prototype.action = function () {
  5007. _super.prototype.action.call(this);
  5008. // update object and gui according to the new status
  5009. this._check();
  5010. };
  5011. Checkbox.prototype._check = function (dontEnable) {
  5012. if (this._on) {
  5013. // set icon eye
  5014. this._elem.classList.add('fa-eye');
  5015. this._elem.classList.add('active');
  5016. this._elem.classList.remove('fa-eye-slash');
  5017. }
  5018. else {
  5019. // set icon eye-slash
  5020. this._elem.classList.remove('fa-eye');
  5021. this._elem.classList.remove('active');
  5022. this._elem.classList.add('fa-eye-slash');
  5023. }
  5024. if (!dontEnable) {
  5025. this._obj.setVisible(this._on);
  5026. }
  5027. };
  5028. return Checkbox;
  5029. }(INSPECTOR.AbstractTreeTool));
  5030. INSPECTOR.Checkbox = Checkbox;
  5031. })(INSPECTOR || (INSPECTOR = {}));
  5032. var __extends = (this && this.__extends) || (function () {
  5033. var extendStatics = Object.setPrototypeOf ||
  5034. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5035. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5036. return function (d, b) {
  5037. extendStatics(d, b);
  5038. function __() { this.constructor = d; }
  5039. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5040. };
  5041. })();
  5042. var INSPECTOR;
  5043. (function (INSPECTOR) {
  5044. var DebugArea = /** @class */ (function (_super) {
  5045. __extends(DebugArea, _super);
  5046. function DebugArea(obj) {
  5047. var _this = _super.call(this) || this;
  5048. _this._obj = obj;
  5049. _this._elem.classList.add('fa-wrench');
  5050. return _this;
  5051. }
  5052. DebugArea.prototype.action = function () {
  5053. _super.prototype.action.call(this);
  5054. if (this._on) {
  5055. // set icon activated
  5056. this._elem.classList.add('active');
  5057. }
  5058. else {
  5059. // set icon deactivated
  5060. this._elem.classList.remove('active');
  5061. }
  5062. this._obj.debug(this._on);
  5063. };
  5064. return DebugArea;
  5065. }(INSPECTOR.AbstractTreeTool));
  5066. INSPECTOR.DebugArea = DebugArea;
  5067. })(INSPECTOR || (INSPECTOR = {}));
  5068. var __extends = (this && this.__extends) || (function () {
  5069. var extendStatics = Object.setPrototypeOf ||
  5070. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5071. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5072. return function (d, b) {
  5073. extendStatics(d, b);
  5074. function __() { this.constructor = d; }
  5075. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5076. };
  5077. })();
  5078. var INSPECTOR;
  5079. (function (INSPECTOR) {
  5080. /**
  5081. * Checkbox to display/hide the primitive
  5082. */
  5083. var Info = /** @class */ (function (_super) {
  5084. __extends(Info, _super);
  5085. function Info(obj) {
  5086. var _this = _super.call(this) || this;
  5087. _this._obj = obj;
  5088. _this._elem.classList.add('fa-info-circle');
  5089. new INSPECTOR.Tooltip(_this._elem, _this._obj.getInfo(), _this._elem);
  5090. return _this;
  5091. }
  5092. // Nothing to do on click
  5093. Info.prototype.action = function () {
  5094. _super.prototype.action.call(this);
  5095. };
  5096. return Info;
  5097. }(INSPECTOR.AbstractTreeTool));
  5098. INSPECTOR.Info = Info;
  5099. })(INSPECTOR || (INSPECTOR = {}));