babylon.inspector.js 223 KB

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