babylon.inspector.js 210 KB

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