babylon.inspector.js 213 KB

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