babylon.inspector.js 228 KB

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