babylon.inspector.js 217 KB

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