babylon.inspector.js 217 KB

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