babylon.inspector.js 208 KB

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