babylon.inspector.js 242 KB

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