babylon.inspector.js 219 KB

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