babylon.inspector.js 225 KB

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